Skip to content
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

Spell Checking #5305

Open
Tracked by #5346
rkusa opened this issue Jul 10, 2022 · 47 comments
Open
Tracked by #5346

Spell Checking #5305

rkusa opened this issue Jul 10, 2022 · 47 comments
Labels
enhancement [core label] potential extension Functionality that could be implemented as an extension (consider moving to community extensions) priority request A request from a stakeholder or influential user

Comments

@rkusa
Copy link

rkusa commented Jul 10, 2022

Is your feature request related to a problem? Please describe.
I regularely make a lot of typos in code comments, docs, but also in variable names. It is always annoying if pull-requests get post-poned just because of typos reviewers found.

Describe the solution you'd like
I find it tremendously helpful if Zed could spell checks my code. I personally rely a lot on this in e.g.:

Things the spell checker might check:

  • comments,
  • doc comments,
  • strings,
  • segments of a variable name (eg. in get_name/GetName/getName, it would check get and name).

Additional useful features:

  • The possibility to add words to a system-wide dictionary.
  • The possibility to add words to a project-specific dictionary.
  • The possibility to check multiple languages at the same time (e.g. for non-English code, variables are often in English, while strings and comments might contain text in another language).

I'd find it especially neat if the spell check would use native system APIs so that I can expect consistent behaviour between the editor and other apps on my system.

Screenshots

Sublime Text:

image

VSCode Code Spell Checker extension:

image

@rkusa rkusa added enhancement [core label] triage Maintainer needs to classify the issue labels Jul 10, 2022
@iamnbutler
Copy link
Member

My dream would be to embed something like Grammarly right in Zed :)

@rkusa
Copy link
Author

rkusa commented Dec 10, 2022

Just came along the following code spelling library written in Rust. Just dropping the link in case it would help: https://github.com/crate-ci/typos

@JosephTLyons JosephTLyons transferred this issue from zed-industries/community Jan 24, 2024
@jaydenseric
Copy link
Contributor

I just tried setting up Zed today and this was the showstopper issue that made me go back to VS Code. Spell check is a critical concern of an editor; it's generally too complex to enforce correct spelling cross-platform via CLI and CI with any degree of confidence and you may be contributing spelling errors to projects with tooling and CI not in your control. I am hopelessly dependent on spellcheck when writing hundreds of words worth of comments and docs per day, or when naming things like types, functions, and variables.

VS Code spell check is quite poor because it's via an extension (https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) and not the native macOS spellcheck system, so the spell check UI is inconsistent with other apps and the learned words and not in sync with every other app on your system. But at least it has a solution.

There are non VS Code editors out there that have really nice native OS based spell check, so it's possible.

@SpyrosMourelatos
Copy link

SpyrosMourelatos commented Mar 4, 2024

I would prefer LanguageTool to Grammarly as it FOSS and supports more languages

@JosephTLyons JosephTLyons added the priority request A request from a stakeholder or influential user label Mar 10, 2024
@JosephTLyons
Copy link
Collaborator

JosephTLyons commented Mar 25, 2024

This feature feels like a rather large one to add to Zed, when considering all of the things you should be able to do with spell check. What does a good first pass look like? What would be the bare minimum needed to ship something useable?

Some unknowns:

  • Is there a Rust crate out there suitable for spell checking in the context of code?
  • Would we have some sort of setting for which file types to spell check, or, maybe a setting for which file types to not spell check.. or both? I think VS Code's spell check has these settings.
  • How do we want to surface the spelling errors? Is it just another red squiggly line and do we have a way to suggest a fix? I feel like for a first pass, we could simply display the potential matches in the hover, and a future follow-up could add the possibility to accept a suggestion for a typo.
  • VS Code provides spell checking for multiple languages, do we just ship English first? Maybe we'll be lucky and have a crate that can handle multiple languages.

Bonus points

Spell checking in Zed's chat editor.

Future AI ideas

A distant future goal might be to somehow leverage the supported AI models in Zed to fill suggestions for mispelled words, if the suggestions provided by some crate aren't the greatest.

@bajtos
Copy link

bajtos commented Mar 26, 2024

