diff options
author | christianchiarulli <[email protected]> | 2021-09-07 19:40:40 -0400 |
---|---|---|
committer | christianchiarulli <[email protected]> | 2021-09-07 19:40:40 -0400 |
commit | 8c83b403ef833101a93b53cc232368424b3dff9b (patch) | |
tree | 4205a61adbdcacbf233bde5e28aaa6fd0dd75a18 /lua/lsp | |
parent | 9ece2e5369de46962422837be3dce3b8e889805d (diff) |
fix: vim.uri bug in 0.6
Diffstat (limited to 'lua/lsp')
-rw-r--r-- | lua/lsp/handlers.lua | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/lua/lsp/handlers.lua b/lua/lsp/handlers.lua index ae06116e..2efa8d10 100644 --- a/lua/lsp/handlers.lua +++ b/lua/lsp/handlers.lua @@ -9,29 +9,43 @@ function M.setup() 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) + 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, + } + if vim.fn.has "nvim-0.5.1" > 0 then + vim.lsp.handlers["textDocument/publishDiagnostics"] = function(_, result, ctx, _) + local uri = result.uri + local bufnr = ctx.bufnr + if not bufnr then + return + end - if not bufnr then - return + local diagnostics = result.diagnostics + vim.lsp.diagnostic.save(diagnostics, ctx.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 + else + vim.lsp.handlers["textDocument/publishDiagnostics"] = function(_, _, params, client_id, _) + local uri = params.uri + local bufnr = vim.uri_to_bufnr(uri) + if not bufnr then + return + end - local diagnostics = params.diagnostics - - vim.lsp.diagnostic.save(diagnostics, bufnr, client_id) - - if not vim.api.nvim_buf_is_loaded(bufnr) then - return + local diagnostics = params.diagnostics + 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.diagnostic.display(diagnostics, bufnr, client_id, config) end vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { |