Support for omni completion of tags
This commit is contained in:
parent
c7436a44cf
commit
a01290160c
@ -2087,6 +2087,16 @@ function! vimwiki#base#write_tags_metadata(metadata) "{{{
|
|||||||
call writefile(entries, metadata_path)
|
call writefile(entries, metadata_path)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
|
" vimwiki#base#get_tags
|
||||||
|
" Returns list of unique tags found in metadata
|
||||||
|
function! vimwiki#base#get_tags(metadata) "{{{
|
||||||
|
let tags = {}
|
||||||
|
for entry in a:metadata
|
||||||
|
let tags[entry.tagname] = 1
|
||||||
|
endfor
|
||||||
|
return keys(tags)
|
||||||
|
endfunction " }}}
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" Command completion functions {{{
|
" Command completion functions {{{
|
||||||
|
@ -49,9 +49,25 @@ function! Complete_wikifiles(findstart, base)
|
|||||||
return startofinlinelink
|
return startofinlinelink
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
let startoftag = match(line, ':\zs[^:[:space:]]*$')
|
||||||
|
if startoftag != -1
|
||||||
|
return startoftag
|
||||||
|
endif
|
||||||
return -1
|
return -1
|
||||||
else
|
else
|
||||||
if a:base !~ '#'
|
" Completion works for wikilinks/anchors, and for tags. So first we have
|
||||||
|
" to find out what we're about to complete.
|
||||||
|
let column = col('.')
|
||||||
|
let line = getline('.')[:(column - len(a:base))]
|
||||||
|
let char_before_start = line[-1:-1]
|
||||||
|
if char_before_start == ':'
|
||||||
|
" Tags completion
|
||||||
|
let metadata = vimwiki#base#load_tags_metadata()
|
||||||
|
let tags = vimwiki#base#get_tags(metadata)
|
||||||
|
call filter(tags,
|
||||||
|
\ "v:val[:" . (len(a:base)-1) . "] == '" . substitute(a:base, "'", "''", '') . "'" )
|
||||||
|
return tags
|
||||||
|
elseif a:base !~ '#'
|
||||||
" we look for wiki files
|
" we look for wiki files
|
||||||
|
|
||||||
if a:base =~# '^wiki\d:'
|
if a:base =~# '^wiki\d:'
|
||||||
|
Loading…
Reference in New Issue
Block a user