Feature #457: Smart autocomplete for 'cse' envs

This commit is contained in:
Karl Yngve Lervåg 2016-05-29 23:41:13 +02:00
parent 257d2f91de
commit 2d6685119e

View File

@ -151,7 +151,17 @@ endfunction
" }}}1
function! s:input_complete(lead, cmdline, pos) " {{{1
return filter(g:vimtex_env_complete_list, 'v:val =~# ''^' . a:lead . '''')
try
let l:cands = uniq(sort(
\ g:vimtex_env_complete_list
\ + map(filter(vimtex#parser#tex(b:vimtex.tex, { 'detailed' : 0 }),
\ 'v:val =~# ''\\begin'''),
\ 'matchstr(v:val, ''\\begin{\zs\k*\ze\*\?}'')')))
catch
let l:cands = g:vimtex_env_complete_list
endtry
return filter(l:cands, 'v:val =~# ''^' . a:lead . '''')
endfunction
" }}}1