From e647ebe16a0267849c26fb2cc891d7a8b43d5f99 Mon Sep 17 00:00:00 2001 From: mbrunnen Date: Tue, 5 Apr 2016 18:10:46 +0200 Subject: [PATCH] Added filename completer for standalone files * Added filename completer for standalone files * added the tikz file --- autoload/vimtex/complete.vim | 23 ++++++++++++++++++++++- test/features/completions/main.tex | 1 + test/features/completions/tikz_pic.tex | 10 ++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 test/features/completions/tikz_pic.tex diff --git a/autoload/vimtex/complete.vim b/autoload/vimtex/complete.vim index e26be99..1c3642b 100644 --- a/autoload/vimtex/complete.vim +++ b/autoload/vimtex/complete.vim @@ -17,7 +17,7 @@ endfunction function! vimtex#complete#init_script() " {{{1 if !g:vimtex_complete_enabled | return | endif - let s:completers = [s:bib, s:ref, s:img, s:inc, s:pdf, s:gls] + let s:completers = [s:bib, s:ref, s:img, s:inc, s:pdf, s:sta, s:gls] endfunction " }}}1 @@ -414,6 +414,27 @@ function! s:pdf.complete(regex) dict " {{{2 return self.candidates endfunction +" }}}1 +" {{{1 Filenames (\includestandalone) + +let s:sta = { + \ 'patterns' : ['\v\\includestandalone%(\s*\[[^]]*\])?\s*\{[^}]*$'], + \ 'enabled' : 1, + \} + +function! s:sta.complete(regex) dict " {{{2 + let self.candidates = substitute(globpath(b:vimtex.root, '**/*.tex'), '\.tex', '', 'g') + let self.candidates = split(self.candidates, '\n') + let self.candidates = map(self.candidates, + \ 'strpart(v:val, len(b:vimtex.root)+1)') + let self.candidates = map(self.candidates, '{ + \ ''word'' : v:val, + \ ''abbr'' : v:val, + \ ''menu'' : '' [includestandalone]'', + \}') + return self.candidates +endfunction + " }}}1 " {{{1 Glossary diff --git a/test/features/completions/main.tex b/test/features/completions/main.tex index f8ef456..23d04b4 100644 --- a/test/features/completions/main.tex +++ b/test/features/completions/main.tex @@ -3,6 +3,7 @@ \usepackage{cleveref} \usepackage{graphicx} \usepackage{pdfpages} +\usepackage{standalone} \usepackage[backend=biber,style=authoryear]{biblatex} \addbibresource{biblatex-examples.bib} diff --git a/test/features/completions/tikz_pic.tex b/test/features/completions/tikz_pic.tex new file mode 100644 index 0000000..a9acb68 --- /dev/null +++ b/test/features/completions/tikz_pic.tex @@ -0,0 +1,10 @@ +\documentclass{standalone} +\usepackage{standalone} +\usepackage{tikz} +\begin{document} +\begin{tikzpicture} + \draw ((0, 0) node[below left]{\large Reliability} -- + (0: 4) node[below right]{\large Acquisition costs} -- + (60: 4) node[above]{\large Energy consumption} -- cycle; +\end{tikzpicture} +\end{document}