nvimdev / lspsaga.nvim

improve neovim lsp experience
MIT License
3.47k stars 288 forks source link

Lightbulb sends empty lsp.Diagnostic in code action requests #1479

Closed gregorias closed 2 months ago

gregorias commented 2 months ago

Describe the bug

Following the fix to https://github.com/nvimdev/lspsaga.nvim/issues/1478, Lightbulb now sends an empty diagnostic as an array to the language server, which is also bug:

LSP[hls] 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]: parsing Diagnostic failed, expected Object, but encountered Array
when processing
{
  "id": 76,
  "params": {
    "context": {
      "diagnostics": [
        []
      ]
    },
    "textDocument": {
      "uri": "file:///Users/grzesiek/Code/findata/transcoder/test/Test/Transcoder/CharlesSchwab.hs"
    },
    "range": {
      "end": {
        "character": 0,
        "line": 22
      },
      "start": {
        "character": 0,
        "line": 22
      }
    }
  },
  "jsonrpc": "2.0",
  "method": "textDocument/codeAction"
}

The problem stems vim.diagnostic.get returning an empty lsp field:

{ {                                                                                                                                                                                                                                                                                                         
    bufnr = 1,                                                                                                                                                                                                                                                                                              
    col = 37,                                                                                                                                                                                                                                                                                               
    end_col = 29,                                                                                                                                                                                                                                                                                           
    end_lnum = 34,                                                                                                                                                                                                                                                                                          
    lnum = 19,                                                                                                                                                                                                                                                                                              
    message = "• \"Could not parse : REDACTED",                                                                                                    
    namespace = 36,                                                                                                                                                                                                                                                                                         
    severity = 1,                                                                                                                                                                                                                                                                                           
    source = "typecheck",                                                                                                                                                                                                                                                                                   
    user_data = {                                                                                                                                                                                                                                                                                           
      lsp = {}                                                                                                                                                                                                                                                                                              
    }                                                                                                                                                                                                                                                                                                       
  } }

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.0

lspsaga commit

42eb7b26eebf5221a4ae9e4e7a49a95b50202daa

Terminal name/version

kitty

glepnir commented 2 months ago

how about now ?

gregorias commented 2 months ago

Looks good. I don’t get any errors from HLS and lightbulb seems to work fine.