plugins/lsp: simplify implementation of inlayHints

This commit is contained in:
Gaetan Lepage 2025-04-26 19:35:31 +02:00
parent b72ba2e4e2
commit 2e559d3c3a

View file

@ -113,8 +113,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
type = types.bool; type = types.bool;
default = false; default = false;
description = '' description = ''
Whether to enable LSP inlay-hints. Whether to enable LSP inlay-hints globally.
Only affects language servers with inlay-hints support.
See [`:h lsp-inlay_hint`](https://neovim.io/doc/user/lsp.html#lsp-inlay_hint). See [`:h lsp-inlay_hint`](https://neovim.io/doc/user/lsp.html#lsp-inlay_hint).
''; '';
@ -189,14 +188,6 @@ lib.nixvim.plugins.mkNeovimPlugin {
# being properly configured (missing some keys: `cmd`, `filetypes`, `root_markers` etc.) # being properly configured (missing some keys: `cmd`, `filetypes`, `root_markers` etc.)
performance.combinePlugins.standalonePlugins = [ cfg.package ]; performance.combinePlugins.standalonePlugins = [ cfg.package ];
plugins.lsp.onAttach = lib.mkIf cfg.inlayHints ''
-- LSP Inlay Hints {{{
if client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
end
-- }}}
'';
plugins.lsp.luaConfig.content = plugins.lsp.luaConfig.content =
let let
runWrappers = runWrappers =
@ -227,6 +218,9 @@ lib.nixvim.plugins.mkNeovimPlugin {
do do
${cfg.preConfig} ${cfg.preConfig}
-- inlay hint
${lib.optionalString cfg.inlayHints "vim.lsp.inlay_hint.enable(true)"}
local __lspServers = ${lib.nixvim.toLuaObject cfg.enabledServers} local __lspServers = ${lib.nixvim.toLuaObject cfg.enabledServers}
-- Adding lspOnAttach function to nixvim module lua table so other plugins can hook into it. -- Adding lspOnAttach function to nixvim module lua table so other plugins can hook into it.
_M.lspOnAttach = function(client, bufnr) _M.lspOnAttach = function(client, bufnr)