Skip to content

Commit

Permalink
feat(syntax): revert Region -> Zone
Browse files Browse the repository at this point in the history
refer: #1880, #1883
  • Loading branch information
lervag committed Dec 7, 2020
1 parent cea1011 commit fa2bd66
Show file tree
Hide file tree
Showing 29 changed files with 184 additions and 186 deletions.
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 ==# '$' ? 'texMathRegionX' : 'texMathRegionXX'),
\ (a:match ==# '$' ? 'texMathZoneX' : 'texMathZoneXX'),
\ a:lnum, a:cnum+1)
\ ? 'open' : 'close'
let result.is_open = result.side ==# 'open'
Expand Down
4 changes: 1 addition & 3 deletions autoload/vimtex/syntax.vim
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ endfunction
" }}}1
function! vimtex#syntax#in_mathzone(...) abort " {{{1
let l:ids = reverse(call('vimtex#syntax#stack', a:000))
let l:index = match(l:ids, '^texMath\%(' . s:mathzones . '\|Text\)')
let l:index = match(l:ids, '^texMath\%(Zone\|Text\)')
return l:index >= 0
\ && match(l:ids[l:index], '^texMathText') == -1
endfunction

let s:mathzones = g:vimtex_syntax_enabled ? 'Region' : 'Zone'

" }}}1
214 changes: 107 additions & 107 deletions autoload/vimtex/syntax/core.vim
Original file line number Diff line number Diff line change
Expand Up @@ -307,22 +307,22 @@ function! vimtex#syntax#core#init() abort " {{{1
call vimtex#syntax#core#new_arg('texTabularArg', {'contains': ''})

" }}}2
" {{{2 Region: Verbatim
" {{{2 Zone: Verbatim

" Verbatim environment
call vimtex#syntax#core#new_region_env('texVerbRegion', '[vV]erbatim')
call vimtex#syntax#core#new_region_env('texVerbZone', '[vV]erbatim')

" Verbatim inline
syntax match texCmdVerb "\\verb\>\*\?" nextgroup=texVerbRegionInline
call vimtex#syntax#core#new_arg('texVerbRegionInline', {
syntax match texCmdVerb "\\verb\>\*\?" nextgroup=texVerbZoneInline
call vimtex#syntax#core#new_arg('texVerbZoneInline', {
\ 'contains': '',
\ 'matcher': 'start="\z([^\ta-zA-Z]\)" end="\z1"'
\})

" }}}2
" {{{2 Region: Expl3
" {{{2 Zone: Expl3

syntax region texE3Region matchgroup=texCmdE3
syntax region texE3Zone matchgroup=texCmdE3
\ start='\\\%(ExplSyntaxOn\|ProvidesExpl\%(Package\|Class\|File\)\)'
\ end='\\ExplSyntaxOff\|\%$'
\ transparent
Expand All @@ -334,17 +334,17 @@ function! vimtex#syntax#core#init() abort " {{{1
call vimtex#syntax#core#new_opt('texE3Opt', {'next': 'texE3Arg'})
call vimtex#syntax#core#new_arg('texE3Arg', {'next': 'texE3Arg', 'opts': 'contained transparent'})

syntax match texE3CmdNestedRegionEnd '\\\ExplSyntaxOff'
syntax match texE3CmdNestedZoneEnd '\\\ExplSyntaxOff'
\ contained containedin=texE3Arg,texE3Group

syntax match texE3Var contained containedin=@texClusterE3 "\\\a*\%(_\+[a-zA-Z]\+\)\+\>"
syntax match texE3Func contained containedin=@texClusterE3 "\\\a*\%(_\+[a-zA-Z]\+\)\+:[a-zA-Z]*"
syntax match texE3Parm contained containedin=@texClusterE3 "#\+\d"

syntax cluster texClusterE3 contains=texE3Region,texE3Arg,texE3Group
syntax cluster texClusterE3 contains=texE3Zone,texE3Arg,texE3Group

" }}}2
" {{{2 Region: Math
" {{{2 Zone: Math

" Define math region group
call vimtex#syntax#core#new_arg('texMathGroup', {'contains': '@texClusterMath'})
Expand All @@ -362,20 +362,20 @@ function! vimtex#syntax#core#init() abort " {{{1

" Math regions: Inline Math Zones
if g:vimtex_syntax_conceal.math_bounds
syntax region texMathRegion matchgroup=texMathDelimRegion concealends contains=@texClusterMath keepend start="\\(" end="\\)"
syntax region texMathRegion matchgroup=texMathDelimRegion concealends contains=@texClusterMath keepend start="\\\[" end="\\]"
syntax region texMathRegionX matchgroup=texMathDelimRegion concealends contains=@texClusterMath start="\$" skip="\\\\\|\\\$" end="\$"
syntax region texMathRegionXX matchgroup=texMathDelimRegion concealends contains=@texClusterMath keepend start="\$\$" end="\$\$"
syntax region texMathZone matchgroup=texMathDelimZone concealends contains=@texClusterMath keepend start="\\(" end="\\)"
syntax region texMathZone matchgroup=texMathDelimZone concealends contains=@texClusterMath keepend start="\\\[" end="\\]"
syntax region texMathZoneX matchgroup=texMathDelimZone concealends contains=@texClusterMath start="\$" skip="\\\\\|\\\$" end="\$"
syntax region texMathZoneXX matchgroup=texMathDelimZone concealends contains=@texClusterMath keepend start="\$\$" end="\$\$"
else
syntax region texMathRegion matchgroup=texMathDelimRegion contains=@texClusterMath keepend start="\\(" end="\\)"
syntax region texMathRegion matchgroup=texMathDelimRegion contains=@texClusterMath keepend start="\\\[" end="\\]"
syntax region texMathRegionX matchgroup=texMathDelimRegion contains=@texClusterMath start="\$" skip="\\\\\|\\\$" end="\$"
syntax region texMathRegionXX matchgroup=texMathDelimRegion contains=@texClusterMath keepend start="\$\$" end="\$\$"
syntax region texMathZone matchgroup=texMathDelimZone contains=@texClusterMath keepend start="\\(" end="\\)"
syntax region texMathZone matchgroup=texMathDelimZone contains=@texClusterMath keepend start="\\\[" end="\\]"
syntax region texMathZoneX matchgroup=texMathDelimZone contains=@texClusterMath start="\$" skip="\\\\\|\\\$" end="\$"
syntax region texMathZoneXX matchgroup=texMathDelimZone contains=@texClusterMath keepend start="\$\$" end="\$\$"
endif

" Math regions: \ensuremath{...}
syntax match texCmdMath "\\ensuremath\>" nextgroup=texMathRegionEnsured
call vimtex#syntax#core#new_arg('texMathRegionEnsured', {'contains': '@texClusterMath'})
syntax match texCmdMath "\\ensuremath\>" nextgroup=texMathZoneEnsured
call vimtex#syntax#core#new_arg('texMathZoneEnsured', {'contains': '@texClusterMath'})

" Bad/Mismatched math
syntax match texMathError "\\[\])]"
Expand Down Expand Up @@ -455,13 +455,13 @@ function! vimtex#syntax#core#init_highlights() abort " {{{1
highlight def link texMathDelim Type
highlight def link texMathEnvArgName Delimiter
highlight def link texMathOper Operator
highlight def link texMathRegion Special
highlight def link texMathZone Special
highlight def link texOpt Identifier
highlight def link texOptSep NormalNC
highlight def link texParm Special
highlight def link texPartArgTitle String
highlight def link texRefArg Special
highlight def link texRegion PreCondit
highlight def link texZone PreCondit
highlight def link texSpecialChar SpecialChar
highlight def link texSymbol SpecialChar
highlight def link texTitleArg Underlined
Expand All @@ -470,91 +470,91 @@ function! vimtex#syntax#core#init_highlights() abort " {{{1
highlight def texStyleItal gui=italic cterm=italic

