marshallward / vim-restructuredtext

Syntax file for reStructuredText on Vim.
26 stars 12 forks source link

Spellchecking: Add test document and first enhancements #71

Closed ghost closed 2 years ago

ghost commented 3 years ago

This adds a test document for spell checking (in English).

The second commit adds some contains=@Spell to various syntax statements such that spell checking is performed.

I'm no vim guru, vim's documentation stated that syntax elements without explicit @Spell @NoSpell are treated according to spell toplevel, which should do spell checking but for me it does not... I hope, you understand Vim better and can improve this.

ghost commented 2 years ago

@marshallward Any comment on this (and the other issues/prs). The lack of spell checking is really annoying for me.

marshallward commented 2 years ago

Sorry for not replying sooner. I had not yet replied because I wanted to look into this some more. After which it fell off my list of tasks, so thank you for the reminder.

I do have spellchecking, but I also have these lines in my .vimrc:

" Do not use undercurl for spelling
hi SpellBad cterm=underline

"...

autocmd filetype rst  setlocal spell spelllang=en_us

My guess is that your proposed changes would always turn on spell checking, even without this setting. Is that right?

Are there examples of explicit spell checking in the other style sheets? I will try to have a look if I get some time.

ghost commented 2 years ago
" Do not use undercurl for spelling
hi SpellBad cterm=underline

"...

autocmd filetype rst  setlocal spell spelllang=en_us

As of now, that would only spell check the top level layer of text but not the text inside a .. note:: directive.

My guess is that your proposed changes would always turn on spell checking, even without this setting. Is that right?

Not quite. There are two layers here:

1) the "master switch", namely the 'spell' option, if not enabled nothing will be spell checked. (This should obviously be left to the user) 2) the syntax level. Since most programming languages do not produce valid sentences and variable names are often not proper English words, the syntax file can mark syntax group as "worthy" or "not worthy" to spell check. If set, only the "worthy" ones are spell checked by Vim (for a programming language usually only comments and string constants). The @Spell and @NoSpell groups tell Vim which syntax groups are "worthy" or "unworthy".

The above patch adds the syntax level indicators (and does not touch the 'spell' option).

Note: Spellchecking for reStructuredText it is essentially reversed to a programming language in the sense that everything is English text (or whatever language you use) thus should be spell checked by Vim, and only some constructs are "code" (e.g. a code block ".. code::").

Are there examples of explicit spell checking in the other style sheets? I will try to have a look if I get some time.

What do you mean by "style sheets"?

marshallward commented 2 years ago

Thanks for that explanation, that answers most of the questions that I had. Mostly I was unsure how the @Spell / @NoSpell directives worked, and why this patch was needed, and you explained it very well.

I will go ahead and merge this now.

ghost commented 2 years ago

Thank you!