feat(cspell): Option to run cspell diagnostics with a specific cspell config#1329
feat(cspell): Option to run cspell diagnostics with a specific cspell config#1329juanpprieto wants to merge 1 commit intojose-elias-alvarez:mainfrom
Conversation
| return diagnostics | ||
| end | ||
|
|
||
| local CSPELL_CONFIG_FILES = { |
There was a problem hiding this comment.
needed to reuse these between diagnostics and code_actions so I moved them to a shared cspell helper
|
|
||
| local cspell_args = { | ||
| "lint", | ||
| "-c", |
There was a problem hiding this comment.
See -c flag here
https://cspell.org/docs/getting-started/#options
There was a problem hiding this comment.
As I understand it, cspell can run without a config file. What will happen when this flag is used but the config file doesn't exist?
| @@ -0,0 +1,25 @@ | |||
| local CSPELL_CONFIG_FILES = { | |||
There was a problem hiding this comment.
This feels like it might be the wrong place for this logic as it's not a global null-ls helper. I just couldn't find a more suitable folder. Maybe adding a common or shared folder within builtins/ would be better?
There was a problem hiding this comment.
Yes, I agree that if we're going to go with this approach we should put this elsewhere.
There was a problem hiding this comment.
I'm not sure about this approach - I agree that there's an inconsistency between the diagnostics source and the code action source, but I think this is a lot of complexity to add for something that's already solved by extra_args. There's also potential performance issues - running findfile() each time the user requests code actions is okay, but running it on every change (which is what happens for diagnostics sources) could cause serious slowdown.
Since these sources are so closely linked, perhaps there's a better solution where one source can derive config values from the other. This might just be a case where we can add a config recipe to the wiki, though, since I think there's already solutions that use existing null-ls functionality.
|
|
||
| local cspell_args = { | ||
| "lint", | ||
| "-c", |
There was a problem hiding this comment.
As I understand it, cspell can run without a config file. What will happen when this flag is used but the config file doesn't exist?
| @@ -0,0 +1,25 @@ | |||
| local CSPELL_CONFIG_FILES = { | |||
There was a problem hiding this comment.
Yes, I agree that if we're going to go with this approach we should put this elsewhere.
|
FYI: I wonder if the approach used in #1339 could also help solve some of the inconsistencies between the code action source and the diagnostics source. |
Context
Using cspell code_action's
find_jsonfunction to reference a commoncspell.jsonconfig across different projects works great. I canaddnew words to the dict without any problem. However...The problem
The cspell
diagnosticcommand is executed without a-c(config) flag which makes it default to looking for acspell.jsonfile at the cwd.This means that diagnostics do not pickup changes (new words added) to the
cspell.jsonfile we wrote to via the code action.Solution
This PR adds:
find_jsonoption to the diagnostics config (same as code_action)-cflag to thecspellcommand so that diagnostics are generated using the correct config