" Inherited groups
highlight def link texArgNew texCmd
highlight def link texAuthorOpt texOpt
highlight def link texCmdAccent texCmd
highlight def link texCmdAuthor texCmd
highlight def link texCmdBib texCmd
highlight def link texCmdClass texCmd
highlight def link texCmdConditional texCmd
highlight def link texCmdDef texCmdNew
highlight def link texCmdEnv texCmd
highlight def link texCmdE3 texCmd
highlight def link texCmdFootnote texCmd
highlight def link texCmdGreek texCmd
highlight def link texCmdInput texCmd
highlight def link texCmdItem texCmdEnv
highlight def link texCmdLet texCmdNew
highlight def link texCmdLigature texSpecialChar
highlight def link texCmdMath texCmd
highlight def link texCmdMathEnv texCmdEnv
highlight def link texCmdMathText texCmd
highlight def link texCmdNew texCmd
highlight def link texCmdNewcmd texCmdNew
highlight def link texCmdNewenv texCmd
highlight def link texCmdNoSpell texCmd
highlight def link texCmdPackage texCmd
highlight def link texCmdPart texCmd
highlight def link texCmdRef texCmd
highlight def link texCmdSize texCmdType
highlight def link texCmdSpaceCode texCmd
highlight def link texCmdStyle texCmd
highlight def link texCmdStyle texCmdType
highlight def link texCmdStyleBold texCmd
highlight def link texCmdStyleBoldItal texCmd
highlight def link texCmdStyleItal texCmd
highlight def link texCmdStyleItalBold texCmd
highlight def link texCmdTitle texCmd
highlight def link texCmdVerb texCmd
highlight def link texCommentAcronym texComment
highlight def link texCommentURL texComment
highlight def link texConditionalArg texArg
highlight def link texDefArgName texArgNew
highlight def link texDefParm texParm
highlight def link texE3Cmd texCmd
highlight def link texE3Delim texDelim
highlight def link texE3Func texCmdType
highlight def link texE3Opt texOpt
highlight def link texE3Parm texParm
highlight def link texE3Var texCmd
highlight def link texEnvOpt texOpt
highlight def link texFileArg texArg
highlight def link texFileOpt texOpt
highlight def link texFilesArg texFileArg
highlight def link texFilesOpt texFileOpt
highlight def link texGroupError texError
highlight def link texLetArgEqual texSymbol
highlight def link texLetArgName texArgNew
highlight def link texLigature texSymbol
highlight def link texMathArg texMathRegion
highlight def link texMathArrayArg texOpt
highlight def link texMathCmd texCmd
highlight def link texMathCmdStyle texMathCmd
highlight def link texMathDelimMod texMathDelim
highlight def link texMathDelimRegion texDelim
highlight def link texMathError texError
highlight def link texMathErrorDelim texError
highlight def link texMathGroup texMathRegion
highlight def link texMathRegionEnsured texMathRegion
highlight def link texMathRegionEnv texMathRegion
highlight def link texMathRegionEnvStarred texMathRegion
highlight def link texMathRegionX texMathRegion
highlight def link texMathRegionXX texMathRegion
highlight def link texMathSub texMathRegion
highlight def link texMathSuper texMathRegion
highlight def link texMathSymbol texCmd
highlight def link texNewcmdArgName texArgNew
highlight def link texNewcmdOpt texOpt
highlight def link texNewcmdParm texParm
highlight def link texNewenvArgName texEnvArgName
highlight def link texNewenvOpt texOpt
highlight def link texNewenvParm texParm
highlight def link texOptEqual texSymbol
highlight def link texRefOpt texOpt
highlight def link texTabularArg texOpt
highlight def link texTabularChar texSymbol
highlight def link texVerbRegion texRegion
highlight def link texVerbRegionInline texVerbRegion
highlight def link texArgNew texCmd
highlight def link texAuthorOpt texOpt
highlight def link texCmdAccent texCmd
highlight def link texCmdAuthor texCmd
highlight def link texCmdBib texCmd
highlight def link texCmdClass texCmd
highlight def link texCmdConditional texCmd
highlight def link texCmdDef texCmdNew
highlight def link texCmdEnv texCmd
highlight def link texCmdE3 texCmd
highlight def link texCmdFootnote texCmd
highlight def link texCmdGreek texCmd
highlight def link texCmdInput texCmd
highlight def link texCmdItem texCmdEnv
highlight def link texCmdLet texCmdNew
highlight def link texCmdLigature texSpecialChar
highlight def link texCmdMath texCmd
highlight def link texCmdMathEnv texCmdEnv
highlight def link texCmdMathText texCmd
highlight def link texCmdNew texCmd
highlight def link texCmdNewcmd texCmdNew
highlight def link texCmdNewenv texCmd
highlight def link texCmdNoSpell texCmd
highlight def link texCmdPackage texCmd
highlight def link texCmdPart texCmd
highlight def link texCmdRef texCmd
highlight def link texCmdSize texCmdType
highlight def link texCmdSpaceCode texCmd
highlight def link texCmdStyle texCmd
highlight def link texCmdStyle texCmdType
highlight def link texCmdStyleBold texCmd
highlight def link texCmdStyleBoldItal texCmd
highlight def link texCmdStyleItal texCmd
highlight def link texCmdStyleItalBold texCmd
highlight def link texCmdTitle texCmd
highlight def link texCmdVerb texCmd
highlight def link texCommentAcronym texComment
highlight def link texCommentURL texComment
highlight def link texConditionalArg texArg
highlight def link texDefArgName texArgNew
highlight def link texDefParm texParm
highlight def link texE3Cmd texCmd
highlight def link texE3Delim texDelim
highlight def link texE3Func texCmdType
highlight def link texE3Opt texOpt
highlight def link texE3Parm texParm
highlight def link texE3Var texCmd
highlight def link texEnvOpt texOpt
highlight def link texFileArg texArg
highlight def link texFileOpt texOpt
highlight def link texFilesArg texFileArg
highlight def link texFilesOpt texFileOpt
highlight def link texGroupError texError
highlight def link texLetArgEqual texSymbol
highlight def link texLetArgName texArgNew
highlight def link texLigature texSymbol
highlight def link texMathArg texMathZone
highlight def link texMathArrayArg texOpt
highlight def link texMathCmd texCmd
highlight def link texMathCmdStyle texMathCmd
highlight def link texMathDelimMod texMathDelim
highlight def link texMathDelimZone texDelim
highlight def link texMathError texError
highlight def link texMathErrorDelim texError
highlight def link texMathGroup texMathZone
highlight def link texMathZoneEnsured texMathZone
highlight def link texMathZoneEnv texMathZone
highlight def link texMathZoneEnvStarred texMathZone
highlight def link texMathZoneX texMathZone
highlight def link texMathZoneXX texMathZone
highlight def link texMathSub texMathZone
highlight def link texMathSuper texMathZone
highlight def link texMathSymbol texCmd
highlight def link texNewcmdArgName texArgNew
highlight def link texNewcmdOpt texOpt
highlight def link texNewcmdParm texParm
highlight def link texNewenvArgName texEnvArgName
highlight def link texNewenvOpt texOpt
highlight def link texNewenvParm texParm
highlight def link texOptEqual texSymbol
highlight def link texRefOpt texOpt
highlight def link texTabularArg texOpt
highlight def link texTabularChar texSymbol
highlight def link texVerbZone texZone
highlight def link texVerbZoneInline texVerbZone
endfunction

