nvimdev

Hover

Usage #

Run :Lspsaga hover_doc. If a hover window is opened, then the command would close it.

Hover doc

Use :Lspsaga hover_doc ++keep if you want to keep the hover window. It will pin the hover window to the top right of your buffer.

Keep hover doc window

Keymap example:

vim.keymap.set('n', 'K', '<cmd>Lspsaga hover_doc')

Prerequisite #

You need to install the Treesitter markdown and markdown_inline parser. If you are not sure if you have them, run :checkhealth.

Why? Unlike the built-in hover, vim.lsp.buf.hover, which uses regex syntax to render markdown, Lspsaga uses treesitter.

Default Options #

Default options in hover section:

  • max_width = 0.9 defines float window width
  • max_height = 0.8 defines float window height
  • open_link = 'gx' key for opening links
  • open_cmd = '!chrome' cmd for opening links

Advanced Configuration #

Lspsaga hover support opening external links in hover window. The default keybinding is gx. The default command is !open on Mac, !explorer on Windows, !wslview on WSL, and !xdg-open on Linux. If these commands are not found, Lspsaga will use open_cmd.

Open links in hover window

Workflow in GIF:

  • Press K to open Lspsaga hover
  • Press k twice to jump into the hover window and view the doc
  • Press gx

Highlight Group #

  • HoverNormal hover window normal highlight
  • HoverBorder hover window border highlight