From 2d6685119e0e13673e89039a80695bcf580b8d2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Sun, 29 May 2016 23:41:13 +0200 Subject: [PATCH] Feature #457: Smart autocomplete for 'cse' envs --- autoload/vimtex/env.vim | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/autoload/vimtex/env.vim b/autoload/vimtex/env.vim index c29ad2f..34e647d 100644 --- a/autoload/vimtex/env.vim +++ b/autoload/vimtex/env.vim @@ -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