diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2020-04-25 21:30:46 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2020-04-25 21:30:46 +0200 |
commit | d757bfd643cc73c2d495355c153ed0257f5d5b47 (patch) | |
tree | ff210950456938a779d98f6a2ba7321aca512897 /autoload/vimtex/syntax.vim | |
parent | 8ec73a3a8974a62a613680a6b6222a77a7b99546 (diff) | |
download | vim-polyglot-d757bfd643cc73c2d495355c153ed0257f5d5b47.tar.gz vim-polyglot-d757bfd643cc73c2d495355c153ed0257f5d5b47.zip |
Change latex provider to luatex, closes #476
Diffstat (limited to 'autoload/vimtex/syntax.vim')
-rw-r--r-- | autoload/vimtex/syntax.vim | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/autoload/vimtex/syntax.vim b/autoload/vimtex/syntax.vim new file mode 100644 index 00000000..428ccaaa --- /dev/null +++ b/autoload/vimtex/syntax.vim @@ -0,0 +1,66 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'latex') == -1 + +" vimtex - LaTeX plugin for Vim +" +" Maintainer: Karl Yngve LervÄg +" Email: karl.yngve@gmail.com +" + +function! vimtex#syntax#init() abort " {{{1 + if !get(g:, 'vimtex_syntax_enabled', 1) | return | endif + + " The following ensures that syntax addons are not loaded until after the + " filetype plugin has been sourced. See e.g. #1428 for more info. + if exists('b:vimtex') + call vimtex#syntax#load() + else + augroup vimtex_syntax + autocmd! + autocmd User VimtexEventInitPost call vimtex#syntax#load() + augroup END + endif +endfunction + +" }}}1 +function! vimtex#syntax#load() abort " {{{1 + if s:is_loaded() | return | endif + + " Initialize project cache (used e.g. for the minted package) + if !has_key(b:vimtex, 'syntax') + let b:vimtex.syntax = {} + endif + + " Initialize b:vimtex_syntax + let b:vimtex_syntax = {} + + " Reset included syntaxes (necessary e.g. when doing :e) + call vimtex#syntax#misc#include_reset() + + " Set some better defaults + syntax spell toplevel + syntax sync maxlines=500 + + " Load some general syntax improvements + call vimtex#syntax#load#general() + + " Load syntax for documentclass and packages + call vimtex#syntax#load#packages() + + " Hack to make it possible to determine if vimtex syntax was loaded + syntax match texVimtexLoaded 'dummyVimtexLoadedText' contained +endfunction + +" }}}1 + +function! s:is_loaded() abort " {{{1 + if exists('*execute') + let l:result = split(execute('syntax'), "\n") + return !empty(filter(l:result, 'v:val =~# "texVimtexLoaded"')) + else + return 0 + endif +endfunction + +" }}}1 + +endif |