Skip to content

Commit

Permalink
merge: add full syntax support to Vimtex
Browse files Browse the repository at this point in the history
This PR brings full syntax support to Vimtex. As a major and partly
breaking change, it marks the start of version 2.0.

refer: #1834
  • Loading branch information
lervag committed Nov 24, 2020
2 parents 7c886a0 + e42225e commit d623e56
Show file tree
Hide file tree
Showing 117 changed files with 2,768 additions and 2,339 deletions.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,11 @@ disabled if desired.
- Context menu on citations (e.g. `\cite{...}`) mapped to `<cr>`
- Improved folding (`:h 'foldexpr'`)
- Improved indentation (`:h 'indentexpr'`)
- Improved syntax highlighting
- Syntax highlighting
- A consistent core syntax specification
- General syntax highlighting for several popular LaTeX packages
- Nested syntax highlighting for several popular LaTeX packages
- Highlight matching delimiters
- Support for `biblatex`/`natbib` package
- Support for `cleveref` package
- Support for `listings` package
- Nested syntax highlighting (`minted`, `dot2tex`, `lualatex`,
`gnuplottex`, `asymptote`, `pythontex`)
- Support for multi-file project packages
- [import](http://ctan.uib.no/macros/latex/contrib/import/import.pdf)
- [subfiles](http://ctan.uib.no/macros/latex/contrib/subfiles/subfiles.pdf)
Expand Down
9 changes: 0 additions & 9 deletions after/syntax/tex.vim

This file was deleted.

2 changes: 1 addition & 1 deletion autoload/vimtex/delim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ function! s:parser_tex(match, lnum, cnum, side, type, direction) abort " {{{1
\ 'close' : '\m' . escape(a:match, '$'),
\}
let result.side = vimtex#syntax#in(
\ (a:match ==# '$' ? 'texMathZoneX' : 'texMathZoneY'),
\ (a:match ==# '$' ? 'texMathRegionX' : 'texMathRegionXX'),
\ a:lnum, a:cnum+1)
\ ? 'open' : 'close'
let result.is_open = result.side ==# 'open'
Expand Down
40 changes: 24 additions & 16 deletions autoload/vimtex/options.vim
Original file line number Diff line number Diff line change
Expand Up @@ -261,16 +261,17 @@ function! vimtex#options#init() abort " {{{1

call s:init_option('vimtex_subfile_start_local', 0)

call s:init_option('vimtex_syntax_alpha', $VIMTEX_ALPHA)
call s:init_option('vimtex_syntax_config', {
\ 'conceal': get(g:, 'tex_conceal', 'abdmgsS'),
\ 'conceal_set_super':
\ get(g:, 'tex_superscripts', '[0-9a-zA-W.,:;+-<>/()=]'),
\ 'conceal_set_sub':
\ get(g:, 'tex_subscripts', '[0-9aehijklmnoprstuvx,+-/().]'),
\})

call s:init_option('vimtex_syntax_enabled', 1)
call s:init_option('vimtex_syntax_conceal_default', 1)
call s:init_option('vimtex_syntax_conceal', {
\ 'accents': g:vimtex_syntax_conceal_default,
\ 'greek': g:vimtex_syntax_conceal_default,
\ 'math_bounds': g:vimtex_syntax_conceal_default,
\ 'math_delimiters': g:vimtex_syntax_conceal_default,
\ 'math_super_sub': g:vimtex_syntax_conceal_default,
\ 'math_symbols': g:vimtex_syntax_conceal_default,
\ 'styles': g:vimtex_syntax_conceal_default,
\})
call s:init_option('vimtex_syntax_nested', {
\ 'aliases' : {
\ 'C' : 'c',
Expand All @@ -280,21 +281,27 @@ function! vimtex#options#init() abort " {{{1
\ 'cs' : [
\ 'csBraces',
\ ],
\ 'python' : [
\ 'pythonEscape',
\ 'pythonBEscape',
\ 'pythonBytesEscape',
\ 'haskell' : [
\ 'hsVarSym',
\ ],
\ 'java' : [
\ 'javaError',
\ ],
\ 'haskell' : [
\ 'hsVarSym',
\ 'markdown' : [
\ 'mkdNonListItemBlock',
\ ],
\ 'python' : [
\ 'pythonEscape',
\ 'pythonBEscape',
\ 'pythonBytesEscape',
\ ],
\ }
\})
call s:init_option('vimtex_syntax_autoload_packages', ['amsmath'])
call s:init_option('vimtex_syntax_nospell_commands', [])
call s:init_option('vimtex_syntax_packages', {
\ 'amsmath': {'load': 2},
\ 'babel': {'conceal': g:vimtex_syntax_conceal_default},
\})

call s:init_option('vimtex_texcount_custom_arg', '')

Expand Down Expand Up @@ -429,6 +436,7 @@ function! s:check_for_deprecated_options() abort " {{{1
\ 'g:vimtex_quickfix_ignored_warnings',
\ 'g:vimtex_quickfix_latexlog',
\ 'g:vimtex_quickfix_warnings',
\ 'g:vimtex_syntax_autoload_packages',
\ 'g:vimtex_textidote_jar',
\ 'g:vimtex_toc_fold',
\ 'g:vimtex_toc_fold_level_start',
Expand Down
36 changes: 1 addition & 35 deletions autoload/vimtex/syntax.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,6 @@
" Email: karl.yngve@gmail.com
"

function! vimtex#syntax#init() abort " {{{1
" This script is a fork of version 119 (dated 2020-06-29) of the syntax script
" "tex.vim" created and maintained by Charles E. Campbell [0].
"
" [0]: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX

if exists('b:current_syntax')
return
elseif !get(g:, 'vimtex_syntax_alpha')
source $VIMRUNTIME/syntax/tex.vim
return
endif

call vimtex#syntax#core#init()
endfunction

" }}}1
function! vimtex#syntax#init_post() 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#after#load()
else
augroup vimtex_syntax
autocmd!
autocmd User VimtexEventInitPost call vimtex#syntax#after#load()
augroup END
endif
endfunction

" }}}1

function! vimtex#syntax#stack(...) abort " {{{1
let l:pos = a:0 > 0 ? [a:1, a:2] : [line('.'), col('.')]
if mode() ==# 'i'
Expand All @@ -60,7 +26,7 @@ endfunction

" }}}1
function! vimtex#syntax#in_mathzone(...) abort " {{{1
return call('vimtex#syntax#in', ['texMathZone'] + a:000)
return call('vimtex#syntax#in', ['texMathRegion'] + a:000)
endfunction

" }}}1
136 changes: 0 additions & 136 deletions autoload/vimtex/syntax/after.vim

This file was deleted.

Loading

0 comments on commit d623e56

Please sign in to comment.