diff options
author | Riley Bruins <ribru17@hotmail.com> | 2024-11-17 12:31:32 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-17 12:31:32 -0800 |
commit | 44229bb85b6cff00193164967126d85a7a785a7b (patch) | |
tree | 04a8b7cef4bbed61e43b6284c34bff9ed901cc00 /runtime/doc | |
parent | 235cb5bc5f2553f5a46807267b8705e53f7a14af (diff) | |
download | rneovim-44229bb85b6cff00193164967126d85a7a785a7b.tar.gz rneovim-44229bb85b6cff00193164967126d85a7a785a7b.tar.bz2 rneovim-44229bb85b6cff00193164967126d85a7a785a7b.zip |
feat(lsp): highlight hover target/range #31110
**Problem:** Despite the LSP providing the option for language servers
to specify a range with a hover response (for highlighting), Neovim does
not give the option to highlight this range.
**Solution:** Add an option to `buf.hover()` which causes this range to
be highlighted.
Co-authored-by: Mathias Fußenegger <mfussenegger@users.noreply.github.com>
Diffstat (limited to 'runtime/doc')
-rw-r--r-- | runtime/doc/lsp.txt | 19 | ||||
-rw-r--r-- | runtime/doc/news.txt | 2 |
2 files changed, 17 insertions, 4 deletions
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index a7d6844dd4..7d50cb52eb 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -338,13 +338,16 @@ Highlight groups that are meant to be used by |vim.lsp.buf.document_highlight()| You can see more about the differences in types here: https://microsoft.github.io/language-server-protocol/specification#textDocument_documentHighlight - *hl-LspReferenceText* + *hl-LspReferenceText* LspReferenceText used for highlighting "text" references - *hl-LspReferenceRead* + *hl-LspReferenceRead* LspReferenceRead used for highlighting "read" references - *hl-LspReferenceWrite* + *hl-LspReferenceWrite* LspReferenceWrite used for highlighting "write" references - *hl-LspInlayHint* + *hl-LspReferenceTarget* +LspReferenceTarget used for highlighting reference targets (e.g. in a + hover range) + *hl-LspInlayHint* LspInlayHint used for highlighting inlay hints @@ -1335,6 +1338,14 @@ hover({config}) *vim.lsp.buf.hover()* mappings are available as usual, except that "q" dismisses the window. You can scroll the contents the same as you would any other buffer. + Note: to disable hover highlights, add the following to your config: >lua + vim.api.nvim_create_autocmd('ColorScheme', { + callback = function() + vim.api.nvim_set_hl(0, 'LspReferenceTarget', {}) + end, + }) +< + Parameters: ~ • {config} (`vim.lsp.buf.hover.Opts?`) See |vim.lsp.buf.hover.Opts|. diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index fc714526d4..d19df84023 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -216,6 +216,8 @@ LSP • |vim.lsp.buf.signature_help()| can now cycle through different signatures using `<C-s>` and also support multiple clients. • The client now supports `'utf-8'` and `'utf-32'` position encodings. +• |vim.lsp.buf.hover()| now highlights hover ranges using the + |hl-LspReferenceTarget| highlight group. LUA |