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

Windows filepaths causing diagnostics to be discarded #551

Open DownerCase opened 3 months ago

DownerCase commented 3 months ago

I've been trying to add this lovely plugin to my setup on Windows today but have been having trouble that seems weird...

So I'm interested in the cmakelint linter but can't get nvim-lint to publish any diagnostics due to the file paths getting mangled.

I am able to verify that cmakelint is being run, and I am getting results back, for me they look like this:

F:\dev\cpp\project\CMakeLists.txt:8: Line ends in whitespace [whitespace/eol]
F:\dev\cpp\project\CMakeLists.txt:10: Line ends in whitespace [whitespace/eol]
F:\dev\cpp\project\CMakeLists.txt:36: Do not mix upper and lower case commands [readability/mixedcase]
...

After the parser I get results of the form:

{file = "\dev\cpp\project\CMakeLists.txt", lnum = 8, message = "Line ends in whitespace", code = "whitespace/eol"}

Notice that the file path has no drive letter.

Later on, this path gets compared to buffer_path, which is set here: https://github.com/mfussenegger/nvim-lint/blob/e824adb9bc01647f71e55457353a68f0f37f9931/lua/lint/parser.lua#L114

For myself that evaluates to F:\dev\cpp\project\CMakeLists.txt

Now we come to that part that causes nothing to be returned

https://github.com/mfussenegger/nvim-lint/blob/e824adb9bc01647f71e55457353a68f0f37f9931/lua/lint/parser.lua#L69-L79

captures.file begins with \ not / so the cwd gets prepended to it, creating an obviously wrong path (F:/dev/cpp/project/dev/cpp/project/CMakeLists.txt)

Even if that wasn't triggered, the later comparison to buffer_path would still fail due to the missing drive letter.

So perhaps it's just a regex issue slicing off the drive letter, but how did #435 not immediately uncover this, and mypy has the same regex problem, so how did #513 fix the authors problem!?

Is this my machine/config being weird, a skill issue, or is it genuinely just broken?

I've managed to hack the things around to fix my problems :smile:. Will wait for a response here before opening a PR though.