Skip to content

Commit

Permalink
feat(syntax): improve glossaries support
Browse files Browse the repository at this point in the history
refer: #3073
  • Loading branch information
lervag committed Mar 1, 2025
1 parent a92f599 commit 31250a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion autoload/vimtex/syntax/p/glossaries.vim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
scriptencoding utf-8

function! vimtex#syntax#p#glossaries#load(cfg) abort " {{{1
syntax match texCmd nextgroup=texGlsArg skipwhite skipnl "\\gls\>"
syntax match texCmdGls "\v\c\\gls%(desc|link)?>"
\ nextgroup=texGlsArg skipwhite skipnl
call vimtex#syntax#core#new_arg('texGlsArg', {'contains': '@NoSpell'})

" \newacronym -> opt -> arg1 -> arg2 -> arg3
Expand All @@ -34,6 +35,8 @@ function! vimtex#syntax#p#glossaries#load(cfg) abort " {{{1
\ nextgroup=texAcrArgLabel skipwhite skipnl
call vimtex#syntax#core#new_arg('texAcrArgLabel', {'contains': '@NoSpell'})

highlight def link texCmdGls texCmd
highlight def link texGlsArg texRefArg
highlight def link texCmdAcr texCmd
highlight def link texCmdNewAcr texCmdNew
highlight def link texNewAcrOpt texOpt
Expand Down
5 changes: 5 additions & 0 deletions test/test-syntax/test-glossaries.tex
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@
\Acrfull{rl} is a fun subfield of \acrlong{ml}. \acrshort{ml} is fun.
\printnoidxglossary[type=acronym]

\gls{sym.electron_charge}
\Gls{sym.electron_charge}
\glsdesc{sym.electron_charge}
\glslink{sym.electron_charge}

\end{document}

0 comments on commit 31250a8

Please sign in to comment.