-
Notifications
You must be signed in to change notification settings - Fork 787
feat(cspell): Option to run cspell diagnostics with a specific cspell config #1329
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,8 +32,18 @@ return h.make_builtin({ | |
generator_opts = { | ||
command = "cspell", | ||
args = function(params) | ||
local config = params:get_config() | ||
local find_json = config.find_json or h.cspell.find_cspell_config | ||
local cspell_json_file = find_json(params.cwd) | ||
|
||
if cspell_json_file == nil or cspell_json_file == "" then | ||
cspell_json_file = "cspell.json" -- default for the -c option | ||
end | ||
|
||
local cspell_args = { | ||
"lint", | ||
"-c", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I understand it, |
||
cspell_json_file, | ||
"--language-id", | ||
params.ft, | ||
"stdin", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
local CSPELL_CONFIG_FILES = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I agree that if we're going to go with this approach we should put this elsewhere. |
||
"cspell.json", | ||
".cspell.json", | ||
"cSpell.json", | ||
".Sspell.json", | ||
".cspell.config.json", | ||
} | ||
|
||
-- find the first cspell.json file in the directory tree | ||
local find_cspell_config = function(cwd) | ||
local cspell_json_file = nil | ||
for _, file in ipairs(CSPELL_CONFIG_FILES) do | ||
local path = vim.fn.findfile(file, (cwd or vim.loop.cwd()) .. ";") | ||
if path ~= "" then | ||
cspell_json_file = path | ||
break | ||
end | ||
end | ||
return cspell_json_file | ||
end | ||
|
||
return { | ||
CSPELL_CONFIG_FILES = CSPELL_CONFIG_FILES, | ||
find_cspell_config = find_cspell_config, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needed to reuse these between diagnostics and code_actions so I moved them to a shared cspell helper