rcarriga / nvim-notify

A fancy, configurable, notification manager for NeoVim
MIT License
3k stars 80 forks source link

"No information available" for some LSPs #110

Closed mauriciotp closed 2 years ago

mauriciotp commented 2 years ago

I was editing my React project, and for no reason, after using hover provided by lsp, a message shows up saying: "No information available" for each Lsp that nvim notify can't get information. For example, i'm using tailwindcss and cssmodules servers, and after pressing shift k (keymap for 'vim.lsp.buf.hover()'), nvim notify generates two messages, one for each server (i presume). Any idea on how to solve it? I was wondering if i could manage to disable the message "No information available" for that specific case that nvim notify can't get information about it.

image

rcarriga commented 2 years ago

for that specific case that nvim notify can't get information about it.

nvim-notify is purely a messaging service, it has nothing to do with the message contents. This is the built-in lsp hover handler.

I'd suggest just writing your own handler for hover to not send these messages. Here is the default handler with the message commented out:

    vim.lsp.handlers["textDocument/hover"] = function(_, result, ctx, config)
      config = config or {}
      config.focus_id = ctx.method
      if not (result and result.contents) then
        vim.notify('No information available')
        return
      end
      local markdown_lines = vim.lsp.util.convert_input_to_markdown_lines(result.contents)
      markdown_lines = vim.lsp.util.trim_empty_lines(markdown_lines)
      if vim.tbl_isempty(markdown_lines) then
        -- vim.notify('No information available')
        return
      end
      return vim.lsp.util.open_floating_preview(markdown_lines, 'markdown', config)
    end
mauriciotp commented 2 years ago

I got it, thanks!