diff --git a/lua/navigator/definition.lua b/lua/navigator/definition.lua index a6bed0a..56792b5 100644 --- a/lua/navigator/definition.lua +++ b/lua/navigator/definition.lua @@ -20,8 +20,7 @@ local definition_hdlr = util.mk_handler(function(err, locations, ctx, _) return end - local client = vim.lsp.get_client_by_id(ctx.client_id) - local oe = require('navigator.util').encoding() + local oe = require('navigator.util').encoding(ctx.client_id) if vim.tbl_islist(locations) then if #locations > 1 then local items = locations_to_items(locations) diff --git a/lua/navigator/dochighlight.lua b/lua/navigator/dochighlight.lua index a2aecc9..9c5344e 100644 --- a/lua/navigator/dochighlight.lua +++ b/lua/navigator/dochighlight.lua @@ -153,8 +153,7 @@ local handle_document_highlight = mk_handler(function(_, result, ctx) end) references[ctx.bufnr] = result local client_id = ctx.client_id - local client = vim.lsp.get_client_by_id(client_id) - vim.lsp.util.buf_highlight_references(ctx.bufnr, result, util.encoding()) + vim.lsp.util.buf_highlight_references(ctx.bufnr, result, util.encoding(client_id)) end) -- modify from vim-illuminate local function goto_adjent_reference(opt) @@ -246,9 +245,8 @@ local function documentHighlight() return end local client_id = ctx.client_id - local client = vim.lsp.get_client_by_id(client_id) vim.lsp.util.buf_clear_references(bufnr) - vim.lsp.util.buf_highlight_references(bufnr, result, util.encoding()) + vim.lsp.util.buf_highlight_references(bufnr, result, util.encoding(client_id)) table.sort(result, function(a, b) return before(a.range, b.range) end) diff --git a/lua/navigator/util.lua b/lua/navigator/util.lua index ad2e539..78cf6c7 100644 --- a/lua/navigator/util.lua +++ b/lua/navigator/util.lua @@ -403,6 +403,12 @@ function M.empty(t) end function M.encoding(client) + if type(client) ~= 'table' then + if client == nil then + client = 1 + end + client = vim.lsp.get_client_by_id(client) + end local oe = client.offset_encoding if oe == nil then return 'utf-8'