Skip to content

Commit

Permalink
feat(syntax): match item label
Browse files Browse the repository at this point in the history
refer: #2885
  • Loading branch information
lervag committed Feb 22, 2024
1 parent f9161b4 commit 01c4c16
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
13 changes: 11 additions & 2 deletions autoload/vimtex/syntax/core.vim
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ function! vimtex#syntax#core#init_rules() abort " {{{1
call vimtex#syntax#core#new_arg('texPartArgTitle')

" Item elements in lists
syntax match texCmdItem "\\item\>"
syntax match texCmdItem "\\item\>" nextgroup=texItemLabel
call vimtex#syntax#core#new_opt('texItemLabel')

" \begin \end environments
syntax match texCmdEnv "\v\\%(begin|end)>" nextgroup=texEnvArgName
Expand Down Expand Up @@ -860,6 +861,8 @@ function! vimtex#syntax#core#init_highlights() abort " {{{1
highlight def link texFilesArg texFileArg
highlight def link texFilesOpt texFileOpt
highlight def link texGroupError texError
highlight def link texItemLabel texOpt
highlight def link texItemLabelConcealed texItemLabel
highlight def link texLetArgEqual texSymbol
highlight def link texLetArgName texArgNew
highlight def link texLigature texSymbol
Expand Down Expand Up @@ -2186,8 +2189,14 @@ function! s:match_conceal_fancy() abort " {{{1
syntax match texCmd '\\dots\>' conceal cchar=
syntax match texCmd '\\slash\>' conceal cchar=/
syntax match texCmd '\\ldots\>' conceal cchar=
syntax match texCmdItem '\\item\>' conceal cchar=
syntax match texTabularChar '\\\\' conceal cchar=

syntax match texCmdItem '\\item\>' conceal cchar=
\ nextgroup=texItemLabelConcealed
syntax match texItemLabelConcealed "\s*\[[^]]*\]"
\ contained contains=texItemLabelDelim
syntax match texItemLabelDelim "\]" contained conceal
syntax match texItemLabelDelim "\s*\[" contained conceal cchar=
endfunction

" }}}1
Expand Down
5 changes: 5 additions & 0 deletions test/test-syntax/test-conceal.tex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

\begin{document}

\begin{description}
\item[testing] This is an item
\item [tested] This is another item
\end{description}

$\binom{a}{b}$

$a_1$
Expand Down

0 comments on commit 01c4c16

Please sign in to comment.