Closed UnderCooled closed 3 months ago
The find
property is used for controlling whether a formatter should run in a certain directory
https://github.com/nvimdev/guard.nvim/blob/d4782860b7da344d7409edbe7ee3693d5b8ea226/README.md?plain=1#L95
For configuration, take a look at the docs of the respective linter, it shouldn't have anything to do with guard :)
I'm trying to add "golangci-lint" to my guard configuration, it depends on "the current working directory should be project root directory", or it won't find imported modules in the project. I thought linter's find
property acting like lspconfig "root_dir".
Likewise, I've added "editorconfig-checker" to my generic linters, I want it only runs when find ".editorconfig" file exist in the project root directory, how should I config this linter without find
property?
Maybe my use case fit using efm-language-server with lspconfig or null-ls better? Adding find project root support may make guard.nvim too complex?
I see an undocumented property cwd
in "spawn.lua", it should fit my use case.
It seems that null-ls has utils to cache and find project root pattern, and supports linting with multiple files, I might go back to this heavier plugin again.
I'm trying to add "golangci-lint" to my guard configuration, it depends on "the current working directory should be project root directory", or it won't find imported modules in the project. I thought linter's
find
property acting like lspconfig "root_dir".
I believe guard-collection
has a config for that, you may want to take a look.
Likewise, I've added "editorconfig-checker" to my generic linters, I want it only runs when find ".editorconfig" file exist in the project root directory, how should I config this linter without
find
property?
Hmm, maybe it has to be implemented for linters as well.
Maybe my use case fit using efm-language-server with lspconfig or null-ls better? Adding find project root support may make guard.nvim too complex?
guard defaults to lsp root, then fallback to vim.fn.cwd()
for formatting, I guess linters don't have that capability because there haven't been a use case yet.
Personally I find null-ls
and efm
a bit bloated, they essentially do the same thing as guard but they parse the diagnostics/formatted text a into lsp responses/text edits and neovim has to read it on top of that...
Yeah, that's why I was trying to switch to guard.nvim... My lspconfig configuration file get blaoted again. 😢
You can check guard-collection's golangci-lint config and null-ls one I posted above.
Null-ls can search "go.mod" path, and set it to command cwd
, and cache that result.
It will work on multiple-files use case:
multiple_files If set, signals that the generator will return results that apply to more than one file. The null-ls diagnostics handler allows applying results to more than one file if this option is true and each diagnostic specifies a bufnr or filename specifying the file to which the diagnostic applies.
It checks exit code (guard.nvim #109).
OK, so there are two problems here.
cwd
is not configurable: we could make it configurable but it seems unnecessary right now, golangci-lint
should work without knowing the root directory (hopefully? Or if it's broken I would have to remove it from the builtins). If it really bugs you, set the buffer cwd to the root like I did.
missing multiple file support: that is trickier, it is not certain what we should do when we get diagnostics of unopened files. We could just cache it, but then it might get updated pretty soon and you may never open that particular file. Also this is quite linter specific, I think most linters work on one file at a time. It can be achieved though with the right api, which... is planned ~long ago~, but I haven't got the capabilities to finish it yet.
If I setup a filetype to use LSP as formatter, I cannot set
find
property to linter?Lots of linters have config files, without
find
property, how can you skip those paths which don't have a config file?