vim / colorschemes

colorschemes for Vim
279 stars 23 forks source link

Add String and Comment highlight groups to sample_spell.vim #154

Closed gdupras closed 2 years ago

gdupras commented 2 years ago

Spell checking if often done on text with Comment or String highlighting. Add these groups to sample_spell.vim.

I had to make some small changes to the "usage" line to make this work. I'm not entirely sure if it was necessary. Feedback welcome.

gdupras commented 2 years ago

Example with blue.vim with gVim on Windows 10:

sample_spell

romainl commented 2 years ago

Thank you, the "usage" change seems harmless but could you try it with the other samples? I would prefer to have a single pattern for all.

gdupras commented 2 years ago

Maybe I should explain why I changed the example usage. These notes might be more for myself than for you.

Originally, the usage was

$ vim -Nu NONE -S colors/tools/sample_spell.vim +source\ colors/blue.vim

The issue with this is that the hi clear line in colorscheme files removes the highlight groups sampleString and sampleComment I added in sample_spell.vim. :help highlight-clear says "Reset all highlighting to the defaults. Removes all highlighting from groups added by the user!".

To prevent this, I sourced the colorscheme first (and used -S instead of +, but that's just a personal preference), like this:

$ vim -Nu NONE -S colors/blue.vim -S colors/tools/sample_spell.vim

Now the issue is that sample_spell.vim contained syntax on. From :help syntax_cmd: "Highlight colors are overruled but links are kept". So I had to remove that line.

I then tried the other sample_*.vim scripts with this new "usage" and syntax on removed. I noticed that some of them do need syntax on to look right (e.g. sample_diff.vim). This is where --clean is useful. With this flag, $VIMRUNTIME/defaults.vim is source first and it contains syntax on. While we are at it, we can also remove set nocompatible from sample_*.vim since --clean already does this.

To recap, the usage should be

$ vim --clean -S colors/blue.vim -S colors/tools/sample_spell.vim

and syntax on and set nocompatible should be removed from sample_*.vim. I can make these changes in an other pull request if you want.

With these changes, the samples look as before with the added benefit that we can now add custom highlight rules like I did in sample_spell.vim.

Note that some of the sample_*.vim did not have syntax on and as a result some of the highlighting was missing. For instance, the URLs in sample_popupmenu.vim were not hightlighted before.

Also, there are sometimes some very small differences with --clean due to some settings likes

set display=truncate
set scrolloff=5

in defaults.vim but I think this doesn't really matter.