" }}}1
Expand Down Expand Up @@ -633,7 +633,7 @@ function! vimtex#syntax#core#new_region_math(mathzone, ...) abort " {{{1
\ 'contained contains=texCmdMathEnv'
\ (empty(l:cfg.next) ? '' : 'nextgroup=' . l:cfg.next . ' skipwhite skipnl')
execute 'syntax match texMathError "\\end{' . l:envname . '}"'
execute 'syntax region texMathRegionEnv'
execute 'syntax region texMathZoneEnv'
\ 'start="\\begin{\z(' . l:envname . '\)}"'
\ 'end="\\end{\z1}"'
\ 'contains=texMathEnvBgnEnd,@texClusterMath'
Expand Down
6 changes: 3 additions & 3 deletions autoload/vimtex/syntax/p/asymptote.vim
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ function! vimtex#syntax#p#asymptote#load(cfg) abort " {{{1
\ ? {}
\ : {'contains': '@vimtex_nested_asy'}

call vimtex#syntax#core#new_region_env('texAsymptoteRegion', 'asy', l:opts)
call vimtex#syntax#core#new_region_env('texAsymptoteRegion', 'asydef', l:opts)
call vimtex#syntax#core#new_region_env('texAsymptoteZone', 'asy', l:opts)
call vimtex#syntax#core#new_region_env('texAsymptoteZone', 'asydef', l:opts)

highlight def link texAsymptoteRegion texRegion
highlight def link texAsymptoteZone texZone
endfunction

