1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
-- Set Default Prefix.
-- Note: You can set a prefix per lsp server in the lv-globals.lua file
local M = {}
function M.setup()
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics,
{
virtual_text = options.lsp.diagnostics.virtual_text,
signs = options.lsp.diagnostics.signs.active,
underline = options.lsp.document_highlight,
}
)
vim.lsp.handlers["textDocument/publishDiagnostics"] =
function(_, _, params, client_id, _)
local config = { -- your config
virtual_text = options.lsp.diagnostics.virtual_text,
signs = options.lsp.diagnostics.signs,
underline = options.lsp.diagnostics.underline,
update_in_insert = options.lsp.diagnostics.update_in_insert,
severity_sort = options.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 = options.lsp.popup_border,
})
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
vim.lsp.handlers.signature_help,
{
border = options.lsp.popup_border,
}
)
end
return M
|