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.76k stars 191 forks source link

Linting & stdin -- workaround #587

Open graelo opened 1 month ago

graelo commented 1 month ago

Hi @mfussenegger , thanks for this great plugin.

I observed that when using linters capable of reading from stdin (linter.stdin = true), opening the stdin pipe causes the vim.fn.getqflist function to return an incorrect buffer number (bufnr) for the parsed items. Specifically, with a fresh instance of neovim with only one file, the linted file has bufnr = 1, but the vim.fn.getqflist function outputs items with bufnr is set to an arbitrary value like 3 or 4. This is likely a neovim bug.

This incorrect bufnr causes all parsing results to be discarded due to the additional conditions in the on_errorformat function (https://github.com/mfussenegger/nvim-lint/blob/master/lua/lint/parser.lua#L21):

if item.valid == 1 and (bufnr == nil or item.bufnr == 0 or item.bufnr == bufnr) then

Current Workaround

As a temporary workaround, I bypass the additional conditions on the bufnr check and benefit from TextChanged (debounced) without further issues.

Suggestion

You could either report upstream this issue (you will likely have more impact than a random person like me), or relax the filtering conditions when iterating over the items parsed by getqflist. WDYT?

Best and thanks again for your work!