From 7a4b71f0867ac82774b9f36df73a66e3266f15a3 Mon Sep 17 00:00:00 2001 From: Garrett Dawson Date: Mon, 3 Apr 2023 08:53:04 -0600 Subject: [PATCH] fix: improve diagnostics --- after/plugin/defaults.lua | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/after/plugin/defaults.lua b/after/plugin/defaults.lua index 6cf72926..60b41a22 100644 --- a/after/plugin/defaults.lua +++ b/after/plugin/defaults.lua @@ -39,13 +39,29 @@ vim.keymap.set('v', '', ":m '>+1gv=gv", { noremap = true, desc = 'Bubbl vim.o.inccommand = "nosplit" vim.diagnostic.config({ - virtual_text = { - -- source = "always", -- Or "if_many" - prefix = '●', -- Could be '■', '▎', 'x' - }, severity_sort = true, + virtual_text = { + source = false, + prefix = '●', + format = function() + return "" + end, + }, float = { - source = "always", -- Or "if_many" + source = "always", + -- close_events = { 'BufLeave', 'CursorMoved', 'InsertEnter', 'FocusLost' }, + format = function(diagnostic) + if diagnostic.source == 'eslint' then + return string.format( + '%s [%s]', + diagnostic.message, + -- shows the name of the rule + diagnostic.user_data.lsp.code + ) + end + + return string.format('%s [%s]', diagnostic.message, diagnostic.source) + end, }, }) @@ -56,6 +72,8 @@ for type, icon in pairs(signs) do end -- null-ls +-- @see: https://github.com/jay-babu/mason-null-ls.nvim +-- might want to just use mason-null-ls. not yet sure what the advantage is. local null_ls = require("null-ls")