diff options
| author | jdhao <jdhao@hotmail.com> | 2021-11-06 12:52:45 +0800 |
|---|---|---|
| committer | jdhao <jdhao@hotmail.com> | 2021-11-06 12:56:54 +0800 |
| commit | ffe588870d3325bf1e7d6a7d33009de0d2bee6e6 (patch) | |
| tree | e2d4ff566bde5f798fcfd1e8140e515d0f7ee42e /lua/config | |
| parent | 002ebf2f719ecfc6882108d79be421ded711e5bf (diff) | |
[breaking change] make it work for nvim 0.5.1
In nvim 0.5.1, the lsp handler signature has changed, see https://github.com/neovim/neovim/pull/15504
and LunarVim/LunarVim#1484.
Diffstat (limited to 'lua/config')
| -rw-r--r-- | lua/config/lsp.lua | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua index 7cc8062..7c92df4 100644 --- a/lua/config/lsp.lua +++ b/lua/config/lsp.lua @@ -166,10 +166,14 @@ vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagn }) -- Refs: https://github.com/neovim/nvim-lspconfig/wiki/UI-customization#show-source-in-diagnostics -vim.lsp.handlers["textDocument/publishDiagnostics"] = function(_, _, params, client_id, _) - local uri = params.uri - local bufnr = vim.uri_to_bufnr(uri) +vim.lsp.handlers["textDocument/publishDiagnostics"] = function(_, result, context, _) + -- result contains diagnostics and uri + -- context contains client_id and method, but not always buf_nr + local client_id = context.client_id + local diagnostics = result.diagnostics + local uri = result.uri + local bufnr = vim.uri_to_bufnr(uri) if not bufnr then return end @@ -178,7 +182,7 @@ vim.lsp.handlers["textDocument/publishDiagnostics"] = function(_, _, params, cli return end - local diagnostics = params.diagnostics + -- change diagnostics format for i, v in ipairs(diagnostics) do diagnostics[i].message = string.format("%s: %s", v.source, v.message) end |