How do we want to surface the spelling errors? Is it just another red squiggly line and do we have a way to suggest a fix?

In VS Code, the Grammarly extension integrates with the "suggested fix" feature provided by language servers. I can use the same keyboard shortcut to fix ESlint violations and spelling/grammar mistakes.

@jansol
Copy link
Contributor

jansol commented Mar 26, 2024

Vale is an offline rule-based "prose linter" (spelling & style checker) with an official LSP implementation. It is also code-aware so it can check code comments and won't get confused by markdown or HTML. Seems like a great fit?

@arthur-st
Copy link

Testing Vale this week, and it works quite well on the CLI level. The configuration might be a bit tricky to set up, but should be fine sailing afterwards.

@phaynes

This comment was marked as off-topic.

@brandondrew

This comment was marked as off-topic.

@levlaz
Copy link

levlaz commented Jul 11, 2024

I'm trying to use zed to write docs in MD and MDX. The lack of a spell checker is really painful.

@albassort

This comment was marked as off-topic.

@phaynes
Copy link

phaynes commented Jul 23, 2024

Hi,

I have taken a first stab at creating a configurable full spell checker / grammar checker and proofing engine that integrates to Zed - example key bindings included, uses the OpenAI and Anthropic API's.

The markdown proofing engine is here, and I am finalising an initial baseline to part of a general publication engine from text - although I am starting with research papers.

Any and all feedback would be greatly appreciated. This is genuinely a first drop of the approach.

Philip

@florinpatrascu
Copy link

I truly appreciate the effort the team and contributors put into bringing this feature to life, but I have to ask: is there any chance of getting a spellchecker for Zed that doesn't rely on a remote service or require a local GPU?

@maxdeviant maxdeviant added the potential extension Functionality that could be implemented as an extension (consider moving to community extensions) label Jul 27, 2024
@jansol
Copy link
Contributor

jansol commented Jul 27, 2024

I truly appreciate the effort the team and contributors put into bringing this feature to life, but I have to ask: is there any chance of getting a spellchecker for Zed that doesn't rely on a remote service or require a local GPU?

The Vale extension does exactly this. It relies on a local dictionary (defined with plain text files) that it matches words and phrases against with plain old regular expressions. Unfortunately it currently advertises support for Markdown files (Vale itself also supports spellchecking comments in programming languages), and the language server was crashing a lot when used from zed last time I tried. Nobody really knew why, though.

@phaynes

This comment was marked as off-topic.

@brandondrew

This comment was marked as off-topic.

@Altair-Bueno

This comment was marked as off-topic.

@phaynes

This comment was marked as off-topic.

@florinpatrascu

This comment was marked as off-topic.

@brandondrew

This comment was marked as off-topic.

@Altair-Bueno
Copy link

Altair-Bueno commented Jul 29, 2024

You know what?, you are right. Its splitting tokens accordingly is not that of an easy problem. Thankfully, is an already solved one. And much easier with tree sitter built in. You can ignore language keywords to speed up spellchecking.

However, instead of debating about how difficult this is we can just look what is out there.

This is the source code for IntelliJ's spellchecker. Which i personally consider to be the best out there (code wise). License is Apache https://github.com/JetBrains/intellij-community/tree/master/spellchecker/src/com/intellij

And this one is Code Spell Checker for VSCode. Not as good. Not as powerful (IntelliJ also caches a lot more stuff like prepositions), but probably simpler. GNU license. https://github.com/streetsidesoftware/vscode-spell-checker

Both of these implement the behavior I stated earlier.

@phaynes

This comment was marked as off-topic.

@bbb651

This comment was marked as off-topic.

@albassort

This comment was marked as off-topic.

@notpeter
Copy link
Member

notpeter commented Aug 8, 2024

This has devolved pretty heavily into a pro-LLM / anti-LLM mess. I'm going to respectfully request that we quiesce further discussion on this GitHub issue, I'd prefer not to lock the issue, but will if necessary. To summarize:

  1. There is significant demand for a "traditional" (non-LLM) spell/grammar check in Zed.
  2. Zed could also ship advanced writing assistance leveraging LLMs (remote or local) at some point in the future.

Both are worth considering. If you want to argue about this further, please go somewhere else. Feel free to open a GitHub Discussion thread or hang-out in #off-topic on the Zed Community Discord.

Thanks all!

@Conaclos
Copy link

My dream would be to embed something like Grammarly right in Zed :)

I personally use Language Tools because you can deploy your own instance locally.
It could be great to have this kind of integration with zed.

@jansol
Copy link
Contributor

jansol commented Aug 20, 2024

There seems to be a LSP implementation for LanguageTool. Getting that to work with Zed should be as easy as copying some existing language extension and pointing it to that LSP.

@ivansigmund

This comment was marked as off-topic.

@bbb651
Copy link
Contributor

bbb651 commented Aug 28, 2024

There are is a bit of documentation here on extensions, read it, look at a couple of random extensions with an LSP in that repository, specifically the rust code they contain, most of them should be pretty similar with code downloading the LSP from github. Copy the code and change the relevant strings, copy an extension.toml, change it as needed and get rid of language since it isn't needed here. You can test it with "load dev extension"

@ivansigmund

This comment was marked as off-topic.

@notpeter
Copy link
Member

I've created an dedicated issue on the extensions repo for discussion of a LanguageTool based Spell-checker extensions. Please migrate your discussion there as this issue has has 20+ followers who get notifications for every comment.

Thanks @ivansigmund @bbb651 @jansol @Conaclos for identifying this a potential path forward.

maxdeviant added a commit to zed-industries/extensions that referenced this issue Sep 9, 2024
Add support for the [Typos Language
Server](https://github.com/tekumara/typos-lsp).

Typos is a spell checker, this extension will help having a bit of spell
checking available while waiting for
zed-industries/zed#5305

---------

Co-authored-by: Marshall Bowers <[email protected]>
@camstuart
Copy link

+1 cspell would be my vote!

@notpeter
Copy link
Member

notpeter commented Sep 15, 2024

+1 cspell would be my vote!

I've created a dedicated issue on the extensions repo for cspell via LSP:

@JosephTLyons
Copy link
Collaborator

JosephTLyons commented Sep 20, 2024

Just popping in to say that someone has contributed a typos extension. I think we should leave this open though, as the underlying typos crate is intentionally low-false positive, so it doesn't catch as much as a normal spell checker.

SCR-20240920-nofy

See: zed-typos extension for more.

@mocenigo

This comment was marked as off-topic.

@rucoder
Copy link

rucoder commented Oct 18, 2024

Just popping in to say that someone has contributed a typos extension. I think we should leave this open though, as the underlying typos crate is intentionally low-false positive, so it doesn't catch as much as a normal spell checker.
SCR-20240920-nofy

See: zed-typos extension for more.

it works pretty good for me, but I cannot find a way to 'ignore' a word. Is there any configuration file for typos extension?

@bbb651
Copy link
Contributor

bbb651 commented Oct 18, 2024

Yes, see the typos reference and the README.
typos-lsp has an open issue to add an lsp action for it, and there's a draft PR to implement it.

@kakalot0008
Copy link

I installed the typos extension, but it's not working. How can I configure it?

@scorphus
Copy link

scorphus commented Nov 5, 2024

Hey, @kakalot0008. I got it working. Here's the snip of my settings.json:

// Zed settings
//
// For information on how to configure Zed, see the Zed
// documentation: https://zed.dev/docs/configuring-zed
//
// To see all of Zed's default settings without changing your
// custom settings, run `zed: open default settings` from the
// command palette (cmd-shift-p / ctrl-shift-p)
{
  // ...
  "lsp": {
    "typos": {
      "initialization_options": {
        // Diagnostic severity within Zed. "Error" by default, can be:
        // "Error", "Hint", "Information", "Warning"
        "diagnosticSeverity": "Hint",
      }
    }
  },
  // ...
}

Please let me know if that works for you!

@kakalot0008
Copy link

Hi, @scorphus. It's worked. Thanks for your setting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement [core label] potential extension Functionality that could be implemented as an extension (consider moving to community extensions) priority request A request from a stakeholder or influential user
Projects
None yet
Development

No branches or pull requests