Closed luochen1990 closed 5 years ago
I think a stopgap solution that's at least easily changeable is to do one of 2 things:
g:rainbow_experimental_spellcheck
to emphasize that it doesn't always work.Neither of these fixes the problem totally, but for most common use cases (developing in the most popular languages), this should be ok since I imagine the more popular languages have better syntax files.
@alok Actually you can config this via defining your own parentheses, we don't need to add an option to make it configurable.
I just recently find out this issue and it is actually a bit annoying. For my case I only want to turn on spell checking for comment which is actually working by default in neovim. However, using rainbow will somehow turn on spell checking everywhere.
I also don't think people want spell checking for there code in general. Is this task a rather simple one so that we can wrap it up?
@jethrosun the problem is, there are so many languages, and we need to offer a configurable option for this plugin's users to make them have a consistent experience, this is very hard and I cannot find a good solution yet.
I pushed a new PR #119 and it supports a new option named parentheses_options
, and you can add contains=@NoSpell
or contains=Spell
by yourself for specified filetypes now.
following is an example for .vim
files:
let g:rainbow_conf = {
\ 'separately': {
\ 'vim': {
\ 'parentheses_options': 'containedin=vimFuncBody contains=@NoSpell',
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold'],
\ },
\ }
\}
I will merge this develop
branch into master
if it is confirmed works well.
Thank you for this new feature.
I assume this let us enable or disable spell checking by hand so the default code-aware spell checking feature is not supported any more, right?
@jethrosun I think providing an option for users maybe the most practical solution at the moment. Maybe we can do better when we find a new solution.
Now people can use 'parentheses_options': 'contains=@Spell'
or 'parentheses_options': 'contains=@NoSpell'
to solve this problem themself. This issue is closed for now.
@luochen1990 - I'm not sure what I'm doing wrong, but when I add:
let g:rainbow_conf = {
\ 'parentheses_options': 'contains=@NoSpell',
\}
This removes most syntax highlighting in parentheses in most file types. The same happens with Spell
instead of NoSpell
. What am I missing?
My fault, parentheses_options
is supposed to be used separately for each filetype (the global one may be covered by the default config of each filetype), and the default value of contains
is TOP
, so if you want to add an item into it, you should set it to TOP,@NoSpell
.
let g:rainbow_conf = {
\ 'separately': {
\ '*': {},
\ 'markdown': {
\ 'parentheses_options': 'contains=TOP,@NoSpell',
\ },
\ },
\}
@luochen1990 - great, thanks! That fixed it.
@boris-petrov I think update contains
via append mode instead of write mode is more natural. I will fix it so you can config it the way you want.
@luochen1990 - works like a charm, thanks!
As you know, the spell checking issue of this plugin have been there for years. Following is the change history about spell checking:
none
->@Spell
, #22 , 6bbf980@Spell
->@NoSpell
, #24 , 9a609c6@NoSpell
->none
, #30 , 785f997According to
:h :syn-spell
, if you add@Spell
syntax rule, then for some filetypes which has no@Spell
in the default syntax files, this will stop the default spell checking behavior.And if you check the default syntax files, you can find out that only a few filetypes' specified
syn spell
explicitly.And there is only 171 filetypes among 590 which you can add syntax rules with
contains=@Spell
safely (without changesyn spell default
's behavior fromtoplevel
tonotoplevel
):And according to
:h spell-syntax
:I tidied the following table:
@Spell
region@NoSpell
regionThe spell checking rule for default region (non-toplevel text which is matched by some syntax rules) is not much clear, literally, it seem to be "Spell Check" on both situation.
An ideal design for rainbow (this plugin) is to make the parentheses region works the same as the toplevel text, so that it will keep the same behavior when people toggle rainbow on/off (this is still not true if the original syntax files defined some parentheses, in this situation, we need to keep the
@Spell
flag same with the original parentheses syntax rule). But it seems that there is no easy way to make it works for every case (every filetypes and 3-party-syntax- plugins).If we want to solve the spell checking problem without some magic, we need to deal with each file types one by one, and all the 3-party-syntax-plugins have to be compatible with rainbow by themselves.
I'd appreciate it if you can provide any better idea, feel free to comment :)