mfussenegger / nvim-lint

An asynchronous linter plugin for Neovim complementary to the built-in Language Server Protocol support.
GNU General Public License v3.0
1.78k stars 192 forks source link

Vale config cannot be stored in hidden folders #280

Closed leesoh closed 9 months ago

leesoh commented 1 year ago

Hi there! First off, thanks for all the work you've put into this plugin. I really like the approach!

I'm running into an issue with Vale. I store my Vale configuration in /home/leesoh/.config/vale/vale.ini. Running vale --config /home/leesoh/.config/vale/vale.ini works as expected.

I've configured the Vale linter like so:

local lint = require('lint')
local v = require('lint.linters.vale')

-- enable linters
require('lint').linters_by_ft = {
  markdown = {'vale', 'markdownlint'}
}

-- lint on save
vim.api.nvim_create_autocmd({ 'BufWritePost' }, {
    callback = function()
        lint.try_lint()
    end,
})

-- markdown
local function get_cur_file_extension(bufnr)
  bufnr = bufnr or 0
  return "." .. vim.fn.fnamemodify(vim.api.nvim_buf_get_name(bufnr), ':e')
end

v.args = {
    '--no-exit',
    '--output', 'JSON',
    '--ext', get_cur_file_extension,
    '--config', '/home/leesoh/.config/vale/vale.ini'
}

I get no errors when saving a markdown file, but I also get no linting. When I run :lua require("lint").try_lint(), I get the following: Linter commandvaleexited with code: 2. If I move my vale.ini to /home/leesoh/vale.iniand update my configuration, everything works as expected. Moving it to/home/leesoh/.hidden/vale.ini` breaks it again.

I took a quick look at the source, but couldn't find a reason for this so I'm hoping you can help. Thanks!!

mfussenegger commented 1 year ago

Just tried it and for me it works fine. Are you sure you're not having some hiccup with the StylesPath in the vale.ini ?

leesoh commented 1 year ago

I didn't think so because the only thing I was changing between attempts was whether the config was in a hidden folder or not. I'll take another look today.

leesoh commented 1 year ago

Here's my vale.ini:

StylesPath = /home/leesoh/.config/vale/styles

MinAlertLevel = suggestion

Packages = Microsoft

[*]
BasedOnStyles = Vale, Microsoft

The same configuration file was used by both the plugin and the CLI tool, but I only received errors using the plugin.

cyntheticfox commented 1 year ago

Trying it for myself, I did have some errors with the example given since markdownlint isn't enabled/installed, but that's it.

My guess is that the configuration may not be getting stored properly, as :lua require("lint").try_lint() shouldn't error as though vale sets an exit code on completion normally, it should be getting passed the --no-exit flag...

Could also add support for a config key to the linter configuration

leesoh commented 1 year ago

Agreed. I couldn't figure out why there'd be an exit code either. And it's really strange that moving the configuration to a non-hidden directory solves the issue.

leesoh commented 1 year ago

I just came back to this on a fresh system. I was wrong initially: I don't believe the --config argument is parsed at all. If the config file is in a location Vale expects, it will be loaded. Otherwise, it will exit with the above error.

mfussenegger commented 1 year ago

I just came back to this on a fresh system. I was wrong initially: I don't believe the --config argument is parsed at all. If the config file is in a location Vale expects, it will be loaded. Otherwise, it will exit with the above error.

So this is a vale issue?

leesoh-bf commented 1 year ago

I don't think so. When I run vale test.md --config nonexistent.ini, I get an error that the path cannot be found. When I point to a valid vale config in /tmp, it runs.

LeoAdL commented 11 months ago

I have the same issue on MacOS 13.4.1: if I place my .vale.ini in ~/.config/, it is not picked up by nvim-lint (exit code 2), while if I move it directly to the home directory, it works as expected.

alecandido commented 10 months ago

I was experiencing the exact same problem (also MacOS 13.4.1), but actually at some point it stopped, and now has a sensible behavior...

For sure, I should have been doing something wrong before, but now all the combinations are working as expecting. I.e. I'm using:

  local vale = require("lint.linters.vale")
  vale.args = {
    "--no-exit",
    "--output",
    "JSON",
    "--ext",
    get_cur_file_extension,
    "--config",
    os.getenv("XDG_CONFIG_HOME") .. "/vale/vale.ini",
  }

and if I replace os.getenv ... line by "/Users/myuser/.config/vale/vale.ini" is working as well, while omitting the last letter, e.g., gives back the error code 2.

By working I mean that the error is not generated any longer, I haven't properly tested the linter itself.

EDIT: I also tested some lints, I confirm it's properly working