Closed gregorias closed 1 month ago
FYI @glepnir I'm still seeing this issue in the latest commit a8b24b2
:
LSP[haskell-tools.nvim] Error condition, please check your setup and/or the [issue tracker](https://github.com/haskell/haskell-language-server/issues): LSP: incoming message parse error: Error in $.params.context.diagnostics[0]: key "range" not found when processing {"params":{"range":{"end":{"line":11,"character":0},"start":{"line":11,"character":0}},"textDocument":{"uri":"file:\/\/\/home\/me\/ projects\/myproject\/src\/MyLib.hs"},"context":{"diagnostics":[{"code":"-Wunused-matches"}]}},"method":"textDocument\/codeAction","jsonrpc ":"2.0","id":17} Press ENTER or type command to continue
And I've verified that this issue disappears when I use a commit before bbe032f
(fix: deprecate and add use_nerd
)
what output of vim.diagnostic.get
Yeah sure, when I run :lua print(vim.inspect(vim.diagnostics.get()))
in a haskell file where I'm seeing this issue (and without changing that cursor position) I see this:
{ { _tags = { unnecessary = true }, bufnr = 1, code = "-Wunused-matches", col = 12, end_col = 15, end_lnum = 12, lnum = 12, message = "Defined but not used: ‘env’", namespace = 33, severity = 2, source = "typecheck", user_data = { lsp = { code = "-Wunused-matches" } } }, { _tags = { unnecessary = true }, bufnr = 11, code = "-Wunused-imports", col = 0, end_col = 29, end_lnum = 15, lnum = 15, message = "The import of ‘Data.Foldable’ is redundant\n except perhaps to import instances from ‘Data.Foldable’\nTo import instances alone, use: import Data.Foldable()", namespace = 33, severity = 2, source = "typecheck", user_data = { lsp = { code = "-Wunused-imports" } } } }
I have update a check of range . does it works now ?
Oh and this is what I get from :lua print(vim.inspect(vim.lsp.diagnostics.get_line_diagnostics()))
, in case that helps.
{ { code = "-Wunused-matches", message = "Defined but not used: ‘env’", range = { ["end"] = { character = 15, line = 12 }, start = { character = 12, line = 12 } }, severity = 2, source = "typecheck", tags = { 1 } } }
But I just saw your comment! Thanks, yes that has made the error go away! Thank you @glepnir.
Might also be worth checking if lnum = row + 1
is correct here, I was seeing the error pop up when I reached the line before the code with the warning.
Could be a coincidence, but perhaps vim.diagnostics.get
considers row numbers to start from 0? I tried checking the docs but they don't say.
update
Describe the bug
Since https://github.com/nvimdev/lspsaga.nvim/commit/bbe032ff1c40e9b695f8a5de9c779ee558dddf4f, Lspsaga sends ill-formatted code action requests causing errors in some language servers, e.g., Haskell Language Server:
The issue is that
range
is missing fromparams.context.diagnostics
. It’s a bug, because the protocol requires it.The problem stems from the plugin copying the table from
vim.diagnostic.get
verbatim.vim.diagnostic.get
promises to returnvim.Diagnostic
, which is not a valid LSP Diagnostic.A fix could be restructuring the return value of
vim.diagnostic.get
into a valid format.Steps to reproduce
I believe the description describes the cause and how to fix it well.
Expected behavior
I believe the description describes the cause and how to fix it well.
Neovim version (nvim -v)
0.10.1
lspsaga commit
bbe032ff1c40e9b695f8a5de9c779ee558dddf4f
Terminal name/version
kitty