From 599f5c6fa051a48ad82965be18237b350f63aa0a Mon Sep 17 00:00:00 2001 From: Josip Palavra <4420778+tyckesak@users.noreply.github.com> Date: Wed, 16 Nov 2022 23:00:49 +0100 Subject: [PATCH 1/4] Fix TeX directive recognition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This one simple typo—probably left over from some old version—rendered TeX directives like `%! TeX program = lualatex` useless and prevented Vimtex from recognising directives at all. --- autoload/vimtex/state/class.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/vimtex/state/class.vim b/autoload/vimtex/state/class.vim index d3bf107a04..88a6c9e6fc 100644 --- a/autoload/vimtex/state/class.vim +++ b/autoload/vimtex/state/class.vim @@ -130,7 +130,7 @@ function! s:vimtex.get_tex_program() abort dict " {{{1 let l:tex_program_re = \ '\v^\c\s*\%\s*!?\s*tex\s+%(ts-)?program\s*\=\s*\zs.*\ze\s*$' - let l:lines = vimtex#parser#preamble(self.tex, {'root' : self.root})[:20] + let l:lines = vimtex#parser#preamble(self.base, {'root' : self.root})[:20] call map(l:lines, 'matchstr(v:val, l:tex_program_re)') call filter(l:lines, '!empty(v:val)') return tolower(get(l:lines, -1, '_')) From 2cfefa6b6c950a18f6724b59ac041e85040d7852 Mon Sep 17 00:00:00 2001 From: tyckesak <4420778+tyckesak@users.noreply.github.com> Date: Sat, 26 Nov 2022 18:05:05 +0100 Subject: [PATCH 2/4] =?UTF-8?q?Modify=20File=20Ending=20Recognition;=20rev?= =?UTF-8?q?ert=20=E2=80=9Cbugfix=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Turns out Vimtex did not recognise files ending in ‘.latex’ which might be the preferred ending for some; neither for ‘.tex’ and ‘.tikz’ if cased differently --- autoload/vimtex/state/class.vim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/autoload/vimtex/state/class.vim b/autoload/vimtex/state/class.vim index 88a6c9e6fc..37981a4998 100644 --- a/autoload/vimtex/state/class.vim +++ b/autoload/vimtex/state/class.vim @@ -18,8 +18,10 @@ function! vimtex#state#class#new(main, main_parser, preserve_root) abort " {{{1 endif let l:ext = fnamemodify(a:main, ':e') - let l:new.tex = index(['tex', 'dtx', 'tikz', 'ins'], l:ext) >= 0 - \ ? a:main : '' + " Recognise (La)TeX-related file extensions + let l:new.tex = empty(filter(['^(la)?tex$', '^dtx$', '^tikz$'], + \ 'l:ext =~? v:val')) + \ ? a:main : '' " Get preamble for some state parsing let l:preamble = !empty(l:new.tex) @@ -130,7 +132,7 @@ function! s:vimtex.get_tex_program() abort dict " {{{1 let l:tex_program_re = \ '\v^\c\s*\%\s*!?\s*tex\s+%(ts-)?program\s*\=\s*\zs.*\ze\s*$' - let l:lines = vimtex#parser#preamble(self.base, {'root' : self.root})[:20] + let l:lines = vimtex#parser#preamble(self.tex, {'root' : self.root})[:20] call map(l:lines, 'matchstr(v:val, l:tex_program_re)') call filter(l:lines, '!empty(v:val)') return tolower(get(l:lines, -1, '_')) From ac8c015d1ff52eca80d7eea79a859b818c0dd0be Mon Sep 17 00:00:00 2001 From: tyckesak <4420778+tyckesak@users.noreply.github.com> Date: Sat, 26 Nov 2022 18:50:44 +0100 Subject: [PATCH 3/4] Typofix nasty Vimscript Regex behaviour --- autoload/vimtex/state/class.vim | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/autoload/vimtex/state/class.vim b/autoload/vimtex/state/class.vim index 37981a4998..a9aa276735 100644 --- a/autoload/vimtex/state/class.vim +++ b/autoload/vimtex/state/class.vim @@ -19,9 +19,7 @@ function! vimtex#state#class#new(main, main_parser, preserve_root) abort " {{{1 let l:ext = fnamemodify(a:main, ':e') " Recognise (La)TeX-related file extensions - let l:new.tex = empty(filter(['^(la)?tex$', '^dtx$', '^tikz$'], - \ 'l:ext =~? v:val')) - \ ? a:main : '' + let l:new.tex = l:ext =~? '^\(\(la\)\=tex\|dtx\|tikz\)$' ? a:main : '' " Get preamble for some state parsing let l:preamble = !empty(l:new.tex) From 0529f763ee4361571f95dfbad0027d5a49e0855c Mon Sep 17 00:00:00 2001 From: tyckesak <4420778+tyckesak@users.noreply.github.com> Date: Sun, 27 Nov 2022 17:39:44 +0100 Subject: [PATCH 4/4] Apply cosmetic changes for filetype recognition Changes requested by higher power. --- autoload/vimtex/state/class.vim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/autoload/vimtex/state/class.vim b/autoload/vimtex/state/class.vim index a9aa276735..8a8cae727e 100644 --- a/autoload/vimtex/state/class.vim +++ b/autoload/vimtex/state/class.vim @@ -18,8 +18,7 @@ function! vimtex#state#class#new(main, main_parser, preserve_root) abort " {{{1 endif let l:ext = fnamemodify(a:main, ':e') - " Recognise (La)TeX-related file extensions - let l:new.tex = l:ext =~? '^\(\(la\)\=tex\|dtx\|tikz\)$' ? a:main : '' + let l:new.tex = l:ext =~? '\v^%(%(la)?tex|dtx|tikz|ins)$' ? a:main : '' " Get preamble for some state parsing let l:preamble = !empty(l:new.tex)