Skip to content

Commit

Permalink
merge(syntax): improve sagetex support
Browse files Browse the repository at this point in the history
refer: #2929
  • Loading branch information
lervag committed Apr 21, 2024
2 parents 268dd8d + ab29c67 commit fa7dcd4
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions autoload/vimtex/syntax/p/sagetex.vim
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,41 @@
function! vimtex#syntax#p#sagetex#load(cfg) abort " {{{1
call vimtex#syntax#nested#include('python')

syntax match texCmdSagetex /\\sagestr\>/
\ nextgroup=texSagetexArg skipwhite skipnl
syntax match texCmdSagetex /\\sageplot\>/
\ nextgroup=texSagetexOpt,texSagetexArg skipwhite skipnl

call vimtex#syntax#core#new_arg('texSagetexArg', {
\ 'contains': '@vimtex_nested_python',
\ 'opts': 'contained keepend'
\})
call vimtex#syntax#add_to_mathzone_ignore('texSagetexArg')
call vimtex#syntax#core#new_opt('texSagetexOpt', {'next': 'texSagetexArg'})

for l:env in [
for l:env_name in [
\ 'sageblock',
\ 'sagesilent',
\ 'sageverbatim',
\ 'sageexample',
\ 'sagecommandline'
\]
call vimtex#syntax#core#new_env({
\ 'name': l:env,
\ 'name': l:env_name,
\ 'region': 'texSagetexZone',
\ 'contains': '@vimtex_nested_python'
\})
endfor

" The following commands are supported inside and outside of math zones
for l:cmd_name in ['sage', 'sagestr']
for l:in_mathmode in [v:true, v:false]
call vimtex#syntax#core#new_cmd({
\ 'name': l:cmd_name,
\ 'mathmode': l:in_mathmode,
\ 'nextgroup': 'texSagetexArg'
\})
endfor
endfor

highlight def link texCmdSagetex texCmd
endfunction

Expand Down

0 comments on commit fa7dcd4

Please sign in to comment.