nvimtools / none-ls.nvim

null-ls.nvim reloaded / Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.
The Unlicense
2.39k stars 69 forks source link

builtins/vale: allow per directory configuration override #158

Closed ianhomer closed 1 month ago

ianhomer commented 1 month ago

Currently the vale builtin gets the cwd for the spawned process from the root directory, e.g.

[DEBUG Mon 15 Jul 11:27:58 2024] 
/Users/ian/.local/share/nvim/lazy/none-ls.nvim/lua/null-ls/helpers/generator_factory.lua:329: 
spawning command "vale" 
at /Users/ian/projects/my-project with args { "--no-exit", "--output", "JSON", "--ext", ".md" }

When we specify the cwd function for the builtin (as in this PR), we see the process spawning from the directory of the file being processed, e.g. file foo/bar/my-file.md (with the change in this PR) we see the debug log

[DEBUG Mon 15 Jul 11:28:25 2024]
/Users/ian/.local/share/nvim/lazy/none-ls.nvim/lua/null-ls/helpers/generator_factory.lua:329:
spawning command "vale" 
at /Users/ian/projects/my-project/foo/bar with args { "--no-exit", "--output", "JSON", "--ext", ".md" }

This has the effect of vale looking for the vale config in this folder first, e.g. foo/bar/.vale.ini, allowing per directory override. If you don't have a per-directory config file and had your .vale.ini in the project root (or a ancestor directory) of the root then vale will pick this up as it did before this change.

ianhomer commented 1 month ago

Fixes https://github.com/nvimtools/none-ls.nvim/issues/157

ianhomer commented 1 month ago

As a background on checking vale configuration

cd foo/bar
vale ls-config

Shows the configurations files being used

  "ConfigFiles": [
    "/Users/ian/projects/my-project/foo/bar/.vale.ini",
    "/Users/ian/Library/Application Support/vale/.vale.ini"
  ],

The global configuration location for your system is shown with vale ls-dirs, e.g on my machine I see

Asset       | Default Location                                               | Found
StylesPath  | /Users/ian/Library/Application Support/vale/styles             | ✓
.vale.ini   | /Users/ian/Library/Application Support/vale/.vale.ini          | ✓
vale-native | /Users/ian/Library/Application Support/vale/native/vale-native | ✗

You can run vale on a file of your choice e.g. cd foo/bar && vale my-file.md and if all set up OK the diagnostics from the command line should match the diagnostics from none-ls builtin in neovim.

mochaaP commented 1 month ago

Thanks!