Skip to content

Commit

Permalink
fix(syntax): improve bad \hyperref highlight
Browse files Browse the repository at this point in the history
refer: #3103
  • Loading branch information
lervag committed Feb 24, 2025
1 parent 63ae2e9 commit 096a045
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions autoload/vimtex/syntax/p/hyperref.vim
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ function! vimtex#syntax#p#hyperref#load(cfg) abort " {{{1

syntax match texCmdHyperref '\\autoref\>'
\ skipwhite nextgroup=texRefOpt,texRefArg

syntax match texCmdHyperref '\\hyperref\>'
\ skipwhite nextgroup=texRefOpt,texRefArg
\ skipwhite nextgroup=texHyperrefLink,texHyperrefText
call vimtex#syntax#core#new_opt('texHyperrefLink', {'next': 'texHyperrefText'})
call vimtex#syntax#core#new_arg('texHyperrefText')

syntax match texCmdHyperref "\\url\>"
\ skipwhite nextgroup=texUrlArg
call vimtex#syntax#core#new_arg('texUrlArg', {'contains': '@NoSpell'})

if a:cfg.conceal
syntax match texCmdHyperref '\\href\>'
\ skipwhite nextgroup=texHrefArgLink
\ skipwhite nextgroup=texHrefArgLinkC
\ conceal
call vimtex#syntax#core#new_arg('texHrefArgLink', {
call vimtex#syntax#core#new_arg('texHrefArgLinkC', {
\ 'opts': 'contained conceal',
\ 'next': 'texHrefArgTextC',
\ 'contains': 'texHrefLinkGroup,@NoSpell',
Expand Down Expand Up @@ -70,8 +73,12 @@ function! vimtex#syntax#p#hyperref#load(cfg) abort " {{{1
endif

highlight def link texCmdHyperref texCmd
highlight def link texHyperrefLink texOpt
highlight def link texHyperrefText texArg
highlight def link texHrefArgLink texOpt
highlight def link texHrefArgTextC texArg
highlight def link texHrefArgLinkC texHrefArgLink
highlight def link texHrefArgText texArg
highlight def link texHrefArgTextC texHrefArgText
highlight def link texHrefLinkGroup texHrefArgLink
highlight def link texUrlArg texOpt
highlight def link texTOPSArgPdf texOpt
Expand Down

0 comments on commit 096a045

Please sign in to comment.