summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/lsp/handlers.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/lsp/handlers.lua')
-rw-r--r--.config/nvim/lua/lsp/handlers.lua86
1 files changed, 47 insertions, 39 deletions
diff --git a/.config/nvim/lua/lsp/handlers.lua b/.config/nvim/lua/lsp/handlers.lua
index c869d79..e273261 100644
--- a/.config/nvim/lua/lsp/handlers.lua
+++ b/.config/nvim/lua/lsp/handlers.lua
@@ -3,61 +3,69 @@
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
+ 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,
- underline = options.lsp.diagnostics.underline,
- update_in_insert = options.lsp.diagnostics.update_in_insert,
- severity_sort = options.lsp.diagnostics.severity_sort,
+ signs = options.lsp.diagnostics.signs.active,
+ underline = options.lsp.document_highlight,
}
- local uri = params.uri
- local bufnr = vim.uri_to_bufnr(uri)
+ )
- if not bufnr then
- return
- end
+ 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)
- local diagnostics = params.diagnostics
+ if not bufnr then
+ return
+ end
- 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-_]+)$"))
+ 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
- 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)
+ if vim.tbl_contains(vim.tbl_keys(v), "code") then
+ diagnostics[i].message = diagnostics[i].message
+ .. string.format(" [%s]", v.code)
+ end
end
- end
- vim.lsp.diagnostic.save(diagnostics, bufnr, client_id)
+ vim.lsp.diagnostic.save(diagnostics, bufnr, client_id)
- if not vim.api.nvim_buf_is_loaded(bufnr) then
- return
- end
+ if not vim.api.nvim_buf_is_loaded(bufnr) then
+ return
+ end
- vim.lsp.diagnostic.display(diagnostics, bufnr, client_id, config)
- 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,
- })
+ vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
+ vim.lsp.handlers.signature_help,
+ {
+ border = options.lsp.popup_border,
+ }
+ )
end
return M