" }}}1
2 changes: 1 addition & 1 deletion autoload/vimtex/syntax/p/circuitikz.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function! vimtex#syntax#p#circuitikz#load(cfg) abort " {{{1
syntax match texTikzEnvBgn "\\begin{circuitikz}"
\ nextgroup=texTikzOpt skipwhite skipnl
\ contains=texCmdEnv
call vimtex#syntax#core#new_region_env('texTikzRegion', 'circuitikz', {
call vimtex#syntax#core#new_region_env('texTikzZone', 'circuitikz', {
\ 'contains': '@texClusterTikz',
\ 'transparent': 1,
\})
Expand Down
2 changes: 1 addition & 1 deletion autoload/vimtex/syntax/p/dot2texi.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

function! vimtex#syntax#p#dot2texi#load(cfg) abort " {{{1
call vimtex#syntax#nested#include('dot')
call vimtex#syntax#core#new_region_env('texDotRegion', 'dot2tex',
call vimtex#syntax#core#new_region_env('texDotZone', 'dot2tex',
\ {'contains': '@vimtex_nested_dot'})
endfunction

Expand Down
2 changes: 1 addition & 1 deletion autoload/vimtex/syntax/p/gnuplottex.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

function! vimtex#syntax#p#gnuplottex#load(cfg) abort " {{{1
call vimtex#syntax#nested#include('gnuplot')
call vimtex#syntax#core#new_region_env('texGnuplotRegion', 'gnuplot',
call vimtex#syntax#core#new_region_env('texGnuplotZone', 'gnuplot',
\ {'contains': '@vimtex_nested_gnuplot'})
endfunction

Expand Down
12 changes: 6 additions & 6 deletions autoload/vimtex/syntax/p/listings.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function! vimtex#syntax#p#listings#load(cfg) abort " {{{1
\ {_, x -> matchstr(x, 'language=\zs\w\+')})

" Match inline listings
syntax match texCmdVerb "\\lstinline\>" nextgroup=texVerbRegionInline
syntax match texCmdVerb "\\lstinline\>" nextgroup=texVerbZoneInline

" Match input file commands
syntax match texCmd "\\lstinputlisting\>"
Expand All @@ -27,7 +27,7 @@ function! vimtex#syntax#p#listings#load(cfg) abort " {{{1
syntax match texLstEnvBgn "\\begin{lstlisting}"
\ nextgroup=texLstOpt skipwhite skipnl contains=texCmdEnv
call vimtex#syntax#core#new_opt('texLstOpt')
call vimtex#syntax#core#new_region_env('texLstRegion', 'lstlisting', {
call vimtex#syntax#core#new_region_env('texLstZone', 'lstlisting', {
\ 'contains': 'texLstEnvBgn',
\})

Expand All @@ -36,7 +36,7 @@ function! vimtex#syntax#p#listings#load(cfg) abort " {{{1
let l:cluster = vimtex#syntax#nested#include(l:nested)
if empty(l:cluster) | continue | endif

let l:grp = 'texLstRegion' . toupper(l:nested[0]) . l:nested[1:]
let l:grp = 'texLstZone' . toupper(l:nested[0]) . l:nested[1:]

execute 'syntax match texLstsetArg'
\ '"\c{\_[^}]*language=' . l:nested . '\%(\s*,\|}\)"'
Expand All @@ -56,10 +56,10 @@ function! vimtex#syntax#p#listings#load(cfg) abort " {{{1
\ 'contains=texCmdEnv,texLstEnvBgn,@' . l:cluster
endfor

highlight def link texCmdLstset texCmd
highlight def link texCmdLstset texCmd
highlight def link texLstsetGroup texOpt
highlight def link texLstRegion texRegion
highlight def link texLstOpt texOpt
highlight def link texLstZone texZone
highlight def link texLstOpt texOpt
endfunction

" }}}1
2 changes: 1 addition & 1 deletion autoload/vimtex/syntax/p/luacode.vim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
function! vimtex#syntax#p#luacode#load(cfg) abort " {{{1
call vimtex#syntax#nested#include('lua')

call vimtex#syntax#core#new_region_env('texLuaRegion', 'luacode\*\?',
call vimtex#syntax#core#new_region_env('texLuaZone', 'luacode\*\?',
\ {'contains': '@vimtex_nested_lua'})

syntax match texCmdLua "\\\%(directlua\|luadirect\)\>" nextgroup=texLuaArg skipwhite skipnl
Expand Down
Loading

0 comments on commit fa2bd66

Please sign in to comment.