davidmh / cspell.nvim

A companion plugin for null-ls/none-ls, adding support for CSpell diagnostics and code actions.
82 stars 13 forks source link

CSpell Multi Config Support #61

Closed JateNensvold closed 1 week ago

JateNensvold commented 1 month ago

Hello! I recently started using this plugin within the last several months and came across a use case that is currently not supported by cspell.nvim. I have found that I often want to split words apart into global and local dictionaries so I can configure project repositories with individual cspell config files while also reducing repeated cspell configuration by using a config with words common across my development system.

Currently cspell.nvim does not support using multiple cspell.json files to enable configuration of dictionaries and custom words from multiple locations(ex. global config and local config) but this is a supported use case as shown in the cspell documentation

I have been dabbling around with adding support for this new feature and have a working feature branch that I submitted in https://github.com/davidmh/cspell.nvim/pull/62

It looks like this feature was discussed once before in https://github.com/davidmh/cspell.nvim/issues/18 and it would be great to hear any review/feedback on what would be required to merge this in, or any other thoughts on adding support for the usage of multiple configuration sources for cspell.nvim . Thanks!

davidmh commented 1 month ago

Thanks for the PR! I'll take a look later today.

JeanMertz commented 2 weeks ago

Is there a way to not have to use a project-local config file?

Currently, with this config:

local config = {
        cspell_config_dirs = {
            "~/.config/cspell",
        },
}

I get this merged config file:

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

Which then results in cspell erroring because my current project from which I'm running Neovim doesn't have a project-specific config file.

Here's the specific error I get:

[null-ls] failed to run generator: ...plugin-null-ls/lua/null-ls/helpers/generator_factory.lua:231: error in generator output: Configuration Configuration Loader Error: Failed to resolve configuration file: "/Users/jean/path/to/current/project/cspell.json" referenced from "/Users/jean/.cache/nvim/cspell.nvim/%Users%jean%path%to%current%project%cspell.json" ------------------------------------------- CSpell: Files checked: 0, Issues found: 0 in 0 files with 1 error.

edit I resolved this with echo "{}" > ~/cspell.json, but that feels like a workaround, as I have no need for that additional config file (which now also shows up in my code-action list).

davidmh commented 2 weeks ago

Hi @JeanMertz, thanks for the report, I'll look into it later this week.

davidmh commented 1 week ago

I won't have time to address this soon, I'm thinking about rolling back the feature to unblock existing users.

@JateNensvold what do you think?

davidmh commented 1 week ago

Alright, I've reverted for now, you should be able to use it as before, @JateNensvold I would love your input on this issue.

JateNensvold commented 1 week ago

I'm taking a look into it now, Ill let you know what I find.