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

Expanding ToC syntax for sections #2221

Closed
yongrenjie opened this issue Oct 25, 2021 · 1 comment
Closed

Expanding ToC syntax for sections #2221

yongrenjie opened this issue Oct 25, 2021 · 1 comment

Comments

@yongrenjie
Copy link
Contributor

yongrenjie commented Oct 25, 2021

Is your feature request related to a problem? Please describe it.

In the ToC, chapter/section labels like chap:foo or sec:bar get special syntax highlighting as defined in autoload/vimtex/toc.vim

syntax match VimtexTocLabelsSecs /\v(chap|sec):.*$/ contained
syntax match VimtexTocLabelsEq /eq:.*$/ contained
syntax match VimtexTocLabelsFig /fig:.*$/ contained
syntax match VimtexTocLabelsTab /tab:.*$/ contained

It might be nice to be able to configure this, e.g. for subsections subsec:baz, or or if someone wanted to use a different abbreviation, say \label{chpt:foo} (I'm not sure whether there's an 'official' guide on what abbreviations to use, or whether it's just a convention 😄). Basically, something like g:vimtex_toc_todo_labels but for sections instead of todos. (probably simpler than the todo labels, actually)

Right now subsections especially tend to get a little bit messed up because the syntax matches the second half of subsec:baz, e.g.

Screenshot 2021-10-25 at 9 55 52 PM

lervag added a commit that referenced this issue Oct 26, 2021
@lervag
Copy link
Owner

lervag commented Oct 26, 2021

It might be nice to be able to configure this, e.g. for subsections subsec:baz, or or if someone wanted to use a different abbreviation, say \label{chpt:foo}

Thanks, I agree that subsec: should also be highlighted and that should be fixed now. But I'm not 100% sure if we need any additional configuration possibilities here. If you want to, you can add your own rules, e.g. like this:

augroup vimtex_toc
  autocmd!
  autocmd User VimtexEventTocCreated call MyTocSyntax()
augroup END

function! MyTocSyntax() abort
  syntax match VimtexTocLabelsSecs  /chpt:.*$/ contained
endfunction

(I'm not sure whether there's an 'official' guide on what abbreviations to use, or whether it's just a convention smile).

I believe this is just a convention, and I am not aware of any official guide.

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

No branches or pull requests

2 participants