make diagnostics open float on hold

This commit is contained in:
gnat 2024-10-24 17:22:28 -07:00
parent a66ee46a7c
commit cddf200122
2 changed files with 8 additions and 10 deletions

View File

@ -24,10 +24,8 @@ vim.diagnostic.config({
}, },
float = { float = {
max_width = math.min(math.floor(vim.o.columns * 0.7), 100),
max_height = math.min(math.floor(vim.o.lines * 0.3), 30),
border = border_style, border = border_style,
title = { { '', 'DiagnosticFloatTitleIcon' }, { 'Problems ', 'DiagnosticFloatTitle' } }, title = { { 'lsp diagnostics', 'DiagnosticFloatTitleIcon' }, { 'Problems ', 'DiagnosticFloatTitle' } },
focusable = false, focusable = false,
scope = 'line', scope = 'line',
source = 'if_many', source = 'if_many',
@ -39,6 +37,13 @@ vim.diagnostic.config({
}, },
}) })
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
group = vim.api.nvim_create_augroup("float_diagnostic", { clear = true }),
callback = function ()
vim.diagnostic.open_float()
end
})
for severity, icon in pairs(signs) do for severity, icon in pairs(signs) do
local hl = "DiagnosticSign" .. capitalize_head(vim.diagnostic.severity[severity]) local hl = "DiagnosticSign" .. capitalize_head(vim.diagnostic.severity[severity])
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })

View File

@ -36,13 +36,6 @@ local handlers = {
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {border = border, focus = false}), ["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {border = border, focus = false}),
} }
-- vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
-- group = vim.api.nvim_create_augroup("float_diagnostic", { clear = true }),
-- callback = function ()
-- vim.lsp.buf.hover(nil, {focus=false, scope='line'})
-- end
-- })
return { return {
event={ "VeryLazy" }, event={ "VeryLazy" },
'neovim/nvim-lspconfig', 'neovim/nvim-lspconfig',