From 474e62d942d3cc228c20a067ab22f1639eb504d2 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Thu, 21 Nov 2024 14:31:45 +0530 Subject: [PATCH] nvim: lsp: offset_encoding is now a required parameter See https://github.com/neovim/neovim/commit/629483e24eed3f2c07e55e0540c553361e0345a2 --- nvim/.config/nvim/lua/lsp.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/nvim/.config/nvim/lua/lsp.lua b/nvim/.config/nvim/lua/lsp.lua index 4e552d2..40ddfd2 100644 --- a/nvim/.config/nvim/lua/lsp.lua +++ b/nvim/.config/nvim/lua/lsp.lua @@ -11,8 +11,13 @@ local preview_location_callback = function(_, result) end local peek_definition = function() - local params = vim.lsp.util.make_position_params() - return vim.lsp.buf_request(0, 'textDocument/definition', params, preview_location_callback) + local bufnr = vim.api.nvim_get_current_buf() + local clients = vim.lsp.get_clients({ bufnr = bufnr }) + + if next(clients) then + local params = vim.lsp.util.make_position_params(0, clients[1].offset_encoding) + return vim.lsp.buf_request(bufnr, 'textDocument/definition', params, preview_location_callback) + end end local inlay_hint_toggle = function() @@ -206,7 +211,7 @@ local on_attach = function(client_id, client, bufnr) local lsp_diagnostics = vim.lsp.diagnostic.from(vim.diagnostic.get(bufnr, diag_opts)) local context = { diagnostics = lsp_diagnostics } - local params = lsp_util.make_range_params() + local params = lsp_util.make_range_params(0, client.offset_encoding) params.context = context vim.lsp.buf_request(bufnr, 'textDocument/codeAction', params, function(err, result, ctx, config)