From bb04215684ff14da69591751f154d7739b9a69d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Mon, 4 Jan 2016 13:05:25 +0100 Subject: [PATCH] Simple version of includegraphics complete (#308) --- README.md | 2 +- autoload/vimtex/complete.vim | 35 ++++++++++++++++++---- doc/vimtex.txt | 56 +++++++++++++++++++----------------- 3 files changed, 61 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index d68ba1b..5b1b802 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ disabled if desired. - [qpdfview](https://launchpad.net/qpdfview) - [SumatraPDF](http://www.sumatrapdfreader.org/free-pdf-reader.html) - Other viewers are supported through a general interface -- Completion of citations and labels +- Completion of citations, labels, and file names for figures - Document navigation through - table of content - table of labels diff --git a/autoload/vimtex/complete.vim b/autoload/vimtex/complete.vim index 95047e2..3cac221 100644 --- a/autoload/vimtex/complete.vim +++ b/autoload/vimtex/complete.vim @@ -16,7 +16,7 @@ endfunction function! vimtex#complete#init_script() " {{{1 if !g:vimtex_complete_enabled | return | endif - let s:completers = [s:bib, s:ref] + let s:completers = [s:bib, s:ref, s:img] endfunction " }}}1 @@ -67,7 +67,7 @@ endfunction " {{{1 Bibtex completion let s:bib = { - \ 'pattern' : '\\\a*cite\a*\*\?\(\[[^\]]*\]\)*\_\s*{[^{}]*', + \ 'pattern' : '\v\\\a*cite\a*%(\s*\[[^]]*\])?\s*\{[^{}]*', \ 'enabled' : 1, \ 'bibs' : '''\v%(%(\\@ - let g:vimtex_complete_patterns = { - \ 'ref' : '\C\\v\?\(eq\|page\|[cC]\)\?ref\*\?\_\s*{[^{}]*', - \ 'bib' : '\C\\\a*cite\a*\*\?\(\[[^\]]*\]\)*\_\s*{[^{}]*', - \ }) -< *g:vimtex_change_complete_envs* Define a list of environments that will be completed when changing the surrounding environments (see |(vimtex-change-env)|). @@ -1230,14 +1221,12 @@ If |g:vimtex_complete_enabled| is 1 (default), then |vimtex| sets the 'omnifunc' to provide omni completion, see |compl-omni|. Omni completion is then accessible with |i_CTRL-X_CTRL-O|. -The omni completion completes both labels and citations. If desired, one may -set |g:vimtex_complete_close_braces|, which makes the completion include -closing braces. +The omni completion completes labels, citations, and file names for figures. +If desired, one may set |g:vimtex_complete_close_braces|, which makes the +completion include closing braces. Associated settings: |g:vimtex_complete_enabled| - |g:vimtex_complete_patterns.ref| - |g:vimtex_complete_patterns.bib| |g:vimtex_complete_close_braces| |g:vimtex_complete_recursive_bib| @@ -1245,10 +1234,10 @@ Associated settings: Complete labels~ *vimtex-complete-labels* -Label completion is triggered by '\ref{' commands as defined with -|g:vimtex_complete_patterns.ref|. The completion parses every relevant aux -file to gather the completion candidates. This is important, because it means -that the completion only works when the LaTeX document has been compiled. +Label completion is triggered by '\ref{' commands. The completion parses every +relevant aux file to gather the completion candidates. This is important, +because it means that the completion only works when the LaTeX document has +been compiled. As an example: > @@ -1268,10 +1257,9 @@ number. The label completion matches: Complete citations~ *vimtex-complete-cites* -Citation completion is triggered by '\cite{' commands as defined with -|g:vimtex_complete_patterns.bib|. The completion parses included bibliography -files (`*.bib`) and `thebibliography` environments to gather the completion -candidates. +Citation completion is triggered by '\cite{' commands. The completion parses +included bibliography files (`*.bib`) and `thebibliography` environments to +gather the completion candidates. As an example, assume that a bibliography file is included with the following entry: > @@ -1291,6 +1279,18 @@ Then the bibliography key `knuth1981` will be completed with e.g.: > In particular, note that regular expressions (or vim patterns) can be used after '\cite{' to search for candidates. +------------------------------------------------------------------------------ +Complete file names for figures~ + *vimtex-complete-images* + +File name completion for figures is triggered by '\includegraphic{' commands. + +As an example: > + + \includegraphic{fig + +offers a list of all matching file names. + ------------------------------------------------------------------------------ Autocomplete~ *vimtex-complete-auto* @@ -1311,7 +1311,10 @@ documents with |neocomplete| and |vimtex|s omni completion function: > let g:neocomplete#sources#omni#input_patterns = {} endif let g:neocomplete#sources#omni#input_patterns.tex = - \ '\v\\\a*(ref|cite)\a*([^]]*\])?\{([^}]*,)*[^}]*' + \ '\v\\%(' + \ . '\a*%(ref|cite)\a*%(\s*\[[^]]*\])?\s*\{[^{}]*' + \ . '|includegraphics%(\s*\[[^]]*\])?\s*\{[^{}]*' + \ . ')' < YouCompleteMe~ *vimtex-complete-youcompleteme* @@ -1334,7 +1337,8 @@ To enable automatic completion with |youcompleteme|, use the following options: let g:ycm_semantic_triggers = {} endif let g:ycm_semantic_triggers.tex = [ - \ 're!\\[A-Za-z]*(ref|cite)[A-Za-z]*([^]]*])?{([^}]*, ?)*' + \ 're!\\[A-Za-z]*(ref|cite)[A-Za-z]*([^]]*])?{([^}]*,?)*', + \ 're!\\includegraphics([^]]*])?{[^}]*' \ ] ==============================================================================