-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spellchecking integration #11660
Comments
Not that I'm against this idea at all - I'm really happy that we're considering adding spell checking as a first class feature - but what would be the advantage of using an integrated spell checker over an LSP-based solution? I've been using vale now for a while and (aside from the fact that it doesn't allow you to add to local dictionaries) it's pretty darn good. I am similarily enthusiastic about Harper, but it appears to have some different limitations. Will there be plans for grammar checking as well? |
You would be able to leverage tree-sitter for spell checking in programming languages. |
What about natural languages (markdown / text / LaTeX?) |
It should work as normal with LSPs now. |
Then I guess I'm not seeing as much of an advantage if I have to use an LSP in any case to get grammar checking. Most grammar checkers (vale, harper) do spell checking as well.... |
Yeah, it's most beneficial for programming languages. |
Looking forward to this. I have used CSpell in the past so having a different strategy/config for code and prose sounds like a good idea and is a limitation of the lsp alternatives. |
Yeah helix having a universally parser/sytanx tree woth tree sitter that we can use for spellchecker is something an LSP can't really match. Spellchecking is also a fairly basic/common feature that is nice to have on core withlut having to use/setup a third party LSP. |
Vale and Harper can already spellcheck comments in code. |
I have concerns this feature will not age well and will eventually become a "thing new users should turn off and replace". Linting natural language is incredibly complicated, and even the best solutions today are far from ideal. I think spelling and grammar checking should be left to integration with external tools, not a part of Helix itself. P.S. When I first switched from Vim to Helix, I wanted integrated spellchecking. Now that I have experience with the superior quality of language-server-based spellchecking, I never want to go back to a simple dictionary-check. |
Nothing's stopping you from continuing to use something else via LSP if you choose. You shouldn't need a language server installed for basic spellchecking (word checking, not grammar) though. In any case this issue is about the technical aspects of integration. Discussion on the concept of integrating spellchecking is in #3637 |
I'm a relatively new user to Helix - so take that as the important context in this statement. I spent a non-trivial bit of time setting up LSP's (in my case Vale) just so that I could get spell-checking in Markdown docs. I get the concerns about the feature potentially not aging well. I think the simple solution to that (similar to what vim/nvim does) is to allow the built-in spell-checker to be turned off if needed. For me - having a built-in spellchecker would have been a productivity/usability boost as a new user (a user who also sucks at spelling occasionally) (also just realized this comment was probably off-topic per @the-mikedavis above - my apologies) |
I am unconvinced by With helix we are in a position where we do have a universal parser for every language and that means we can enable a much more reliable spellchecker. This is something that is impractical (and inefficient) for a LS to replicate. |
@jsco2t I responded to you on the discussion thread: #3637 (comment). @pascalkuthe I responded to you on the discussion thread: #3637 (comment). |
I wanted to try it but there is a private dependency in it:
|
Yeah that commit is on my driver branch which has a bunch of other changes. I pushed up another branch off of master: commit. You'll need a dictionary downloaded into |
@the-mikedavis Is it possible to underline the spelling issues in a different color than the LSP issues? |
I was imagining that there would be diagnostics (same as LSP diagnostics) for misspelled words. They could be at a different or maybe customizable severity which would affect how they're displayed. In the linked commit/branch I'm using |
I don't know if you've already started this implementation. I wanted to do something similar last year as an LSP for spellchecking support called In the wordc part of Also, if the TS strategy is great to avoid spellchecking keywords, it would still be useful to have tailored dictionaries for language and programming terms. CSpell had done a great job if I recall correctly. I would be happy to help on this feature |
The spellbook branch looks already really usable to me. Highlight spelling mistakes alone is a game changer for me.
Expanding on this a bit:
Is it possible to configure which treesitter objects (?) are spellchecked? For example, what if I only want spellchecking of i.e. variable names? EDIT: where do I have to put |
I believe that branch should be creating the personal dictionary file for you if you use the That branch is really hacky though - there isn't any interaction with tree-sitter to (dis)qualify nodes to check yet and the checking is run per-render on the visible viewport. |
Yes and no: if the directory
Yes, I am aware! However, and that's kudos to you, it already works really and is much more performant than for example https://github.com/ltex-plus/ltex-ls-plus and does what it's supposed to. From a users perspective, only treesitter is missing to decrease the number of false-positives. Great work already! |
I have just started testing this branch too, and I agree it is working really well. Is it possible to add words to a dict on a project level? I have used cSpell in the past and that only checks words that are greater than 3 characters long which removes a lot of false negatives. It would be useful if that could be added as a configurable option. If a single word within a kebab-case string is identified as misspelled it highlights the whole string. Not sure if this is intended, but I would expect it just to highlight the misspelled word(s) like it is doing for other cases. When using the add_word_to_personal_dictionary command on a highlighted word within a camel or pascal case string it passes the whole string to the command and not just the highlighted segment. |
This will be a bit off-topic for PR, but relevant to the topic of "false negatives". |
Another feature that would be nice to have are custom affixes. For example, my custom dictionary contains
and uses existing suffixes to define the plural. Now I want add words with the prefix
Of course I can specify them manually (which is probably most of the time sufficient), but it would be nice to able to add a custom
with the custom prefix
In the best case, the words are also merged with existing affixes. In the case of |
We are aware of typos but intentionally choose a more traditionam dictionary approach because typoes has way too many false negatives. I would rather add to my personal dictionary and use TS for eliminating false negatives. |
@pascalkuthe Yeah, I was not suggesting that approach in Helix. I think typos shines in CIs to enforce some base level of quality, where false positives are very very annoying. During text editing most people doesn't mind few false positives. Having said that on Helix Matrix channel someone linked https://github.com/tekumara/typos-lsp and I just configured it in Helix for my |
Having a spellcheck in parity with Vim would require no manual setup to provision a user dictionary. just press zg/zw will add/remove the word under the cursor to the user dictionary. if it does not exist, it will be created. I think Helix should be no less user friendly than that! 👍 |
I've switched https://github.com/helix-editor/spellbook (Hunspell-like spellchecking library) to public and published a v0.1.0 release. It's still a work-in-progress but it's matured to the point where the
check
interface works robustly for at leasten_US
. Other languages should work too but there may be bugs with more advanced rules dictionaries can use.suggest
functionality is what I'm working on now but now thatcheck
is in place it's a good time to start thinking about the integration with Helix which is also a potentially large amount of work.I'm using it in my driver branch in (commit) where the integration is very naive: it checks all words in the viewport render and highlights misspelled words.
@pascalkuthe and I have chatted about this and here's what we're thinking for a proper integration:
spellbook::Dictionary::new
can take tens of milliseconds depending on the size of a dictionary.Interacting with the spellchecker should be similar to interacting with LSP code-actions.
<space>a
should pull up LSP code actions and actions from the spellchecker: adding a misspelled word to a personal dictionary and suggestions fromsuggest
. Adding to a personal dictionary can use thespellbook::Dictionary::add
function and append a line with the word to a file in$XDG_STATE_HOME/helix/personal-dictionary/<locale>
.The text was updated successfully, but these errors were encountered: