Open GilShoshan94 opened 1 year ago
Almost every IDE has a built-in spell checker.
For example, for VSCode: https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker
It does the job really well and I use it in every single project.
@raphaelricardo10
That's not the same, the spell checker that you linked is a "simple" checker. Yes it has some feature that makes it works nicely with code such as knowing how to parse CamelCase or sneak-case but it has no knowledge over the code as does an LSP such as rust-analyzer.
Also performance wise it is slower then one integrated inside r-a that would know what to check only.
I invite you to read the discussion https://github.com/rust-lang/rust-analyzer/discussions/14389 if you are curious about the benefits to spell check in the LSP.
I don't know how relevant this is but on neovim people usually rely on Tree-sitter to identify code sections where spell checking should be enabled (comments, docstrings, etc.). Personally I'm not sure I want to rely on an LSP to spell check because 1/ they are way slower than Tree-sitter (it is nice to be able to spellcheck even if the LSP is not completely initialized, especially if you open a file only to add some doc), and 2/ Tree-sitter is an incremental parser, which means it can be used to identify spellcheck regions accurately even if your code doesn't compile.
Let's take the following example:
fn main() {
some_func(
arg1,
arg2, // I want the spelcheker to be working even if I'm not done with the code yet
}
Would rust-analyzer still be able to pick up the fact that this is a comment where spellchecking should be enabled ? Even if the code is not valid yet ? This is probably a bad example, but you get my point
(fun fact: GitHub uses Tree-sitter to highlight the Rust code above)
@ShellCode33 while probably not as fast as tree-sitter, rust-analyzer does support incremental parsing and has a real understanding of the code, unlike the TextMate grammars you might have encountered before.
If you give it a try, you'll find out that it does supports incomplete code like the one you've shown. So yes, it knows where the comments are.
Discussed in https://github.com/rust-lang/rust-analyzer/discussions/14389
Quoted from https://github.com/rust-lang/rust-analyzer/discussions/14389#discussioncomment-5466129