2018-04-20 07:03:53 +02:00
|
|
|
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
2010-01-20 01:00:00 +01:00
|
|
|
" Vimwiki plugin file
|
2015-02-23 12:10:42 +01:00
|
|
|
" Home: https://github.com/vimwiki/vimwiki/
|
2010-01-20 01:00:00 +01:00
|
|
|
" GetLatestVimScripts: 2226 1 :AutoInstall: vimwiki
|
|
|
|
|
2018-04-20 07:03:53 +02:00
|
|
|
|
2014-02-24 12:16:23 +01:00
|
|
|
if exists("g:loaded_vimwiki") || &cp
|
2010-01-20 01:00:00 +01:00
|
|
|
finish
|
|
|
|
endif
|
2014-02-24 12:16:23 +01:00
|
|
|
let g:loaded_vimwiki = 1
|
2010-01-20 01:00:00 +01:00
|
|
|
|
2018-06-12 20:55:56 +02:00
|
|
|
" Set to version number for release, otherwise -1 for dev-branch
|
|
|
|
let s:plugin_vers = -1
|
|
|
|
|
|
|
|
" Get the directory the script is installed in
|
|
|
|
let s:plugin_dir = expand('<sfile>:p:h:h')
|
2018-04-20 07:03:53 +02:00
|
|
|
|
2010-01-20 01:00:00 +01:00
|
|
|
let s:old_cpo = &cpo
|
|
|
|
set cpo&vim
|
|
|
|
|
2012-06-07 02:00:00 +02:00
|
|
|
|
2018-05-15 21:48:58 +02:00
|
|
|
if exists('g:vimwiki_autowriteall')
|
|
|
|
let s:vimwiki_autowriteall_saved = g:vimwiki_autowriteall
|
|
|
|
else
|
|
|
|
let s:vimwiki_autowriteall_saved = 1
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2016-12-25 21:35:56 +01:00
|
|
|
" this is called when the cursor leaves the buffer
|
2018-04-20 07:03:53 +02:00
|
|
|
function! s:setup_buffer_leave()
|
2016-12-25 21:35:56 +01:00
|
|
|
" don't do anything if it's not managed by Vimwiki (that is, when it's not in
|
|
|
|
" a registered wiki and not a temporary wiki)
|
2016-12-28 22:17:08 +01:00
|
|
|
if vimwiki#vars#get_bufferlocal('wiki_nr') == -1
|
2016-12-25 21:35:56 +01:00
|
|
|
return
|
2010-01-20 01:00:00 +01:00
|
|
|
endif
|
|
|
|
|
2016-12-25 21:35:56 +01:00
|
|
|
let &autowriteall = s:vimwiki_autowriteall_saved
|
2014-11-26 14:35:38 +01:00
|
|
|
|
2019-01-19 21:05:27 +01:00
|
|
|
if !empty(vimwiki#vars#get_global('menu'))
|
2016-12-25 21:35:56 +01:00
|
|
|
exe 'nmenu disable '.vimwiki#vars#get_global('menu').'.Table'
|
2014-11-26 14:35:38 +01:00
|
|
|
endif
|
2018-04-20 07:03:53 +02:00
|
|
|
endfunction
|
2014-11-26 14:35:38 +01:00
|
|
|
|
2012-06-07 02:00:00 +02:00
|
|
|
|
2016-12-25 21:35:56 +01:00
|
|
|
" create a new temporary wiki for the current buffer
|
|
|
|
function! s:create_temporary_wiki()
|
|
|
|
let path = expand('%:p:h')
|
|
|
|
let ext = '.'.expand('%:e')
|
2012-06-07 02:00:00 +02:00
|
|
|
|
2016-12-25 21:35:56 +01:00
|
|
|
let syntax_mapping = vimwiki#vars#get_global('ext2syntax')
|
|
|
|
if has_key(syntax_mapping, ext)
|
|
|
|
let syntax = syntax_mapping[ext]
|
|
|
|
else
|
|
|
|
let syntax = vimwiki#vars#get_wikilocal_default('syntax')
|
2012-06-07 02:00:00 +02:00
|
|
|
endif
|
2010-02-23 01:00:00 +01:00
|
|
|
|
2016-12-25 21:35:56 +01:00
|
|
|
let new_temp_wiki_settings = {'path': path,
|
|
|
|
\ 'ext': ext,
|
|
|
|
\ 'syntax': syntax,
|
|
|
|
\ }
|
2013-04-19 05:46:58 +02:00
|
|
|
|
2016-12-25 21:35:56 +01:00
|
|
|
call vimwiki#vars#add_temporary_wiki(new_temp_wiki_settings)
|
2018-05-09 22:02:07 +02:00
|
|
|
|
|
|
|
" Update the wiki number of the current buffer, because it may have changed when adding this
|
|
|
|
" temporary wiki.
|
|
|
|
call vimwiki#vars#set_bufferlocal('wiki_nr', vimwiki#base#find_wiki(expand('%:p')))
|
2016-12-25 21:35:56 +01:00
|
|
|
endfunction
|
2010-01-20 01:00:00 +01:00
|
|
|
|
2011-06-11 02:00:00 +02:00
|
|
|
|
2018-02-15 18:38:39 +01:00
|
|
|
" This function is called when Vim opens a new buffer with a known wiki
|
|
|
|
" extension. Both when the buffer has never been opened in this session and
|
|
|
|
" when it has.
|
2018-04-20 07:03:53 +02:00
|
|
|
function! s:setup_new_wiki_buffer()
|
2016-12-25 21:35:56 +01:00
|
|
|
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
|
|
|
|
if wiki_nr == -1 " it's not in a known wiki directory
|
|
|
|
if vimwiki#vars#get_global('global_ext')
|
|
|
|
call s:create_temporary_wiki()
|
|
|
|
else
|
|
|
|
" the user does not want a temporary wiki, so do nothing
|
|
|
|
return
|
|
|
|
endif
|
2012-06-07 02:00:00 +02:00
|
|
|
endif
|
2011-06-11 02:00:00 +02:00
|
|
|
|
2018-02-14 06:53:46 +01:00
|
|
|
if vimwiki#vars#get_wikilocal('maxhi')
|
|
|
|
call vimwiki#vars#set_bufferlocal('existing_wikifiles', vimwiki#base#get_wikilinks(wiki_nr, 1))
|
|
|
|
call vimwiki#vars#set_bufferlocal('existing_wikidirs',
|
|
|
|
\ vimwiki#base#get_wiki_directories(wiki_nr))
|
|
|
|
endif
|
|
|
|
|
2017-11-11 21:52:07 +01:00
|
|
|
" this makes that ftplugin/vimwiki.vim and afterwards syntax/vimwiki.vim are
|
|
|
|
" sourced
|
|
|
|
setfiletype vimwiki
|
2011-06-11 02:00:00 +02:00
|
|
|
|
2018-04-20 07:03:53 +02:00
|
|
|
endfunction
|
2010-01-20 01:00:00 +01:00
|
|
|
|
|
|
|
|
2016-12-25 21:35:56 +01:00
|
|
|
" this is called when the cursor enters the buffer
|
2018-04-20 07:03:53 +02:00
|
|
|
function! s:setup_buffer_enter()
|
2016-12-25 21:35:56 +01:00
|
|
|
" don't do anything if it's not managed by Vimwiki (that is, when it's not in
|
|
|
|
" a registered wiki and not a temporary wiki)
|
2016-12-28 22:17:08 +01:00
|
|
|
if vimwiki#vars#get_bufferlocal('wiki_nr') == -1
|
2016-12-25 21:35:56 +01:00
|
|
|
return
|
2010-01-20 01:00:00 +01:00
|
|
|
endif
|
|
|
|
|
2018-02-26 07:20:14 +01:00
|
|
|
if &filetype != 'vimwiki'
|
2017-11-11 21:52:07 +01:00
|
|
|
setfiletype vimwiki
|
2011-06-11 02:00:00 +02:00
|
|
|
endif
|
2010-01-20 01:00:00 +01:00
|
|
|
|
2018-02-15 18:38:39 +01:00
|
|
|
call s:set_global_options()
|
2010-01-20 01:00:00 +01:00
|
|
|
|
2018-02-15 18:38:39 +01:00
|
|
|
call s:set_windowlocal_options()
|
2018-04-20 07:03:53 +02:00
|
|
|
endfunction
|
2012-06-07 02:00:00 +02:00
|
|
|
|
2018-02-15 18:38:39 +01:00
|
|
|
|
2018-04-20 07:03:53 +02:00
|
|
|
function! s:setup_cleared_syntax()
|
|
|
|
" highlight groups that get cleared
|
2012-06-07 02:00:00 +02:00
|
|
|
" on colorscheme change because they are not linked to Vim-predefined groups
|
|
|
|
hi def VimwikiBold term=bold cterm=bold gui=bold
|
|
|
|
hi def VimwikiItalic term=italic cterm=italic gui=italic
|
|
|
|
hi def VimwikiBoldItalic term=bold cterm=bold gui=bold,italic
|
|
|
|
hi def VimwikiUnderline gui=underline
|
2016-12-21 19:43:34 +01:00
|
|
|
if vimwiki#vars#get_global('hl_headers') == 1
|
2012-06-07 02:00:00 +02:00
|
|
|
for i in range(1,6)
|
2018-02-15 18:38:39 +01:00
|
|
|
execute 'hi def VimwikiHeader'.i.' guibg=bg guifg='
|
|
|
|
\ . vimwiki#vars#get_global('hcolor_guifg_'.&bg)[i-1]
|
|
|
|
\ .' gui=bold ctermfg='.vimwiki#vars#get_global('hcolor_ctermfg_'.&bg)[i-1]
|
|
|
|
\ .' term=bold cterm=bold'
|
2012-06-07 02:00:00 +02:00
|
|
|
endfor
|
|
|
|
endif
|
2018-04-20 07:03:53 +02:00
|
|
|
endfunction
|
2010-01-20 01:00:00 +01:00
|
|
|
|
|
|
|
|
2018-04-20 07:03:53 +02:00
|
|
|
function! s:vimwiki_get_known_extensions()
|
2015-01-09 22:23:21 +01:00
|
|
|
" Getting all extensions that different wikis could have
|
|
|
|
let extensions = {}
|
2016-12-22 21:00:19 +01:00
|
|
|
for idx in range(vimwiki#vars#number_of_wikis())
|
|
|
|
let ext = vimwiki#vars#get_wikilocal('ext', idx)
|
|
|
|
let extensions[ext] = 1
|
2015-01-09 22:23:21 +01:00
|
|
|
endfor
|
2016-12-21 19:43:34 +01:00
|
|
|
" append extensions from g:vimwiki_ext2syntax
|
|
|
|
for ext in keys(vimwiki#vars#get_global('ext2syntax'))
|
2015-01-09 22:23:21 +01:00
|
|
|
let extensions[ext] = 1
|
|
|
|
endfor
|
|
|
|
return keys(extensions)
|
2018-04-20 07:03:53 +02:00
|
|
|
endfunction
|
2015-01-09 22:23:21 +01:00
|
|
|
|
2018-02-15 18:38:39 +01:00
|
|
|
|
|
|
|
" Set settings which are global for Vim, but should only be executed for
|
|
|
|
" Vimwiki buffers. So they must be set when the cursor enters a Vimwiki buffer
|
|
|
|
" and reset when the cursor leaves the buffer.
|
|
|
|
function! s:set_global_options()
|
|
|
|
let s:vimwiki_autowriteall_saved = &autowriteall
|
|
|
|
let &autowriteall = vimwiki#vars#get_global('autowriteall')
|
|
|
|
|
2019-01-19 21:05:27 +01:00
|
|
|
if !empty(vimwiki#vars#get_global('menu'))
|
2018-02-15 18:38:39 +01:00
|
|
|
exe 'nmenu enable '.vimwiki#vars#get_global('menu').'.Table'
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
|
|
" Set settings which are local to a window. In a new tab they would be reset to
|
|
|
|
" Vim defaults. So we enforce our settings here when the cursor enters a
|
|
|
|
" Vimwiki buffer.
|
|
|
|
function! s:set_windowlocal_options()
|
2018-08-07 21:39:54 +02:00
|
|
|
if !&diff " if Vim is currently in diff mode, don't interfere with its folding
|
|
|
|
let foldmethod = vimwiki#vars#get_global('folding')
|
|
|
|
if foldmethod =~? '^expr.*'
|
|
|
|
setlocal foldmethod=expr
|
|
|
|
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
|
|
|
|
setlocal foldtext=VimwikiFoldText()
|
|
|
|
elseif foldmethod =~? '^list.*' || foldmethod =~? '^lists.*'
|
|
|
|
setlocal foldmethod=expr
|
|
|
|
setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
|
|
|
|
setlocal foldtext=VimwikiFoldText()
|
|
|
|
elseif foldmethod =~? '^syntax.*'
|
|
|
|
setlocal foldmethod=syntax
|
|
|
|
setlocal foldtext=VimwikiFoldText()
|
|
|
|
elseif foldmethod =~? '^custom.*'
|
|
|
|
" do nothing
|
|
|
|
else
|
|
|
|
setlocal foldmethod=manual
|
|
|
|
normal! zE
|
|
|
|
endif
|
2018-02-15 18:38:39 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
if vimwiki#vars#get_global('conceallevel') && exists("+conceallevel")
|
|
|
|
let &conceallevel = vimwiki#vars#get_global('conceallevel')
|
|
|
|
endif
|
|
|
|
|
|
|
|
if vimwiki#vars#get_global('auto_chdir')
|
|
|
|
exe 'lcd' vimwiki#vars#get_wikilocal('path')
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
2018-04-20 07:03:53 +02:00
|
|
|
|
2018-06-12 20:55:56 +02:00
|
|
|
function! s:get_version()
|
2019-04-01 19:59:43 +02:00
|
|
|
if s:plugin_vers != -1
|
2019-04-03 16:39:21 +02:00
|
|
|
echo "Stable version: " . string(s:plugin_vers)
|
2018-06-12 20:55:56 +02:00
|
|
|
else
|
2019-04-03 16:39:21 +02:00
|
|
|
let l:plugin_rev = system("git --git-dir " . s:plugin_dir . "/.git rev-parse --short HEAD")
|
|
|
|
let l:plugin_branch = system("git --git-dir " . s:plugin_dir . "/.git rev-parse --abbrev-ref HEAD")
|
|
|
|
let l:plugin_date = system("git --git-dir " . s:plugin_dir . "/.git show -s --format=%ci")
|
2018-06-12 20:55:56 +02:00
|
|
|
if v:shell_error == 0
|
2019-04-03 16:39:21 +02:00
|
|
|
echo "Branch: " . l:plugin_branch
|
|
|
|
echo "Revision: " . l:plugin_rev
|
|
|
|
echo "Date: " . l:plugin_date
|
2018-06-12 20:55:56 +02:00
|
|
|
else
|
|
|
|
echo "Unknown version"
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
2010-01-20 01:00:00 +01:00
|
|
|
|
2016-12-21 19:43:34 +01:00
|
|
|
|
|
|
|
" Initialization of Vimwiki starts here. Make sure everything below does not
|
2018-02-10 22:04:37 +01:00
|
|
|
" cause autoload/vimwiki/base.vim to be loaded
|
2016-12-21 19:43:34 +01:00
|
|
|
|
|
|
|
call vimwiki#vars#init()
|
|
|
|
|
2018-04-20 07:03:53 +02:00
|
|
|
|
|
|
|
" Define callback functions which the user can redefine
|
|
|
|
if !exists("*VimwikiLinkHandler")
|
2012-06-07 02:00:00 +02:00
|
|
|
function VimwikiLinkHandler(url)
|
|
|
|
return 0
|
2010-01-20 01:00:00 +01:00
|
|
|
endfunction
|
2018-04-20 07:03:53 +02:00
|
|
|
endif
|
2012-06-07 02:00:00 +02:00
|
|
|
|
2018-04-20 07:03:53 +02:00
|
|
|
if !exists("*VimwikiLinkConverter")
|
2015-04-29 14:59:10 +02:00
|
|
|
function VimwikiLinkConverter(url, source, target)
|
|
|
|
" Return the empty string when unable to process link
|
|
|
|
return ''
|
|
|
|
endfunction
|
2018-04-20 07:03:53 +02:00
|
|
|
endif
|
2015-04-29 14:59:10 +02:00
|
|
|
|
2018-04-20 07:03:53 +02:00
|
|
|
if !exists("*VimwikiWikiIncludeHandler")
|
|
|
|
function! VimwikiWikiIncludeHandler(value)
|
2012-06-07 02:00:00 +02:00
|
|
|
return ''
|
2018-04-20 07:03:53 +02:00
|
|
|
endfunction
|
|
|
|
endif
|
|
|
|
|
2010-01-20 01:00:00 +01:00
|
|
|
|
|
|
|
|
2018-04-20 07:03:53 +02:00
|
|
|
" Define autocommands for all known wiki extensions
|
2010-01-20 01:00:00 +01:00
|
|
|
|
2016-12-25 21:35:56 +01:00
|
|
|
let s:known_extensions = s:vimwiki_get_known_extensions()
|
|
|
|
|
|
|
|
if index(s:known_extensions, '.wiki') > -1
|
|
|
|
augroup filetypedetect
|
|
|
|
" clear FlexWiki's stuff
|
|
|
|
au! * *.wiki
|
|
|
|
augroup end
|
|
|
|
endif
|
2010-01-20 01:00:00 +01:00
|
|
|
|
|
|
|
augroup vimwiki
|
|
|
|
autocmd!
|
2018-10-28 21:04:24 +01:00
|
|
|
autocmd ColorScheme * call s:setup_cleared_syntax()
|
2016-12-25 21:35:56 +01:00
|
|
|
for s:ext in s:known_extensions
|
|
|
|
exe 'autocmd BufNewFile,BufRead *'.s:ext.' call s:setup_new_wiki_buffer()'
|
2018-02-15 18:38:39 +01:00
|
|
|
exe 'autocmd BufEnter *'.s:ext.' call s:setup_buffer_enter()'
|
2016-12-25 21:35:56 +01:00
|
|
|
exe 'autocmd BufLeave *'.s:ext.' call s:setup_buffer_leave()'
|
2010-02-23 01:00:00 +01:00
|
|
|
" Format tables when exit from insert mode. Do not use textwidth to
|
|
|
|
" autowrap tables.
|
2016-12-21 21:28:48 +01:00
|
|
|
if vimwiki#vars#get_global('table_auto_fmt')
|
2019-03-15 13:31:28 +01:00
|
|
|
exe 'autocmd InsertLeave *'.s:ext.' call vimwiki#tbl#format(line("."), 2)'
|
2014-02-24 12:16:23 +01:00
|
|
|
exe 'autocmd InsertEnter *'.s:ext.' call vimwiki#tbl#reset_tw(line("."))'
|
2010-02-23 01:00:00 +01:00
|
|
|
endif
|
2018-04-22 21:24:28 +02:00
|
|
|
if vimwiki#vars#get_global('folding') =~? ':quick$'
|
2016-07-12 16:41:44 +02:00
|
|
|
" from http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text
|
|
|
|
" Don't screw up folds when inserting text that might affect them, until
|
|
|
|
" leaving insert mode. Foldmethod is local to the window. Protect against
|
|
|
|
" screwing up folding when switching between windows.
|
2018-04-22 21:24:28 +02:00
|
|
|
exe 'autocmd InsertEnter *'.s:ext.' if !exists("w:last_fdm") | let w:last_fdm=&foldmethod'.
|
|
|
|
\ ' | setlocal foldmethod=manual | endif'
|
|
|
|
exe 'autocmd InsertLeave,WinLeave *'.s:ext.' if exists("w:last_fdm") |'.
|
|
|
|
\ 'let &l:foldmethod=w:last_fdm | unlet w:last_fdm | endif'
|
2016-07-12 16:41:44 +02:00
|
|
|
endif
|
2010-01-20 01:00:00 +01:00
|
|
|
endfor
|
|
|
|
augroup END
|
|
|
|
|
2018-04-20 07:03:53 +02:00
|
|
|
|
|
|
|
|
2011-06-11 02:00:00 +02:00
|
|
|
command! VimwikiUISelect call vimwiki#base#ui_select()
|
2019-03-31 03:12:56 +02:00
|
|
|
|
|
|
|
" these commands take a count e.g. :VimwikiIndex 2
|
|
|
|
" the default behavior is to open the index, diary etc.
|
|
|
|
" for the CURRENT wiki if no count is given
|
|
|
|
command! -count=0 VimwikiIndex
|
|
|
|
\ call vimwiki#base#goto_index(<count>)
|
|
|
|
|
|
|
|
command! -count=0 VimwikiTabIndex
|
|
|
|
\ call vimwiki#base#goto_index(<count>, 1)
|
|
|
|
|
|
|
|
command! -count=0 VimwikiDiaryIndex
|
|
|
|
\ call vimwiki#diary#goto_diary_index(<count>)
|
|
|
|
|
|
|
|
command! -count=0 VimwikiMakeDiaryNote
|
|
|
|
\ call vimwiki#diary#make_note(<count>)
|
|
|
|
|
|
|
|
command! -count=0 VimwikiTabMakeDiaryNote
|
|
|
|
\ call vimwiki#diary#make_note(<count>, 1)
|
|
|
|
|
|
|
|
command! -count=0 VimwikiMakeYesterdayDiaryNote
|
|
|
|
\ call vimwiki#diary#make_note(<count>, 0,
|
2018-04-20 07:03:53 +02:00
|
|
|
\ vimwiki#diary#diary_date_link(localtime() - 60*60*24))
|
2019-03-31 03:12:56 +02:00
|
|
|
|
|
|
|
command! -count=0 VimwikiMakeTomorrowDiaryNote
|
|
|
|
\ call vimwiki#diary#make_note(<count>, 0,
|
2018-04-20 07:03:53 +02:00
|
|
|
\ vimwiki#diary#diary_date_link(localtime() + 60*60*24))
|
2012-06-07 02:00:00 +02:00
|
|
|
|
|
|
|
command! VimwikiDiaryGenerateLinks
|
|
|
|
\ call vimwiki#diary#generate_diary_section()
|
2010-01-20 01:00:00 +01:00
|
|
|
|
2018-06-12 20:55:56 +02:00
|
|
|
command! VimwikiShowVersion call s:get_version()
|
|
|
|
|
2016-12-25 21:35:56 +01:00
|
|
|
let s:map_prefix = vimwiki#vars#get_global('map_prefix')
|
|
|
|
|
2016-04-29 13:06:31 +02:00
|
|
|
if !hasmapto('<Plug>VimwikiIndex') && maparg(s:map_prefix.'w', 'n') == ""
|
2016-12-25 21:35:56 +01:00
|
|
|
exe 'nmap <silent><unique> '.s:map_prefix.'w <Plug>VimwikiIndex'
|
2010-01-20 01:00:00 +01:00
|
|
|
endif
|
2019-03-31 03:12:56 +02:00
|
|
|
nnoremap <unique><script> <Plug>VimwikiIndex
|
|
|
|
\ :<C-U>call vimwiki#base#goto_index(v:count1)<CR>
|
2010-01-20 01:00:00 +01:00
|
|
|
|
2016-04-29 13:06:31 +02:00
|
|
|
if !hasmapto('<Plug>VimwikiTabIndex') && maparg(s:map_prefix.'t', 'n') == ""
|
2016-12-25 21:35:56 +01:00
|
|
|
exe 'nmap <silent><unique> '.s:map_prefix.'t <Plug>VimwikiTabIndex'
|
2010-01-20 01:00:00 +01:00
|
|
|
endif
|
2019-03-31 03:12:56 +02:00
|
|
|
nnoremap <unique><script> <Plug>VimwikiTabIndex
|
|
|
|
\ :<C-U>call vimwiki#base#goto_index(v:count1, 1)<CR>
|
2010-01-20 01:00:00 +01:00
|
|
|
|
2016-04-29 13:06:31 +02:00
|
|
|
if !hasmapto('<Plug>VimwikiUISelect') && maparg(s:map_prefix.'s', 'n') == ""
|
2016-12-25 21:35:56 +01:00
|
|
|
exe 'nmap <silent><unique> '.s:map_prefix.'s <Plug>VimwikiUISelect'
|
2011-06-11 02:00:00 +02:00
|
|
|
endif
|
|
|
|
nnoremap <unique><script> <Plug>VimwikiUISelect :VimwikiUISelect<CR>
|
|
|
|
|
2016-04-29 13:06:31 +02:00
|
|
|
if !hasmapto('<Plug>VimwikiDiaryIndex') && maparg(s:map_prefix.'i', 'n') == ""
|
2016-12-25 21:35:56 +01:00
|
|
|
exe 'nmap <silent><unique> '.s:map_prefix.'i <Plug>VimwikiDiaryIndex'
|
2010-01-20 01:00:00 +01:00
|
|
|
endif
|
2019-03-31 03:12:56 +02:00
|
|
|
nnoremap <unique><script> <Plug>VimwikiDiaryIndex
|
|
|
|
\ :<C-U>call vimwiki#diary#goto_diary_index(v:count)<CR>
|
2010-01-20 01:00:00 +01:00
|
|
|
|
2016-04-29 13:06:31 +02:00
|
|
|
if !hasmapto('<Plug>VimwikiDiaryGenerateLinks') && maparg(s:map_prefix.'<Leader>i', 'n') == ""
|
2016-12-25 21:35:56 +01:00
|
|
|
exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>i <Plug>VimwikiDiaryGenerateLinks'
|
2012-06-07 02:00:00 +02:00
|
|
|
endif
|
|
|
|
nnoremap <unique><script> <Plug>VimwikiDiaryGenerateLinks :VimwikiDiaryGenerateLinks<CR>
|
|
|
|
|
2016-04-29 13:06:31 +02:00
|
|
|
if !hasmapto('<Plug>VimwikiMakeDiaryNote') && maparg(s:map_prefix.'<Leader>w', 'n') == ""
|
2016-12-25 21:35:56 +01:00
|
|
|
exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>w <Plug>VimwikiMakeDiaryNote'
|
2010-02-23 01:00:00 +01:00
|
|
|
endif
|
2019-03-31 03:12:56 +02:00
|
|
|
nnoremap <unique><script> <Plug>VimwikiMakeDiaryNote
|
|
|
|
\ :<C-U>call vimwiki#diary#make_note(v:count)<CR>
|
2010-02-23 01:00:00 +01:00
|
|
|
|
2016-04-29 13:06:31 +02:00
|
|
|
if !hasmapto('<Plug>VimwikiTabMakeDiaryNote') && maparg(s:map_prefix.'<Leader>t', 'n') == ""
|
2016-12-25 21:35:56 +01:00
|
|
|
exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>t <Plug>VimwikiTabMakeDiaryNote'
|
2010-02-23 01:00:00 +01:00
|
|
|
endif
|
2011-06-11 02:00:00 +02:00
|
|
|
nnoremap <unique><script> <Plug>VimwikiTabMakeDiaryNote
|
2019-03-31 03:12:56 +02:00
|
|
|
\ :<C-U>call vimwiki#diary#make_note(v:count, 1)<CR>
|
2010-02-23 01:00:00 +01:00
|
|
|
|
2016-04-29 13:06:31 +02:00
|
|
|
if !hasmapto('<Plug>VimwikiMakeYesterdayDiaryNote') && maparg(s:map_prefix.'<Leader>y', 'n') == ""
|
2016-12-25 21:35:56 +01:00
|
|
|
exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>y <Plug>VimwikiMakeYesterdayDiaryNote'
|
2015-10-28 23:00:00 +01:00
|
|
|
endif
|
|
|
|
nnoremap <unique><script> <Plug>VimwikiMakeYesterdayDiaryNote
|
2019-03-31 03:12:56 +02:00
|
|
|
\ :<C-U>call vimwiki#diary#make_note(v:count, 0,
|
|
|
|
\ vimwiki#diary#diary_date_link(localtime() - 60*60*24))<CR>
|
2015-10-28 23:00:00 +01:00
|
|
|
|
2018-04-04 01:48:24 +02:00
|
|
|
if !hasmapto('<Plug>VimwikiMakeTomorrowDiaryNote')
|
|
|
|
exe 'nmap <silent><unique> '.s:map_prefix.'<Leader>m <Plug>VimwikiMakeTomorrowDiaryNote'
|
|
|
|
endif
|
|
|
|
nnoremap <unique><script> <Plug>VimwikiMakeTomorrowDiaryNote
|
2019-03-31 03:12:56 +02:00
|
|
|
\ :<C-U>call vimwiki#diary#make_note(v:count, 0,
|
|
|
|
\ vimwiki#diary#diary_date_link(localtime() + 60*60*24))<CR>
|
2010-01-20 01:00:00 +01:00
|
|
|
|
2018-04-20 07:03:53 +02:00
|
|
|
|
|
|
|
|
2010-02-23 01:00:00 +01:00
|
|
|
function! s:build_menu(topmenu)
|
2016-12-25 21:35:56 +01:00
|
|
|
for idx in range(vimwiki#vars#number_of_wikis())
|
2016-12-22 19:55:20 +01:00
|
|
|
let norm_path = fnamemodify(vimwiki#vars#get_wikilocal('path', idx), ':h:t')
|
2010-09-03 02:00:00 +02:00
|
|
|
let norm_path = escape(norm_path, '\ \.')
|
2010-02-23 01:00:00 +01:00
|
|
|
execute 'menu '.a:topmenu.'.Open\ index.'.norm_path.
|
2018-05-17 21:47:50 +02:00
|
|
|
\ ' :call vimwiki#base#goto_index('.(idx+1).')<CR>'
|
2010-02-23 01:00:00 +01:00
|
|
|
execute 'menu '.a:topmenu.'.Open/Create\ diary\ note.'.norm_path.
|
2018-05-17 20:06:27 +02:00
|
|
|
\ ' :call vimwiki#diary#make_note('.(idx+1).')<CR>'
|
2016-12-25 21:35:56 +01:00
|
|
|
endfor
|
2010-01-20 01:00:00 +01:00
|
|
|
endfunction
|
|
|
|
|
2010-02-23 01:00:00 +01:00
|
|
|
function! s:build_table_menu(topmenu)
|
|
|
|
exe 'menu '.a:topmenu.'.-Sep- :'
|
|
|
|
exe 'menu '.a:topmenu.'.Table.Create\ (enter\ cols\ rows) :VimwikiTable '
|
|
|
|
exe 'nmenu '.a:topmenu.'.Table.Format<tab>gqq gqq'
|
2010-05-12 02:00:00 +02:00
|
|
|
exe 'nmenu '.a:topmenu.'.Table.Move\ column\ left<tab><A-Left> :VimwikiTableMoveColumnLeft<CR>'
|
2018-04-20 07:03:53 +02:00
|
|
|
exe 'nmenu '.a:topmenu.
|
|
|
|
\ '.Table.Move\ column\ right<tab><A-Right> :VimwikiTableMoveColumnRight<CR>'
|
2010-02-23 01:00:00 +01:00
|
|
|
exe 'nmenu disable '.a:topmenu.'.Table'
|
|
|
|
endfunction
|
|
|
|
|
2016-12-21 19:43:34 +01:00
|
|
|
|
2016-12-21 21:28:48 +01:00
|
|
|
if !empty(vimwiki#vars#get_global('menu'))
|
|
|
|
call s:build_menu(vimwiki#vars#get_global('menu'))
|
|
|
|
call s:build_table_menu(vimwiki#vars#get_global('menu'))
|
2010-01-20 01:00:00 +01:00
|
|
|
endif
|
|
|
|
|
2018-04-20 07:03:53 +02:00
|
|
|
|
|
|
|
" Hook for calendar.vim
|
2016-12-21 21:28:48 +01:00
|
|
|
if vimwiki#vars#get_global('use_calendar')
|
2011-06-11 02:00:00 +02:00
|
|
|
let g:calendar_action = 'vimwiki#diary#calendar_action'
|
|
|
|
let g:calendar_sign = 'vimwiki#diary#calendar_sign'
|
2010-02-23 01:00:00 +01:00
|
|
|
endif
|
|
|
|
|
2012-06-07 02:00:00 +02:00
|
|
|
|
2010-01-20 01:00:00 +01:00
|
|
|
let &cpo = s:old_cpo
|