From 16ec9365bcd0954508812e4d7152ac1ea95b0b40 Mon Sep 17 00:00:00 2001 From: Dietrich Rink Date: Sat, 10 Jun 2023 14:58:06 +0200 Subject: [PATCH] make diagnostics prettier and show them in pop-up --- basic/nvim/plugconf/lspconfig.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/basic/nvim/plugconf/lspconfig.lua b/basic/nvim/plugconf/lspconfig.lua index 2ccf4d8..8055d28 100644 --- a/basic/nvim/plugconf/lspconfig.lua +++ b/basic/nvim/plugconf/lspconfig.lua @@ -14,3 +14,27 @@ vim.api.nvim_create_autocmd('LspAttach', { vim.keymap.set('n', 'p', vim.diagnostic.goto_prev, opts) end, }) + +-- Show diagnostics in bordered pop-up +vim.diagnostic.config { virtual_text = false, float = { border = 'rounded' } } +vim.lsp.handlers['textDocument/hover'] = vim.lsp.with( + vim.lsp.handlers.hover, { border = 'rounded' } +) +vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with( + vim.lsp.handlers.signature_help, { border = 'rounded' } +) +vim.o.updatetime = 500 +vim.api.nvim_create_autocmd({'CursorHold'}, { + pattern = {'*'}, + callback = function(ev) + vim.diagnostic.open_float(nil, { focus = false }) + end, +}) + +-- Set diagnostic signs +local signs = { Error = ' ', Warning = ' ', Hint = ' ', Information = ' ' } +for type, icon in pairs(signs) do + local hl = 'DiagnosticSign' .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) +end +