Update diagnostic messages

This commit is contained in:
2023-09-19 16:25:09 +02:00
parent 2d3526b0d0
commit 39a2651693
+18 -59
View File
@@ -58,69 +58,37 @@ local function ca_rename()
end end
end end
function P._setup_diagnostic() function P._setup_diagnostics()
-- https://github.com/neovim/nvim-lspconfig/wiki/UI-Customization#customizing-how-diagnostics-are-displayed
vim.diagnostic.config({ vim.diagnostic.config({
underline = true, underline = true,
signs = true, signs = true,
virtual_text = false, virtual_text = {
-- virtual_text = { prefix = "",
-- format = function(diagnostic) format = function (diagnostic)
-- return string.format("%s: %s", diagnostic.user_data.lsp.code, diagnostic.message) return diagnostic.message
-- end end,
-- }, },
float = { float = {
show_header = false, show_header = false,
source = "if_many", source = "always",
border = "rounded", border = "rounded",
focusable = false, focusable = false,
format = function (diagnostic) format = function (diagnostic)
return string.format("%s", diagnostic.message) return string.format("%s", diagnostic.message)
end, end,
}, },
update_in_insert = false, -- default to false update_in_insert = false,
severity_sort = true, -- default to false severity_sort = false,
}) })
-- Change diagnostic icons local signs = { Error = "󰅚 ", Warn = "󰀪 ", Hint = "󰌶 ", Info = "", }
vim.fn.sign_define("DiagnosticSignError", { for type, icon in pairs(signs) do
text = "E", local hl = "DiagnosticSign" .. type
texthl = "DiagnosticSignError", vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl, })
-- culhl = 'DiagnosticSignError', end
numhl = "DiagnosticSignError",
-- linehl = 'LspDiagnosticsUnderlineError'
})
vim.fn.sign_define("DiagnosticSignWarn", {
text = "W",
texthl = "DiagnosticSignWarn",
-- culhl = 'DiagnosticSignWarn',
numhl = "DiagnosticSignWarn",
-- linehl = 'LspDiagnosticsUnderlineWarning'
})
vim.fn.sign_define("DiagnosticSignHint", {
text = "H",
texthl = "DiagnosticSignHint",
-- culhl = 'DiagnosticSignHint',
numhl = "DiagnosticSignHint",
-- linehl = 'LspDiagnosticsUnderlineHint'
})
vim.fn.sign_define("DiagnosticSignInfo", {
text = "i",
texthl = "DiagnosticSignInfo",
-- culhl = 'DiagnosticSignInfo',
numhl = "DiagnosticSignInfo",
-- linehl = 'LspDiagnosticsUnderlineInfo'
})
-- Change some highlights
-- vim.cmd('highlight DiagnosticUnderlineError guifg=' .. utils.get_hl('DiagnosticError').foreground)
-- vim.cmd('highlight DiagnosticUnderlineWarn guifg=' .. utils.get_hl('DiagnosticWarn').foreground)
end end
function P.on_attach(client, bufnr) function P.on_attach(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
-- Disabled in favor of nvim-cmp
-- vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings. -- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions -- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { silent = true, buffer = bufnr, } local opts = { silent = true, buffer = bufnr, }
@@ -145,8 +113,6 @@ function P.on_attach(client, bufnr)
end, end,
opts opts
) )
-- if client.server_capabilities.document_range_formatting then
-- end
-- The below command will highlight the current variable and its usages in the buffer. -- The below command will highlight the current variable and its usages in the buffer.
if client.server_capabilities.document_highlight then if client.server_capabilities.document_highlight then
@@ -163,14 +129,7 @@ function P.on_attach(client, bufnr)
callback = vim.lsp.buf.clear_references, callback = vim.lsp.buf.clear_references,
}) })
end end
-- Auto show current line diagnostics after 300 ms
-- vim.cmd('autocmd CursorHold <buffer> lua vim.diagnostic.open_float({ scope = "line" })')
-- vim.api.nvim_create_autocmd("CursorHold", {
-- buffer = bufnr,
-- callback = function()
-- vim.diagnostic.open_float({ scope = "line" })
-- end
-- })
vim.opt.updatetime = 100 vim.opt.updatetime = 100
end end
@@ -311,7 +270,7 @@ function P.setup_server(self, name)
end end
function P.setup(self) function P.setup(self)
self._setup_diagnostic() self._setup_diagnostics()
utils.try_require("cmp_nvim_lsp", package_name, function (mod) utils.try_require("cmp_nvim_lsp", package_name, function (mod)
P.capabilities = mod.default_capabilities() P.capabilities = mod.default_capabilities()