plugins/lsp: add inlay-hint option

`onAttach` code is based on [this comment](https://github.com/lvimuser/lsp-inlayhints.nvim/issues/46#issuecomment-1949916683).

Documented upstream at [`:h lsp-inlay_hint`](https://neovim.io/doc/user/lsp.html#lsp-inlay_hint)
This commit is contained in:
Matt Sturgeon 2024-03-23 17:03:15 +00:00
parent 70088f6f89
commit 4a22c35e6d
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
2 changed files with 16 additions and 0 deletions

View file

@ -112,6 +112,12 @@ in
visible = false;
};
inlayHints = mkEnableOption ''
LSP inlay-hints. Only affects language servers with inlay-hints support.
See [`:h lsp-inlay_hint`](https://neovim.io/doc/user/lsp.html#lsp-inlay_hint).
'';
onAttach = mkOption {
type = types.lines;
description = "A lua function to be run when a new LSP buffer is attached. The argument `client` and `bufnr` is provided.";
@ -196,6 +202,15 @@ in
++ (mkMaps "vim.lsp.buf." cfg.keymaps.lspBuf)
++ cfg.keymaps.extra;
# Enable inlay-hints
plugins.lsp.onAttach = mkIf cfg.inlayHints ''
-- LSP Inlay Hints {{{
if client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then
vim.lsp.inlay_hint.enable(bufnr, true)
end
-- }}}
'';
# Enable all LSP servers
extraConfigLua = ''
-- LSP {{{

View file

@ -7,6 +7,7 @@
example = {
plugins.lsp = {
enable = true;
inlayHints = true;
keymaps = {
silent = true;