completefunc set to CompleteSnippets()
This commit is contained in:
parent
e86a27c888
commit
e92b423040
|
@ -362,6 +362,35 @@ function! ListUltisnips() abort
|
|||
endfor
|
||||
echo '---------------------------------------------------'
|
||||
endfunction
|
||||
|
||||
function! CompleteSnippets(findstart, base)
|
||||
if a:findstart
|
||||
let l:line = getline('.')
|
||||
let l:start = col('.') - 1
|
||||
while l:start > 0 && l:line[l:start - 1] =~ '\a'
|
||||
let l:start -= 1
|
||||
endwhile
|
||||
return l:start
|
||||
else
|
||||
let l:res = []
|
||||
let l:snips = UltiSnips#SnippetsInCurrentScope(1)
|
||||
let l:keylist = sort(keys(l:snips))
|
||||
for l:key in l:keylist
|
||||
if l:key =~ '^' . a:base
|
||||
let l:item = {'word': l:key, 'menu': l:snips[l:key]}
|
||||
call add(l:res, l:item)
|
||||
endif
|
||||
endfor
|
||||
return l:res
|
||||
endif
|
||||
endfunction
|
||||
|
||||
set completefunc=CompleteSnippets
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"}}}
|
||||
|
||||
" Netrw
|
||||
|
|
Loading…
Reference in New Issue