Replies: 15 comments 62 replies
-
Sounds great, my only thought is that https://github.com/valentjn/ltex-ls has proven to be the ultimate spell and grammar checker, could you integrate that somehow? At the moment it needs some special features to work that are not part of the lsp spec. There is a plugin version for nvim, https://github.com/vigoux/ltex-ls.nvim that implements those features, could it be ported to Helix? |
Beta Was this translation helpful? Give feedback.
-
Using tree-sitter to determine what should be spell checked sounds like a good idea to me 👍 Spell-checking in general though is a question mark: there isn't anything built-in at the moment or a way to plug in a checker like aspell. It would probably be worth some discussion whether that even belongs in the core or as a plugin. I think it would be handy if LSP could be used to provide spell-checking capabilities. Maybe languages could inject a language like we do for tree-sitter-comment or markdown in docs and the spelling language server could act on the injected ranges (although currently injected content can't be adressed by a language server afaik). |
Beta Was this translation helpful? Give feedback.
-
Microsoft recently released a blog post on how they introduced spell checking to Visual Studio: https://devblogs.microsoft.com/visualstudio/visual-studio-spell-checker-preview-now-available/ |
Beta Was this translation helpful? Give feedback.
-
I've come around to the other side on this since my last comment ☝️: I think it's reasonable to have spell-checking as a core feature. Finding system-installed dictionaries is fairly straight-forward and fits well into Spell checking also requires some other advancements in core that we want for other features like running tree-sitter queries across language injections (like for rainbow brackets, textobjects, indents) and segmenting a whole buffer into words efficiently (useful for- but maybe different than lexical autocomplete). Specifically about spell-checking, we really only need the ability to: create an in-memory dictionary from Hunspell The existing options we have (hunspell, nuspell, enchant) are a bit annoying from a build perspective: we would need to depend on the presence of libenchant or hunspell as a library at build-time and use FFI, so spell checking as a feature would probably need to be optional. I'd really like to avoid complicating the build or increasing our dependency on C(++) codebases so as archseer mentions, I'm working on a pure-Rust spell-checker compatible with Hunspell dictionaries. I'll make the repo public and push up an integration branch once the project matures some more. |
Beta Was this translation helpful? Give feedback.
-
As #2507 has been released as part of 23.10, could / should this discussion be revisited? :) In my experience, good spellcheck also in a coding environment (not just pure markdown or text) per se is already quite useful at catching a number of "stupid" bugs :) . My questions:
|
Beta Was this translation helpful? Give feedback.
-
Nope, it does not. New words could be added to a custom dictionary file
in the project directory.
…On Fri, 2024-01-26 at 06:01 -0800, weakish wrote:
@akhilman Does diagnostic-language-server support code actions (e.g.
replace the word with suggestions, add word to dictionary, etc)?
|
Beta Was this translation helpful? Give feedback.
-
Vale now has a language server, and tree sitter based spell checking for comments in programming languages like Rust! https://github.com/errata-ai/vale/releases/tag/v3.5.0 https://github.com/errata-ai/vale-ls (needs vale installed) I have not tried it in Helix yet, but it looks like it could be perfect. |
Beta Was this translation helpful? Give feedback.
-
I got vale working in Helix. It's really good. One other one to try out is https://github.com/tekumara/typos-lsp - I was using this beforehand. It has really low false-positive rate but a higher false-negative rate due to the fact that it has a predefined list of common misspellings and only alerts on those. It's fairly comprehensive, though! |
Beta Was this translation helpful? Give feedback.
-
I'm using
and things appear to be working. |
Beta Was this translation helpful? Give feedback.
-
I do not have a My
|
Beta Was this translation helpful? Give feedback.
-
Use the configuration tool (https://vale.sh/generator) to generate your |
Beta Was this translation helpful? Give feedback.
-
One other option that was recently shared on the Helix Matrix chat is Harper. This is the best LSP solution that I've tested so far. It's very fast and can be installed using cargo. Will work for both text based documents as well as comments. Another good option until we have @the-mikedavis's solution. Configuration is in the wiki: https://github.com/helix-editor/helix/wiki/Language-Server-Configurations#harper-ls |
Beta Was this translation helpful? Give feedback.
-
Your mistake may have been trying Vale first. Vale is significantly harder to set-up than Harper. Better documentation for how to set-up a spellchecking LSP could alleviate this issue. |
Beta Was this translation helpful? Give feedback.
-
Harper also uses tree-sitter for spellchecking in code, just like Helix would. |
Beta Was this translation helpful? Give feedback.
-
For a bit of background: I've been writing a lot of documentation lately for Phoenix Live View and Helix is my daily driver 🧬 ⚗️
Would the maintainers be interested in accepting a PR to Helix core that adds a built-in spellchecker that uses tree-sitter queries to determine what parts of the document to spellcheck? For example, consider the following Elixir code:
As a user, I would like the text inside of the comment string and the
@doc
to be spellchecked against my preferred language (in this case, en-US), but not the Elixir identifiers themselves. The tree-sitter queries could look something like this:This would allow for syntax-aware spell checking for each language and would be customizable for each user. Typos could be represented as diagnostics, possibly even with a list of close matches to a known dictionary?
See https://github.com/lewis6991/spellsitter.nvim for an example of what I am thinking of 🙂
Beta Was this translation helpful? Give feedback.
All reactions