Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(syntax): \lstset syntax highlighting #2001

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions autoload/vimtex/syntax/p/listings.vim
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ function! vimtex#syntax#p#listings#load(cfg) abort " {{{1

" Match \lstset
syntax match texCmdLstset "\\lstset\>"
\ nextgroup=texLstsetArg,texLstsetGroup skipwhite skipnl
call vimtex#syntax#core#new_arg('texLstsetGroup', {
\ 'contains': 'texComment,texLength,texOptSep,texOptEqual'
\ nextgroup=texLstsetArg,texLstsetArg skipwhite skipnl
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for duplicate texLstsetArg. :)

call vimtex#syntax#core#new_arg('texLstsetArg', {
\ 'contains': 'texCmdSize,texCmdStyle,@texClusterOpt'
\})

" Match unspecified lstlisting environment
Expand Down Expand Up @@ -51,7 +51,7 @@ function! vimtex#syntax#p#listings#load(cfg) abort " {{{1
execute 'syntax match texLstsetArg'
\ '"\c{\_[^}]*language=' . l:nested . '\%(\s*,\|}\)"'
\ 'nextgroup=' . l:grp 'skipwhite skipnl'
\ 'contains=texLstsetGroup'
\ 'contains=texLstsetArg'

call vimtex#syntax#core#new_region_env(l:grp, 'lstlisting', {
\ 'contains': 'texLstEnvBgn,' . l:cluster,
Expand Down Expand Up @@ -91,7 +91,7 @@ function! vimtex#syntax#p#listings#load(cfg) abort " {{{1
highlight def link texLstOpt texOpt
highlight def link texLstZone texZone
highlight def link texLstZoneInline texVerbZoneInline
highlight def link texLstsetGroup texOpt
highlight def link texLstsetArg texOpt
endfunction

" }}}1
6 changes: 6 additions & 0 deletions test/test-syntax/test-listings.tex
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,10 @@

\lstset{language=x,numbers=none}

\lstset{
language=C,
basicstyle=\color[RGB]{0,0,0},
numberstyle=\small
}

\end{document}
7 changes: 5 additions & 2 deletions test/test-syntax/test-listings.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ call vimtex#test#assert(vimtex#syntax#in('texLstZoneInline', 9, 14))
call vimtex#test#assert(vimtex#syntax#in('texLstZone', 15, 1))
call vimtex#test#assert(vimtex#syntax#in('texLstZoneC', 23, 1))
call vimtex#test#assert(vimtex#syntax#in('texLstZonePython', 30, 1))
call vimtex#test#assert(vimtex#syntax#in('texLstZoneRust', 36, 1))
call vimtex#test#assert(vimtex#syntax#in('texLstZoneRust', 37, 1))

call vimtex#test#assert(vimtex#syntax#in('texLstsetGroup', 42, 10))
call vimtex#test#assert(vimtex#syntax#in('texLstsetArg', 42, 10))

call vimtex#test#assert(vimtex#syntax#in('texCmd', 46, 20))
call vimtex#test#assert(vimtex#syntax#in('texCmdSize', 47, 20))

quit!