-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Lua error at multiline strings in util.lua: 'Column value outside range' #224
Comments
This issue appears when a language server publishes a diagnostic which has an unsupported In my case this diagnostic field was set to I resolved this by attaching a custom local lspconfig = require("lspconfig")
local on_publish_diagnostics = vim.lsp.handlers["textDocument/publishDiagnostics"]
lspconfig.golangci_lint_ls.setup({
-- <...>
handlers = {
-- stops an out-of-range column error when viewing diagnostics with Trouble.nvim
["textDocument/publishDiagnostics"] = function(_, result, ctx, config)
for idx, diag in ipairs(result.diagnostics) do
for position, value in pairs(diag.range) do
if value.character == -1 then
result.diagnostics[idx].range[position].character = 0
end
end
end
return on_publish_diagnostics(_, result, ctx, config)
end,
},
}) |
@snoord I just recently found this error too when using golangci-lint-ls. Your solution works flawlessly! |
According to the LSP spec, the line and character must both be unsigned integers. The spec also specifically calls out that `-1` is not supported: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#position With some code structures, it is possible to produce an error such as the following from `golangci-lint run --out-format=json`: ```json { "FromLinter": "typecheck", "Text": ": # github.com/my/package [github.com/my/package.test]\n./main.go:31:2: undefined: asdf", "Severity": "", "SourceLines": [ "package main" ], "Replacement": null, "Pos": { "Filename": "main.go", "Offset": 0, "Line": 1, "Column": 0 }, "ExpectNoLint": false, "ExpectedNoLintLinter": "" } ``` This ultimately does result in some issues with tooling compatibility, for example: folke/trouble.nvim#224 (comment) By preventing the number from dropping below zero, this class of error should no longer be present.
According to the LSP spec, the line and character must both be unsigned integers. The spec also specifically calls out that `-1` is not supported: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#position With some code structures, it is possible to produce an error such as the following from `golangci-lint run --out-format=json`: ```json { "FromLinter": "typecheck", "Text": ": # github.com/my/package [github.com/my/package.test]\n./main.go:31:2: undefined: asdf", "Severity": "", "SourceLines": [ "package main" ], "Replacement": null, "Pos": { "Filename": "main.go", "Offset": 0, "Line": 1, "Column": 0 }, "ExpectNoLint": false, "ExpectedNoLintLinter": "" } ``` This ultimately does result in some issues with tooling compatibility, for example: folke/trouble.nvim#224 (comment) By preventing the number from dropping below zero, this class of error should no longer be present.
Development on the main branch is EOL. Trouble has been rewritten and will be merged in main soon. This issue/feature either no longer exists or has been implemented on dev. For more info, see https://github.com/folke/trouble.nvim/tree/dev |
Warnings that refer to the position where a multiline string ends causes errors when hover in Trouble buffer and goto doesn't work.
Small example, create a python file with following content:
To get the following warnings in the Trouble buffer:
When placing the cursor on the middle warning this is the error output:
When pressing
<enter>
on that entry, this is the error output:It works fine to hover and "go to" on other warnings, it's just errors referring to last line of multiline string it seems like.
The text was updated successfully, but these errors were encountered: