col('.') inside the omnicompletion function returns garbage

so use a workaround
This commit is contained in:
EinfachToll 2015-02-09 21:40:17 +01:00
parent 42f427e718
commit ac4f66586a

View File

@ -43,26 +43,30 @@ function! Complete_wikifiles(findstart, base)
let line = getline('.')[:column] let line = getline('.')[:column]
let startoflink = match(line, '\[\[\zs[^\\[]*$') let startoflink = match(line, '\[\[\zs[^\\[]*$')
if startoflink != -1 if startoflink != -1
let s:line_context = '['
return startoflink return startoflink
endif endif
if VimwikiGet('syntax') == 'markdown' if VimwikiGet('syntax') == 'markdown'
let startofinlinelink = match(line, '\[.*\](\zs.*$') let startofinlinelink = match(line, '\[.*\](\zs.*$')
if startofinlinelink != -1 if startofinlinelink != -1
let s:line_context = '['
return startofinlinelink return startofinlinelink
endif endif
endif endif
let startoftag = match(line, ':\zs[^:[:space:]]*$') let startoftag = match(line, ':\zs[^:[:space:]]*$')
if startoftag != -1 if startoftag != -1
let s:line_context = ':'
return startoftag return startoftag
endif endif
let s:line_context = ''
return -1 return -1
else else
" Completion works for wikilinks/anchors, and for tags. So first we have " Completion works for wikilinks/anchors, and for tags. s:line_content
" to find out what we're about to complete. " tells us, which string came before a:base. There seems to be no easier
let column = col('.') " solution, because calling col('.') here returns garbage.
let line = getline('.')[:(column - len(a:base))] if s:line_context == ''
let char_before_start = line[-1:-1] return []
if char_before_start == ':' elseif s:line_context == ':'
" Tags completion " Tags completion
let metadata = vimwiki#base#load_tags_metadata() let metadata = vimwiki#base#load_tags_metadata()
let tags = vimwiki#base#get_tags(metadata) let tags = vimwiki#base#get_tags(metadata)