Skip to content

Commit

Permalink
Added in_sage command and removed texSagetexArg from mathzone
Browse files Browse the repository at this point in the history
  • Loading branch information
shivangp76 committed Apr 19, 2024
1 parent e6e4d55 commit 9f4be32
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions autoload/vimtex/syntax.vim
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@ function! vimtex#syntax#in_comment(...) abort " {{{1
return call('vimtex#syntax#in', ['texComment'] + a:000)
endfunction

" }}}1
function! vimtex#syntax#in_sage(...) abort " {{{1
return call('vimtex#syntax#in', ['texSagetexArg'] + a:000) || call('vimtex#syntax#in', ['texSagetexZone'] + a:000)
endfunction

" }}}1
function! vimtex#syntax#in_mathzone(...) abort " {{{1
" The following checks if we are inside a texMathZone environment. The
" arguments to \label{...}, the texRefArg group, and \text{...} like
" commands, the texMathTextArg group, are actively ignored as these should
" not be considered to be math environments.
" arguments to \label{...}, the texRefArg group, the texSagetexArg group,
" and \text{...} like commands, the texMathTextArg group, are actively
" ignored as these should not be considered to be math environments.
let l:groups = reverse(call('vimtex#syntax#stack', a:000))
let l:group = matchstr(l:groups, '\v^tex%(Math%(Zone|Text|Tag)|RefArg|SagetexArg)')
return l:group =~# '^texMathZone'
Expand Down
4 changes: 2 additions & 2 deletions autoload/vimtex/syntax/p/sagetex.vim
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
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

Expand Down Expand Up @@ -36,6 +34,8 @@ function! vimtex#syntax#p#sagetex#load(cfg) abort " {{{1
\ 'sage',
\ 'sagestr'
\]
execute 'syntax match texCmdSagetex /\\' . l:env .
\ '\>/ nextgroup=texSagetexArg skipwhite skipnl'
call vimtex#syntax#core#new_cmd({
\ 'name': l:env,
\ 'mathmode': 1,
Expand Down

0 comments on commit 9f4be32

Please sign in to comment.