Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows filepaths causing diagnostics to be discarded #551

Open
DownerCase opened this issue Mar 8, 2024 · 0 comments
Open

Windows filepaths causing diagnostics to be discarded #551

DownerCase opened this issue Mar 8, 2024 · 0 comments

Comments

@DownerCase
Copy link

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:

local buffer_path = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(bufnr), ":p")

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

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

if captures.file then
local path
if vim.startswith(captures.file, '/') then
path = captures.file
else
path = vim.fn.simplify(linter_cwd .. '/' .. captures.file)
end
if normalize(path) ~= normalize(buffer_path) then
return nil
end
end

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 😄. Will wait for a response here before opening a PR though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant