summaryrefslogtreecommitdiff
path: root/lua/lsp/handlers.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/lsp/handlers.lua')
-rw-r--r--lua/lsp/handlers.lua44
1 files changed, 43 insertions, 1 deletions
diff --git a/lua/lsp/handlers.lua b/lua/lsp/handlers.lua
index d3a487ae..2322e76a 100644
--- a/lua/lsp/handlers.lua
+++ b/lua/lsp/handlers.lua
@@ -5,10 +5,52 @@ local M = {}
function M.setup()
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = lvim.lsp.diagnostics.virtual_text,
- signs = lvim.lsp.diagnostics.signs,
+ signs = lvim.lsp.diagnostics.signs.active,
underline = lvim.lsp.document_highlight,
})
+ vim.lsp.handlers["textDocument/publishDiagnostics"] = function(_, _, params, client_id, _)
+ local config = { -- your config
+ virtual_text = lvim.lsp.diagnostics.virtual_text,
+ signs = lvim.lsp.diagnostics.signs,
+ underline = lvim.lsp.diagnostics.underline,
+ update_in_insert = lvim.lsp.diagnostics.update_in_insert,
+ severity_sort = lvim.lsp.diagnostics.severity_sort,
+ }
+ local uri = params.uri
+ local bufnr = vim.uri_to_bufnr(uri)
+
+ if not bufnr then
+ return
+ end
+
+ local diagnostics = params.diagnostics
+
+ for i, v in ipairs(diagnostics) do
+ local source = v.source
+ if source then
+ if string.find(source, "/") then
+ source = string.sub(v.source, string.find(v.source, "([%w-_]+)$"))
+ end
+ diagnostics[i].message = string.format("%s: %s", source, v.message)
+ else
+ diagnostics[i].message = string.format("%s", v.message)
+ end
+
+ if vim.tbl_contains(vim.tbl_keys(v), "code") then
+ diagnostics[i].message = diagnostics[i].message .. string.format(" [%s]", v.code)
+ end
+ end
+
+ vim.lsp.diagnostic.save(diagnostics, bufnr, client_id)
+
+ if not vim.api.nvim_buf_is_loaded(bufnr) then
+ return
+ end
+
+ vim.lsp.diagnostic.display(diagnostics, bufnr, client_id, config)
+ end
+
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
border = lvim.lsp.popup_border,
})