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-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
|
|
|
|
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
|
|
|
|
2016-12-25 21:35:56 +01:00
|
|
|
if vimwiki#vars#get_global('menu') != ""
|
|
|
|
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)
|
|
|
|
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')
|
|
|
|
|
|
|
|
if vimwiki#vars#get_global('menu') !=# ''
|
|
|
|
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()
|
|
|
|
let foldmethod = vimwiki#vars#get_global('folding')
|
2018-04-22 21:24:28 +02:00
|
|
|
if foldmethod =~? '^expr.*'
|
2018-02-15 18:38:39 +01:00
|
|
|
setlocal foldmethod=expr
|
|
|
|
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
|
|
|
|
setlocal foldtext=VimwikiFoldText()
|
2018-04-22 21:24:28 +02:00
|
|
|
elseif foldmethod =~? '^list.*' || foldmethod =~? '^lists.*'
|
2018-02-15 18:38:39 +01:00
|
|
|
setlocal foldmethod=expr
|
|
|
|
setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
|
|
|
|
setlocal foldtext=VimwikiFoldText()
|
2018-04-22 21:24:28 +02:00
|
|
|
elseif foldmethod =~? '^syntax.*'
|
2018-02-15 18:38:39 +01:00
|
|
|
setlocal foldmethod=syntax
|
|
|
|
setlocal foldtext=VimwikiFoldText()
|
2018-04-22 21:24:28 +02:00
|
|
|
elseif foldmethod =~? '^custom.*'
|
2018-02-16 18:11:49 +01:00
|
|
|
" do nothing
|
2018-02-15 18:38:39 +01:00
|
|
|
else
|
|
|
|
setlocal foldmethod=manual
|
|
|
|
normal! zE
|
|
|
|
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
|
|
|
|
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!
|
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()'
|
2014-02-24 12:16:23 +01:00
|
|
|
exe 'autocmd ColorScheme *'.s:ext.' call s:setup_cleared_syntax()'
|
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')
|
2014-02-24 12:16:23 +01:00
|
|
|
exe 'autocmd InsertLeave *'.s:ext.' call vimwiki#tbl#format(line("."))'
|
|
|
|
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()
|
2018-04-17 07:13:37 +02:00
|
|
|
" why not using <count> instead of v:count1?
|
|
|
|
" See https://github.com/vimwiki-backup/vimwiki/issues/324
|
2012-06-07 02:00:00 +02:00
|
|
|
command! -count=1 VimwikiIndex
|
2011-06-11 02:00:00 +02:00
|
|
|
\ call vimwiki#base#goto_index(v:count1)
|
2012-06-07 02:00:00 +02:00
|
|
|
command! -count=1 VimwikiTabIndex
|
|
|
|
\ call vimwiki#base#goto_index(v:count1, 1)
|
2010-02-23 01:00:00 +01:00
|
|
|
|
2012-06-07 02:00:00 +02:00
|
|
|
command! -count=1 VimwikiDiaryIndex
|
|
|
|
\ call vimwiki#diary#goto_diary_index(v:count1)
|
|
|
|
command! -count=1 VimwikiMakeDiaryNote
|
2011-06-11 02:00:00 +02:00
|
|
|
\ call vimwiki#diary#make_note(v:count1)
|
2012-06-07 02:00:00 +02:00
|
|
|
command! -count=1 VimwikiTabMakeDiaryNote
|
|
|
|
\ call vimwiki#diary#make_note(v:count1, 1)
|
2015-10-28 23:00:00 +01:00
|
|
|
command! -count=1 VimwikiMakeYesterdayDiaryNote
|
2018-04-20 07:03:53 +02:00
|
|
|
\ call vimwiki#diary#make_note(v:count1, 0,
|
|
|
|
\ vimwiki#diary#diary_date_link(localtime() - 60*60*24))
|
2018-04-04 01:48:24 +02:00
|
|
|
command! -count=1 VimwikiMakeTomorrowDiaryNote
|
2018-04-20 07:03:53 +02:00
|
|
|
\ call vimwiki#diary#make_note(v:count1, 0,
|
|
|
|
\ 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-04-20 07:03:53 +02:00
|
|
|
|
|
|
|
|
2016-12-25 21:35:56 +01:00
|
|
|
let s:map_prefix = vimwiki#vars#get_global('map_prefix')
|
|
|
|
|
2010-08-24 02:00:00 +02:00
|
|
|
if !hasmapto('<Plug>VimwikiIndex')
|
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
|
2011-06-11 02:00:00 +02:00
|
|
|
nnoremap <unique><script> <Plug>VimwikiIndex :VimwikiIndex<CR>
|
2010-01-20 01:00:00 +01:00
|
|
|
|
2010-08-24 02:00:00 +02:00
|
|
|
if !hasmapto('<Plug>VimwikiTabIndex')
|
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
|
2011-06-11 02:00:00 +02:00
|
|
|
nnoremap <unique><script> <Plug>VimwikiTabIndex :VimwikiTabIndex<CR>
|
2010-01-20 01:00:00 +01:00
|
|
|
|
|
|
|
if !hasmapto('<Plug>VimwikiUISelect')
|
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>
|
|
|
|
|
|
|
|
if !hasmapto('<Plug>VimwikiDiaryIndex')
|
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
|
2011-06-11 02:00:00 +02:00
|
|
|
nnoremap <unique><script> <Plug>VimwikiDiaryIndex :VimwikiDiaryIndex<CR>
|
2010-01-20 01:00:00 +01:00
|
|
|
|
2012-06-07 02:00:00 +02:00
|
|
|
if !hasmapto('<Plug>VimwikiDiaryGenerateLinks')
|
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>
|
|
|
|
|
2010-02-23 01:00:00 +01:00
|
|
|
if !hasmapto('<Plug>VimwikiMakeDiaryNote')
|
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
|
2011-06-11 02:00:00 +02:00
|
|
|
nnoremap <unique><script> <Plug>VimwikiMakeDiaryNote :VimwikiMakeDiaryNote<CR>
|
2010-02-23 01:00:00 +01:00
|
|
|
|
|
|
|
if !hasmapto('<Plug>VimwikiTabMakeDiaryNote')
|
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
|
2010-02-23 01:00:00 +01:00
|
|
|
\ :VimwikiTabMakeDiaryNote<CR>
|
|
|
|
|
2015-10-28 23:00:00 +01:00
|
|
|
if !hasmapto('<Plug>VimwikiMakeYesterdayDiaryNote')
|
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
|
|
|
|
\ :VimwikiMakeYesterdayDiaryNote<CR>
|
|
|
|
|
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
|
|
|
|
\ :VimwikiMakeTomorrowDiaryNote<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.
|
2016-12-25 21:35:56 +01:00
|
|
|
\ ' :call vimwiki#base#goto_index('.idx.')<CR>'
|
2010-02-23 01:00:00 +01:00
|
|
|
execute 'menu '.a:topmenu.'.Open/Create\ diary\ note.'.norm_path.
|
2016-12-25 21:35:56 +01:00
|
|
|
\ ' :call vimwiki#diary#make_note('.idx.')<CR>'
|
|
|
|
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
|