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.93k stars 203 forks source link

`append_fname` logic is convoluted #572

Closed frothedoatmilk closed 5 months ago

frothedoatmilk commented 5 months ago

Hi! I'm trying to write a config for haml-lint and I'm seeing some interesting patterns in how append_fname is used in the linters. The way I imagined append_fname would work is something like:

opts = { ..., append_fname = true, ...} => <command> <args> <filename> opts = { ..., append_fname = false, ...} => <command> <args>

But I'm seeing there is some additional logic, where the file name only gets appended if you're not trying to use stdin...but if you need to use the file name in a stdin linter, you have to do some trickery and use vim.api.nvim_buf_get_name(0). This occurs in a number of the linters in the repo at this point. Is there a reason why the append_fname doesn't just default to true across the board?

mfussenegger commented 5 months ago

Because it's common for linters to either take a filename, or use input from stdin, but not both. In some cases the stdin option also requires - as filename. The defaults model the common case but can't capture all variants.