nvim: Update lsp diagnostics keys
Can show hide diagnostics, virtual text and virtual lines independently.
This commit is contained in:
parent
642d422007
commit
96cab3d9a6
1 changed files with 16 additions and 5 deletions
|
|
@ -51,7 +51,6 @@ local lsp = {
|
|||
vim.fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" })
|
||||
|
||||
for server, config in pairs(lspconfig_opts.servers) do
|
||||
-- TODO: Check if it actually can be ignored in Nvim 0.11+, see https://cmp.saghen.dev/installation.html#lazy-nvim
|
||||
if vim.fn.has("nvim-0.11") == false then
|
||||
config.capabilities = require("blink.cmp").get_lsp_capabilities(config.capabilities)
|
||||
end
|
||||
|
|
@ -206,16 +205,28 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
|||
require("which-key").add({ "<localleader>l", group = "language" })
|
||||
end
|
||||
map("n", "<localleader>ld", "<cmd>lua vim.diagnostic.open_float()<cr>", o({ desc = "Show line diagnostics" }))
|
||||
map("n", "<localleader>lI", function()
|
||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
|
||||
end, o({ desc = "Toggle inlay hints" }))
|
||||
map("n", "<localleader>la", "<cmd>lua vim.lsp.buf.code_action()<cr>", o({ desc = "Codeactions" }))
|
||||
map("n", "<localleader>ln", "<cmd>lua vim.lsp.buf.rename()<cr>", o({ desc = "Rename element" }))
|
||||
map("n", "<localleader>lc", "<cmd>lua vim.lsp.buf.declaration()<cr>", o({ desc = "Declaration" }))
|
||||
map("n", "<localleader>ls", "<cmd>lua vim.lsp.buf.signature_help()<cr>", o({ desc = "Signature help" }))
|
||||
map("n", "<localleader>lo", function()
|
||||
|
||||
map("n", "<localleader>lI", function()
|
||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
|
||||
end, o({ desc = "Toggle inlay hints" }))
|
||||
map("n", "<localleader>lD", function()
|
||||
vim.diagnostic.enable(not vim.diagnostic.is_enabled())
|
||||
end, o({ desc = "Toggle Diagnostics" }))
|
||||
-- FIXME: Will be re-enabled with insert-mode autocmd above
|
||||
map("n", "<localleader>lo", function()
|
||||
local c = vim.diagnostic.config() or {}
|
||||
vim.diagnostic.config({ virtual_text = not c["virtual_text"] })
|
||||
end, o({ desc = "Toggle virtual diag text" }))
|
||||
if vim.fn.has("nvim-0.11") == true then -- new feature https://gpanders.com/blog/whats-new-in-neovim-0-11/#virtual-lines
|
||||
map("n", "<localleader>lO", function()
|
||||
local c = vim.diagnostic.config() or {}
|
||||
vim.diagnostic.config({ virtual_lines = not c["virtual_lines"] })
|
||||
end, o({ desc = "Toggle virtual diag lines" }))
|
||||
end
|
||||
|
||||
local pref = function(glances, telescope, fallback)
|
||||
if glances and vim.fn.exists(":Glance") > 0 then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue