New feature: documentation window highlighting
In the new branch test_highlighting is available a feature I had wanted to implement for some time. Basically, it highlights the bibliographic keys in the documentation windows:
I haven't written the documentation yet. This is the relevant part of the configuration:
local defaults = {
additional_information = {
bib_highlighting = true,
highlight_colors = {
default_group = "Normal", -- Highlight group for most of the keys (in my config it's the yellow part)
important_group = "IncSearch", -- Highlight group to distinguish the most important keys
default = { -- Eventually, color codes can be specified
fg = "",
bg = "",
},
important = {
fg = "",
bg = "",
},
},
highlight_links = { -- This sets, for each key, if "Default" or "Important" is used.
-- Normal highlight groups can be used too.
-- Bibtex
Address = "Default",
Annote = "Default",
Author = "Important",
Booktitle = "Default",
Email = "Default",
Chapter = "Default",
Crossref = "Default",
Doi = "Default",
Edition = "Default",
Editor = "Default",
Howpublished = "Default",
Institution = "Default",
Journal = "Default",
Key = "Default",
Month = "Default",
Note = "Default",
Number = "Default",
Organization = "Default",
Pages = "Default",
Publisher = "Default",
School = "Default",
Series = "Default",
Title = "Important",
Type = "Default",
Volume = "Default",
Year = "Default",
-- Biblatex
Isbn = "Default",
-- cmp-vimtex-specific keys
File = "Default",
Lnum = "Default",
Cite = "Default",
},
},
}
This may interest @lervag and @benbrastmckie.
Good idea; although I don't really like the default groups here. I would choose groups that don't set the background colors by default. In particular, I would choose one of the groups from :help group-names, perhaps PreProc or Define for the default group and Special for the important group.
Also, I would actually rather prefer to keep the keys more neutral and perhaps instead highlight the values differently. That is, have something like this:
local defaults = {
additional_information = {
highlight_colors = {
key_group = "PreProc",
value_group = "String",
important_value_group = "Identifier",
},
The syntax matching will be somewhat more complex, but I don't think it will be very hard.
Do you think that the ability to set guifg and guibg with the actual color codes should be removed? I almost feel that it may be excessive for this plugin (i.e., that the user should simply be able to specify a group).
Good question. My intuition is the same as you, that the user should instead learn to specify their own highlight groups directly.
I've been trying to write functioning syntax rules to highlight a row of the following kind:
TITLE: some_text
I've tried, without success:
syntax keyword CmpVimtexTitle TITLE
syntax match CmpVimtexTitleBody "TITLE: .*$"ms=s+7
But it doesn't work: it matches only TITLE, even though I've put the match offset in the second command.
I would try something like this:
syntax match CmpVimtexTitle "^TITLE:\s*"
\ nextgroup=CmpVimtexTitleBody
\ contains=CmpVimtexColon
syntax match CmpVimtexTitleBody ".*" contained
syntax match CmpVimtexColon ":" contained
I've added a match for the colon, as I think it makes sense to highlight it differently. This idea should work for everything that is a single line. If you need for the body to match multiple lines you need to do something more advanced here.
Ok, I've updated it. I'll write the documentation when I can, and then merge with master if everything's fine.
Thanks for the help, as usual!
Glad to help :)
On a sidenote, would you mind if I asked you to post about the plugin in the main subreddits? I'd like to get as many users on board as possible to start troubleshooting eventual bugs, and receive suggestions for new features. I've seen that the (Neo)vim and Latex communities are pretty big, but I don't really use it.
I can make a post on r/neovim; I don't think it makes sense to post on r/vim as nvim-cmp does not work there.
Edit: Here it is: https://www.reddit.com/r/neovim/comments/1b5l5cm/cmpvimtex_a_vimtex_source_for_nvimcmp/
Thanks!