folke / trouble.nvim

🚦 A pretty diagnostics, references, telescope results, quickfix and location list to help you solve all the trouble your code is causing.
Apache License 2.0
5.15k stars 173 forks source link

Fix lsp provider when lsp does not return an array #366

Closed ashton closed 3 months ago

ashton commented 7 months ago

Hey, hello, I was using Trouble with rescript-language-server and I was having issues using lsp provider, it wasn't working, so when I debbuged the issue I found that rescript-language-server was responding the follow to the lsp_buf_request function:

{
  range = {
    ["end"] = {
      character = 23,
      line = 1
    },
    start = {
      character = 6,
      line = 1
    }
  },
  uri = "file:///Users/matheus.ashton/dev/pessoal/rsus/src/Transactions/TransactionsPage.res"
}

And in here the evaluation of #result == 0 is true, because the length operator works differently if the table has not an array part: https://stackoverflow.com/a/23591039

So it understands that there is no result at all, but in fact it is just not formatted right.

So I added a vim.tbl_isempty inside each test in order to check if it's indeed has no result or if it just don't have and array part in the table.

This fixed the issue for me.

PS: Also, if you check this same case comparing the behavior of vim.lsp.buf.definition() it works normally.

folke commented 3 months ago

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