parent
ce5c822072
commit
fea76ace23
@ -722,7 +722,7 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...) "{{{
|
|||||||
" a:1 -- previous vimwiki link to save
|
" a:1 -- previous vimwiki link to save
|
||||||
" a:2 -- should we update previous link
|
" a:2 -- should we update previous link
|
||||||
if a:0 && a:2 && len(a:1) > 0
|
if a:0 && a:2 && len(a:1) > 0
|
||||||
let b:vimwiki_prev_link = a:1
|
call vimwiki#vars#set_bufferlocal('prev_link', a:1)
|
||||||
endif
|
endif
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
@ -880,8 +880,10 @@ function! s:get_wiki_buffers() "{{{
|
|||||||
while bcount<=bufnr("$")
|
while bcount<=bufnr("$")
|
||||||
if bufexists(bcount)
|
if bufexists(bcount)
|
||||||
let bname = fnamemodify(bufname(bcount), ":p")
|
let bname = fnamemodify(bufname(bcount), ":p")
|
||||||
|
" this may find buffers that are not part of the current wiki, but that
|
||||||
|
" doesn't hurt
|
||||||
if bname =~# vimwiki#vars#get_wikilocal('ext')."$"
|
if bname =~# vimwiki#vars#get_wikilocal('ext')."$"
|
||||||
let bitem = [bname, getbufvar(bname, "vimwiki_prev_link")]
|
let bitem = [bname, vimwiki#vars#get_bufferlocal('prev_link', bcount)]
|
||||||
call add(blist, bitem)
|
call add(blist, bitem)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -894,7 +896,7 @@ endfunction " }}}
|
|||||||
function! s:open_wiki_buffer(item) "{{{
|
function! s:open_wiki_buffer(item) "{{{
|
||||||
call vimwiki#base#edit_file(':e', a:item[0], '')
|
call vimwiki#base#edit_file(':e', a:item[0], '')
|
||||||
if !empty(a:item[1])
|
if !empty(a:item[1])
|
||||||
call setbufvar(a:item[0], "vimwiki_prev_link", a:item[1])
|
call vimwiki#vars#set_bufferlocal('prev_link', a:item[1], a:item[0])
|
||||||
endif
|
endif
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
@ -1125,11 +1127,11 @@ endfunction " }}}
|
|||||||
|
|
||||||
" vimwiki#base#go_back_link
|
" vimwiki#base#go_back_link
|
||||||
function! vimwiki#base#go_back_link() "{{{
|
function! vimwiki#base#go_back_link() "{{{
|
||||||
if exists("b:vimwiki_prev_link")
|
let prev_link = vimwiki#vars#get_bufferlocal('prev_link')
|
||||||
|
if prev_link !=# ''
|
||||||
" go back to saved wiki link
|
" go back to saved wiki link
|
||||||
let prev_word = b:vimwiki_prev_link
|
execute ":e ".substitute(prev_link[0], '\s', '\\\0', 'g')
|
||||||
execute ":e ".substitute(prev_word[0], '\s', '\\\0', 'g')
|
call setpos('.', prev_link[1])
|
||||||
call setpos('.', prev_word[1])
|
|
||||||
else
|
else
|
||||||
" maybe we came here by jumping to a tag -> pop from the tag stack
|
" maybe we came here by jumping to a tag -> pop from the tag stack
|
||||||
silent! pop!
|
silent! pop!
|
||||||
@ -1251,7 +1253,7 @@ function! vimwiki#base#rename_link() "{{{
|
|||||||
let &buftype="nofile"
|
let &buftype="nofile"
|
||||||
|
|
||||||
let cur_buffer = [expand('%:p'),
|
let cur_buffer = [expand('%:p'),
|
||||||
\getbufvar(expand('%:p'), "vimwiki_prev_link")]
|
\ vimwiki#vars#get_bufferlocal('prev_link')]
|
||||||
|
|
||||||
let blist = s:get_wiki_buffers()
|
let blist = s:get_wiki_buffers()
|
||||||
|
|
||||||
|
@ -540,35 +540,40 @@ function! vimwiki#vars#get_syntaxlocal(key, ...)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" Get a variable for the buffer we are currently in.
|
" Get a variable for the buffer we are currently in or for the given buffer (number or name).
|
||||||
" Populate the variable, if it doesn't exist.
|
" Populate the variable, if it doesn't exist.
|
||||||
function! vimwiki#vars#get_bufferlocal(key)
|
function! vimwiki#vars#get_bufferlocal(key, ...)
|
||||||
if exists('b:vimwiki_'.a:key)
|
let buffer = a:0 ? a:1 : '%'
|
||||||
return b:vimwiki_{a:key}
|
|
||||||
|
let value = getbufvar(buffer, 'vimwiki_'.a:key, '/\/\')
|
||||||
|
if type(value) != 1 || value !=# '/\/\'
|
||||||
|
return value
|
||||||
elseif a:key ==# 'wiki_nr'
|
elseif a:key ==# 'wiki_nr'
|
||||||
let b:vimwiki_wiki_nr = vimwiki#base#find_wiki(expand('%:p'))
|
call setbufvar(buffer, 'vimwiki_wiki_nr', vimwiki#base#find_wiki(expand('%:p')))
|
||||||
return b:vimwiki_wiki_nr
|
|
||||||
elseif a:key ==# 'subdir'
|
elseif a:key ==# 'subdir'
|
||||||
let b:vimwiki_subdir = vimwiki#base#current_subdir()
|
call setbufvar(buffer, 'vimwiki_subdir', vimwiki#base#current_subdir())
|
||||||
return b:vimwiki_subdir
|
|
||||||
elseif a:key ==# 'invsubdir'
|
elseif a:key ==# 'invsubdir'
|
||||||
let subdir = vimwiki#vars#get_bufferlocal('subdir')
|
let subdir = vimwiki#vars#get_bufferlocal('subdir')
|
||||||
let b:vimwiki_invsubdir = vimwiki#base#invsubdir(subdir)
|
call setbufvar(buffer, 'vimwiki_invsubdir', vimwiki#base#invsubdir(subdir))
|
||||||
return b:vimwiki_invsubdir
|
|
||||||
elseif a:key ==# 'existing_wikifiles'
|
elseif a:key ==# 'existing_wikifiles'
|
||||||
let b:vimwiki_existing_wikifiles =
|
call setbufvar(buffer, 'vimwiki_existing_wikifiles',
|
||||||
\ vimwiki#base#get_wikilinks(vimwiki#vars#get_bufferlocal('wiki_nr'), 1)
|
\ vimwiki#base#get_wikilinks(vimwiki#vars#get_bufferlocal('wiki_nr'), 1))
|
||||||
return b:vimwiki_existing_wikifiles
|
|
||||||
elseif a:key ==# 'existing_wikidirs'
|
elseif a:key ==# 'existing_wikidirs'
|
||||||
let b:vimwiki_existing_wikidirs =
|
call setbufvar(buffer, 'vimwiki_existing_wikidirs',
|
||||||
\ vimwiki#base#get_wiki_directories(vimwiki#vars#get_bufferlocal('wiki_nr'))
|
\ vimwiki#base#get_wiki_directories(vimwiki#vars#get_bufferlocal('wiki_nr')))
|
||||||
return b:vimwiki_existing_wikidirs
|
elseif a:key ==# 'prev_link'
|
||||||
|
call setbufvar(buffer, 'vimwiki_prev_link', '')
|
||||||
|
elseif a:key ==# 'fs_rescan'
|
||||||
|
call setbufvar(buffer, 'vimwiki_fs_rescan', 0)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
return getbufvar(buffer, 'vimwiki_'.a:key)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! vimwiki#vars#set_bufferlocal(key, value)
|
function! vimwiki#vars#set_bufferlocal(key, value, ...)
|
||||||
let b:vimwiki_{a:key} = a:value
|
let buffer = a:0 ? a:1 : '%'
|
||||||
|
call setbufvar(buffer, 'vimwiki_' . a:key, a:value)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,11 +66,11 @@ function! s:setup_new_wiki_buffer() "{{{
|
|||||||
|
|
||||||
" to force a rescan of the filesystem which may have changed
|
" to force a rescan of the filesystem which may have changed
|
||||||
" and update VimwikiLinks syntax group that depends on it;
|
" and update VimwikiLinks syntax group that depends on it;
|
||||||
" b:vimwiki_fs_rescan indicates that setup_filetype() has not been run
|
" 'fs_rescan' indicates that setup_filetype() has not been run
|
||||||
if exists('b:vimwiki_fs_rescan') && vimwiki#vars#get_wikilocal('maxhi')
|
if vimwiki#vars#get_bufferlocal('fs_rescan') == 1 && vimwiki#vars#get_wikilocal('maxhi')
|
||||||
set syntax=vimwiki
|
set syntax=vimwiki
|
||||||
endif
|
endif
|
||||||
let b:vimwiki_fs_rescan = 1
|
call vimwiki#vars#set_bufferlocal('fs_rescan', 1)
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
|
|
||||||
@ -90,11 +90,11 @@ function! s:setup_buffer_enter() "{{{
|
|||||||
elseif &syntax ==? 'vimwiki'
|
elseif &syntax ==? 'vimwiki'
|
||||||
" to force a rescan of the filesystem which may have changed
|
" to force a rescan of the filesystem which may have changed
|
||||||
" and update VimwikiLinks syntax group that depends on it;
|
" and update VimwikiLinks syntax group that depends on it;
|
||||||
" b:vimwiki_fs_rescan indicates that setup_filetype() has not been run
|
" 'fs_rescan' indicates that setup_filetype() has not been run
|
||||||
if exists("b:vimwiki_fs_rescan") && vimwiki#vars#get_wikilocal('maxhi')
|
if vimwiki#vars#get_bufferlocal('fs_rescan') == 1 && vimwiki#vars#get_wikilocal('maxhi')
|
||||||
set syntax=vimwiki
|
set syntax=vimwiki
|
||||||
endif
|
endif
|
||||||
let b:vimwiki_fs_rescan = 1
|
call vimwiki#vars#set_bufferlocal('fs_rescan', 1)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" The settings foldmethod, foldexpr and foldtext are local to window. Thus in
|
" The settings foldmethod, foldexpr and foldtext are local to window. Thus in
|
||||||
|
Loading…
Reference in New Issue
Block a user