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

Feature: Add g:vimtex_syntax_custom_envs #2756

Merged
merged 3 commits into from
Jul 16, 2023
Merged

Conversation

lervag
Copy link
Owner

@lervag lervag commented Jul 12, 2023

This should resolve #2745.

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
doc/vimtex.txt Outdated Show resolved Hide resolved
@GergelyKalmar
Copy link

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
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

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
2 checks passed
@lervag lervag deleted the feat/syntax-custom-envs branch July 16, 2023 20:23
@lervag
Copy link
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

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

@lervag
Copy link
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