Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete syntax support for SageTeX #2929

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 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 All @@ -18,20 +16,36 @@ function! vimtex#syntax#p#sagetex#load(cfg) abort " {{{1
\})
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

" Note: The following commands are supported both inside and outside 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

call vimtex#syntax#add_to_mathzone_ignore('texSagetexArg')

highlight def link texCmdSagetex texCmd
endfunction

Expand Down
Loading