Skip to content

Feature: Add g:vimtex_syntax_custom_envs#2756

Merged
lervag merged 3 commits intomasterfrom
feat/syntax-custom-envs
Jul 16, 2023
Merged

Feature: Add g:vimtex_syntax_custom_envs#2756
lervag merged 3 commits intomasterfrom
feat/syntax-custom-envs

Conversation

@lervag
Copy link
Copy Markdown
Owner

@lervag lervag commented Jul 12, 2023

This should resolve #2745.

lervag added 2 commits July 12, 2023 23:05
Combine these into syntax#core#new_env and add option 'nested' to
specify nested syntax regions. This allows some simplification and
general improvements.
Adds a new option g:vimtex_syntax_custom_envs that allows to define
syntax rules for custom environments in the same spirit as the
corresponding g:vimtex_syntax_custom_cmds.

refer: #2745
@GergelyKalmar
Copy link
Copy Markdown

I'm seeing the following error when switching to this branch:

Error detected while processing function vimtex#syntax#core#init_post[12]..vimtex#syntax#packages#init[20]..vimtex#syntax#core#init_custom[12]..vimtex#syntax#core#new_env[19]..vimtex#s
yntax#core#new_env:
line   70:
E399: Not enough arguments: syntax region start="\\begin{\z(code\)}\s*\[\_[^\]]\{-}language=python\_[^\]]\{-}\]" end="\\end{\z1}" contains=texCmdEnv,@vimtex_nested_python keepend

Config:

let g:vimtex_syntax_custom_envs = [{
      \ 'name': 'code', 'nested': {
      \   'python': 'language=python',
      \ }}]

@lervag
Copy link
Copy Markdown
Owner Author

lervag commented Jul 16, 2023

Thanks, I fixed both of those now. Note, though, that the latter issue is really due to you forgetting to pass the region key. But I realize that VimTeX can just forgive that and create a region name based on the "name" key.

@GergelyKalmar
Copy link
Copy Markdown

Ah, I see! I think creating the region name is perhaps even better. It works perfectly fine now! Perhaps the region argument can be marked now optional in the documentation?

lervag added a commit that referenced this pull request Jul 16, 2023
@lervag lervag merged commit 6c5932a into master Jul 16, 2023
@lervag lervag deleted the feat/syntax-custom-envs branch July 16, 2023 20:23
@lervag
Copy link
Copy Markdown
Owner Author

lervag commented Jul 16, 2023

Thanks; I've made a minor adjustment to the docs regarding the region name. And I merged this, since it seems good enough for now :)

@GergelyKalmar
Copy link
Copy Markdown

Awesome, thank you very much for the feature! Works perfectly fine.

@lervag
Copy link
Copy Markdown
Owner Author

lervag commented Jul 17, 2023

Glad to hear it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide a way to add/identify custom listings environments

2 participants