feat(nvim): add lsp inlay hints

nixos
Moritz Böhme 2023-08-11 19:00:43 +02:00
parent 1566dc84f4
commit d6b95fdef6
Signed by: moritz
GPG Key ID: 970C6E89EB0547A9
1 changed files with 14 additions and 2 deletions

View File

@ -54,7 +54,7 @@ capabilities.textDocument.foldingRange = {
require("ufo").setup() require("ufo").setup()
local lspconfig = require("lspconfig") local lspconfig = require("lspconfig")
local on_attach_def = function(_, bufnr) local on_attach_def = function(client, bufnr)
require("which-key").register({ require("which-key").register({
K = { vim.lsp.buf.hover, "Hover" }, K = { vim.lsp.buf.hover, "Hover" },
["<leader>"] = { ["<leader>"] = {
@ -71,7 +71,13 @@ local on_attach_def = function(_, bufnr)
}, },
}, },
t = { t = {
l = { lsp_lines.toggle, "Lsp lines" }, l = { lsp_lines.toggle, "LSP lines" },
i = {
function()
vim.lsp.inlay_hint(bufnr, nil)
end,
"LSP inlay hints",
},
}, },
}, },
g = { g = {
@ -99,6 +105,12 @@ local on_attach_def = function(_, bufnr)
d = { vim.diagnostic.goto_next, "Next diagnostic" }, d = { vim.diagnostic.goto_next, "Next diagnostic" },
}, },
}, { buffer = bufnr, silent = true }) }, { buffer = bufnr, silent = true })
if client.server_capabilities.inlayHintProvider then
vim.defer_fn(function()
vim.lsp.inlay_hint(bufnr, true)
end, 1000)
end
end end
local lspconfig_default_options = { local lspconfig_default_options = {