-
Notifications
You must be signed in to change notification settings - Fork 395
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
Latex-style highlighting and editing in .bib file #2301
Comments
Reg. highlighting: This is not trivial, but I'll look into it. There may be some possibilities here, and if I can find a simple and elegant way I'll add it. Reg. F7: this is harder, but I'll try. But I do not want to make it "context sensitive", in the sense that |
Wow, I didn't expect highlighting to be difficult, and By "everywhere", do you mean it would work for not just for |
I think
No problem. Improved syntax highlighting seems useful, and
The latter - everywhere inside the |
Now |
With the caveat that I've never done any Vim programming and may be grossly oversimplifying here, can't the syntax regions be everywhere inside two curly brackets
|
No, it is not that simple. First, we need to ignore the outer Finally, and "worse": VimTeX does not provide a syntax script for bib files. So if I were to fix this, I would either have to include a syntax script and modify it, or I would need to override the built-in script. Further, a lot of users are now using Neovim with Tree-sitter, and adding this support would add to the existing confusion between syntax scripts. I'm actually not sure if it is worth it. I'll make a proof of concept and consider it afterwards.
If I do this, it will be much easier to do it with syntax nesting. And that will give a much better result as well. The "simple" way is not less complicated here, actually. |
I've given this some more thought. I thinkg I would either have to fully adopt bibtex syntax into VimTeX or do nothing. Considering that bibtex syntax is now supported by Tree-sitter and that the potential gains are not so very high, I believe the best strategy here is to leave this as it is. However, if you really want this, you could "make your own". Create if !get(b:, "current_syntax", '') ==# 'bib' | finish | endif
if exists("b:loaded_bib_vimtex_syntax") | finish | endif
let b:loaded_bib_vimtex_syntax = 1
unlet b:current_syntax
syntax include @vimtex_nested_tex syntax/tex.vim
let b:current_syntax = 'bib'
syntax cluster vimtex_nested_tex remove=texGroup,texGroupError
syntax cluster bibVarContents add=@vimtex_nested_tex I've tested it and it seems to work as expected. |
Is your feature request related to a problem? Please describe it.
Currently, there is no latex-style highlighting inside an entry field of a
.bib
file and<F7>
doesn't insert a command the way it does for a.tex
file.Describe the solution you'd like
Both of these would be useful for as non-trivial Latex editing is sometimes required.
It may not be necessary to render, say, the content of
\emph
as emphasized, nor to highlight~
,--
, etc (though I think that would be nice) but it would be very helpful to highlight every command at least, as would the<F7>
insertion, especially in the visual mode.Examples from Biblatex developers and a TeX thread
The text was updated successfully, but these errors were encountered: