rust-lang / rust.vim

Vim configuration for Rust.
Apache License 2.0
3.91k stars 297 forks source link

Grammar check assumes that each line in a doc comment is a sentence. #283

Open euclio opened 5 years ago

euclio commented 5 years ago

Steps to reproduce:

Type a doc comment with multiple lines.

Expected vs. actual behavior:

Words at the beginning of a line that are part of a sentence are not highlighted.

Words at the beginning of a line are highlighted as grammar errors.

Paste debugging info from the Rust Vim plugin via one of the following commands: :RustInfo, :RustInfoToClipboard, or :RustInfoToFile <filename>.

screen shot 2018-11-27 at 5 17 22 pm

Notice that the words at the beginning of the doc comment are underlined, but the words in the regular comment at the top are not underlined.

chris-morgan commented 5 years ago

Reproduced. We’ll need to tweak 'spellcapcheck' so that it doesn’t treat the ! of //! as the end of a sentence.

chris-morgan commented 5 years ago

My attempts to fix this have failed; I believe that spellcapcheck is not just matched willy-nilly, but that it already cares about word boundaries or something in some way.

I tried adding \(//\)\@<! to the start (that is, don’t treat ! as a sentence ending if it’s prefixed by //): that failed, highlighting nothing as SpellCap, although searching for that regular expression matches just what you’d expect. Then I tried \%([^/]|^\) (non-grouping, to see if that had any effect): that failed too. Then in desperation I tried just adding . to the start: it stilled failed.

If anyone else wants to try, here’s something to get you started (because the backslashing was slightly painful to get right):

set spellcheck=[.?!]\\_[\\])'\"\    \ ]\\+

Incidentally, we’d need to be careful about setting spellcapcheck anyway, because it’s designed to be set per human language, not per code language—so we’d need to only adjust it if it hasn’t been overridden already.

I give up. Others are welcome to try.