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

cspell and cspell.nvim giving different results when importing cspell extensions #74

Open
spacian opened this issue Jan 16, 2025 · 1 comment · May be fixed by #75
Open

cspell and cspell.nvim giving different results when importing cspell extensions #74

spacian opened this issue Jan 16, 2025 · 1 comment · May be fixed by #75

Comments

@spacian
Copy link

spacian commented Jan 16, 2025

I tried to install a new dictionary following the instructions. However, cspell.nvim does not seem take the new dictionary into account. Weirdly, if I run cspell through a term manually, it works as expected. Thus the result is something like this:

Image

At the top, you see cspell.nvim's highlighting through null-ls. At the bottom is the cspell output.

"Katze" (cat) is a German word. German words are generally case sensitive, thus "katze" is expected to be incorrect. "clearlynotaproperword" is just there to check that incorrect words still recognized for English words and "english" is a correct English word. "acustomword" is a word I added to the cspell.json to check that the file is used at all by cspell.nvim.
cspell as an external command works as intended. cspell is not installed on the system, it is installed only for nvim with mason.
cspell.nvim does not take into account the imported file. It does recognize the custom word added manually to the config though.

Last but not least, the cspell.json:

{
    "version": "0.2",
    "language": "en,de",
    "import": [
        "C:\\Users\\[my_user]\\AppData\\Roaming\\npm\\node_modules\\@cspell\\dict-de-de\\cspell-ext.json"
    ],
    "words": ["acustomword"]
}

I'm on Windows 11, if that changes anything. The issue is the same on powershell and cmd.
Any ideas what might be going on?

@spacian
Copy link
Author

spacian commented Jan 17, 2025

I dug a little deeper and the issue seems to be that the top level cspell.json generated by cspell.nvim which imports the local cspell.json in the project does not respect the language settings of the imported files. I think that makes sense in the context of cspell, you don't want all the imports to add their own languages. However, in the context of this plugin, it results in unexpected and undesired behavior.

To give the concrete file contents: The language setting "en" leads to the language "de" in the imported file being discarded. New languages cannot be added.

{"version":"0.2","flagWords":[],"language":"en","words":[],"import":["path\/to\/project\/cspell.json"]}

After manually adding the installed languages to the toplevel cspell.json, cspell.nvim gives the correct diagnostics.

{"version":"0.2","flagWords":[],"language":"en,de","words":[],"import":["path\/to\/project\/cspell.json"]}

The project cspell.json is the on from above.

@spacian spacian linked a pull request Jan 17, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant