Closed pwnalone closed 5 months ago
very nice PR
I'll merge and make a new release sometime today
I removed the autocommand that sets the highlights on the ColorScheme
Good
The author of the previous highlighting code said they were experiencing issues where some colorschemes clear the highlight
I do too (on Lunarvim), but I was unable to determine what happens: currently no highlight gets applied on my config anyway (so I tested your changes on an default nvim config).
I can 'fix' that by calling setup_highlight()
each time a snippet is run, which I'll probably do for v1.3.12, even if it's a bit heavy-handed
Description
This PR is related to #278.
Currently, it's not possible to set certain highlight attributes for Sniprun's highlight groups. This is because the code is manually constructing VimScript commands, which it then wraps in calls to
vim.cmd()
, and it only considers a few attributes.This PR updates the code to use Neovim's
nvim_set_hl()
API function, which handles all attributes.Backward compatibility
This update should be mostly backward compatible with the previous way of setting highlights; however, there are some differences to be aware of.
:highlight
command updates the highlight group if already set, whereasnvim_set_hl()
completely replaces the definition.:highlight
command accepts analtfont
attribute for GUIs, andnvim_set_hl()
does not.See below for documentation on the attributes/options accepted by these two commands.
VimScript
:highlight
attributesLua
nvim_set_hl()
optionsNotes
I removed the autocommand that sets the highlights on the
ColorScheme
event, since it appears to be unnecessary. The author of the previous highlighting code said they were experiencing issues where some colorschemes clear the highlight groups, causing the defaults to be lost (see here), but I tested this with multiple colorschemes and did not experience this issue myself.As mentioned here, Sniprun's author wants the highlight groups to be defined in this order of priority:
This PR maintains this priority.