zed-cspell icon indicating copy to clipboard operation
zed-cspell copied to clipboard

Support cspell.json

Open mantou132 opened this issue 11 months ago • 11 comments

Now resolve: https://github.com/vlabo/cspell-lsp/blob/main/validator.mts#L47 https://github.com/streetsidesoftware/vscode-spell-checker/blob/3cfd2ce210e1338e5f7b19e2357e52f1860aa751/packages/_server/src/DocumentValidationController.mts#L109

mantou132 avatar Jan 05 '25 08:01 mantou132

Thanks a lot for building this extension! I just tested it and cspell seems to pick up a cspell.json file in the workspace root. I was able to manually add custom words there and the extensions correctly picked them up (after restart). However I was not able to install and use another language dictionary (this is what I tried). Maybe this extension could provide some config that would list and install custom dictionaries via cspell link add @cspell/dict-de-ch command.

shishkin avatar Jan 07 '25 17:01 shishkin

@shishkin After installing the dictionary, configure it in cspell.json:

npm install -g @cspell/dict-de-ch
cspell link add @cspell/dict-de-ch

cspell.json:

"dictionaries": ["de-ch"]

mantou132 avatar Jan 10 '25 09:01 mantou132

Yeah, I know that. But I don't have cspell or even npm installed globally on my system and would like to keep like that. As long as this Zed extension manages to install cspell it should also install and manage dictionaries IMHO.

shishkin avatar Jan 10 '25 09:01 shishkin

cspell supports using an alternate config file, let's say ~/.config/cspell.json. Where in my zed config should I put the --config arg for that to happen?

ygingras avatar Jan 16 '25 22:01 ygingras

But I don't have cspell or even npm installed globally on my system and would like to keep like that.

I've done the following:

npm init
npm install cspell @cspell/dict-nl-nl @cspell/dict-en_us
npx cspell link add @cspell/dict-en_us
npx cspell link add @cspell/dict-nl-nl

Not sure what will happen when the versions of the local cspell package and the extension start to drift apart.

And I have a local cspell.config.yaml with:

$schema: https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json
version: "0.2"
dictionaries:
  - en-US
  - en_us
  - nl-nl
language: "en-US,nl-nl"

(Yes, I'm not sure whether to use en-US or en_us.

peteruithoven avatar Jan 18 '25 18:01 peteruithoven

Building on @peteruithoven 's workaround, I figured that cspell package is just a CLI and not essential for the language server. The cspell link add command just writes a global config into $XDG_CONFIG/cspell/cspell.json with a dictionary import. So after npm install @cspell/dict-de-ch I was able to import and use the dictionary with the following local cspell.json config:

{
  "$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
  "language": "en-US, de-CH",
  "import": ["./node_modules/@cspell/dict-de-ch/cspell-ext.json"]
}

shishkin avatar Jan 19 '25 19:01 shishkin

Thanks for this extension, very useful. However, it works for me in JavaScript files and JSON, but not in .vue or .md files. Do you know why that is?

mgalic avatar Jan 19 '25 23:01 mgalic

Where and how can I add words to cspell that all projects I open in Zed would pick up? I guess what I'm asking is, how can I tell zed-cspell to use a global cspell.json file?

Tobbe avatar Apr 18 '25 07:04 Tobbe

I noticed at some point when I added a word to the dictionary it used ~/.config/zed/cspell.json, which is quite ideal. However it now doesn't seem to pick that up and wants to always create a new file in project root.

EDIT: To work around this I did a ln -s ~/.config/zed/cspell.json ~/.config/cspell.json, which is one of the valid paths it'll look for by default. Have to add them manually tho, but better than nothing.

Blacksmoke16 avatar May 15 '25 01:05 Blacksmoke16

Most settings from cspell.json seem to work, but the ignorePaths from my project local cspell.json setting doesn’t appear to have any effect. I tested the same config in the VSCode extension, and there it works as expected. Is there a way to make this extension respect the ignorePaths setting too?

dmitriyyan avatar Jul 14 '25 14:07 dmitriyyan

Hello everyone, you can try v0.0.5

But you need to wait for the following pr merge:

https://github.com/zed-industries/extensions/pull/3461

mantou132 avatar Oct 01 '25 04:10 mantou132