From cddf200122381f1f74fdde238f09ca62f12b8037 Mon Sep 17 00:00:00 2001 From: gnat Date: Thu, 24 Oct 2024 17:22:28 -0700 Subject: [PATCH] make diagnostics open float on hold --- lua/core/diagnostics.lua | 11 ++++++++--- lua/plugins/nvim-lspconfig.lua | 7 ------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lua/core/diagnostics.lua b/lua/core/diagnostics.lua index 4af031c..9ba4eb4 100644 --- a/lua/core/diagnostics.lua +++ b/lua/core/diagnostics.lua @@ -24,10 +24,8 @@ vim.diagnostic.config({ }, 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, - title = { { '  ', 'DiagnosticFloatTitleIcon' }, { 'Problems ', 'DiagnosticFloatTitle' } }, + title = { { 'lsp diagnostics', 'DiagnosticFloatTitleIcon' }, { 'Problems ', 'DiagnosticFloatTitle' } }, focusable = false, scope = 'line', 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 local hl = "DiagnosticSign" .. capitalize_head(vim.diagnostic.severity[severity]) vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) diff --git a/lua/plugins/nvim-lspconfig.lua b/lua/plugins/nvim-lspconfig.lua index 293d99e..348786e 100644 --- a/lua/plugins/nvim-lspconfig.lua +++ b/lua/plugins/nvim-lspconfig.lua @@ -36,13 +36,6 @@ local handlers = { ["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 { event={ "VeryLazy" }, 'neovim/nvim-lspconfig',