diff options
author | kylo252 <[email protected]> | 2021-12-13 17:58:35 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-12-13 17:58:35 +0100 |
commit | 6cf21e9ddec41addf01744176afb2e138b3e1b3f (patch) | |
tree | 4abf843da0e2ed38689c872694b13d7418536106 /lua/lvim/lsp/handlers.lua | |
parent | 3a2d62ed2510ca05eb6ea87240a86df82338f5aa (diff) | |
parent | b09ada89402e668ea1636bdbf671a89330199717 (diff) |
Merge LunarVim/release-candidate
Diffstat (limited to 'lua/lvim/lsp/handlers.lua')
-rw-r--r-- | lua/lvim/lsp/handlers.lua | 70 |
1 files changed, 20 insertions, 50 deletions
diff --git a/lua/lvim/lsp/handlers.lua b/lua/lvim/lsp/handlers.lua index 27ce8589..45f73e91 100644 --- a/lua/lvim/lsp/handlers.lua +++ b/lua/lvim/lsp/handlers.lua @@ -9,42 +9,10 @@ function M.setup() underline = lvim.lsp.diagnostics.underline, update_in_insert = lvim.lsp.diagnostics.update_in_insert, severity_sort = lvim.lsp.diagnostics.severity_sort, + float = lvim.lsp.diagnostics.float, } - if vim.fn.has "nvim-0.5.1" > 0 then - vim.lsp.handlers["textDocument/publishDiagnostics"] = function(_, result, ctx, _) - local uri = result.uri - local bufnr = vim.uri_to_bufnr(uri) - if not bufnr then - return - end - - local diagnostics = result.diagnostics - local ok, vim_diag = pcall(require, "vim.diagnostic") - if ok then - -- FIX: why can't we just use vim.diagnostic.get(buf_id)? - config.signs = true - for i, diagnostic in ipairs(diagnostics) do - local rng = diagnostic.range - diagnostics[i].lnum = rng["start"].line - diagnostics[i].end_lnum = rng["end"].line - diagnostics[i].col = rng["start"].character - diagnostics[i].end_col = rng["end"].character - end - local namespace = vim.lsp.diagnostic.get_namespace(ctx.client_id) - - vim_diag.set(namespace, bufnr, diagnostics, config) - if not vim.api.nvim_buf_is_loaded(bufnr) then - return - end - vim_diag.show(namespace, bufnr, diagnostics, config) - else - vim.lsp.diagnostic.save(diagnostics, bufnr, ctx.client_id) - if not vim.api.nvim_buf_is_loaded(bufnr) then - return - end - vim.lsp.diagnostic.display(diagnostics, bufnr, ctx.client_id, config) - end - end + if vim.fn.has "nvim-0.6" == 1 then + vim.diagnostic.config(config) else vim.lsp.handlers["textDocument/publishDiagnostics"] = function(_, _, params, client_id, _) local uri = params.uri @@ -60,27 +28,29 @@ function M.setup() end vim.lsp.diagnostic.display(diagnostics, bufnr, client_id, config) end - end - - vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { - border = lvim.lsp.popup_border, - }) - vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { - border = lvim.lsp.popup_border, - }) -end + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = lvim.lsp.popup_border, + }) -local function split_by_chunk(text, chunkSize) - local s = {} - for i = 1, #text, chunkSize do - s[#s + 1] = text:sub(i, i + chunkSize - 1) + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = lvim.lsp.popup_border, + }) end - return s end function M.show_line_diagnostics() - -- TODO: replace all this with vim.diagnostic.show_position_diagnostics() + if vim.fn.has "nvim-0.6" == 1 then + return vim.diagnostic.open_float(0, { scope = "line" }) + end + + local function split_by_chunk(text, chunkSize) + local s = {} + for i = 1, #text, chunkSize do + s[#s + 1] = text:sub(i, i + chunkSize - 1) + end + return s + end local diagnostics = vim.lsp.diagnostic.get_line_diagnostics() local severity_highlight = { "LspDiagnosticsFloatingError", |