diff options
| author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-11-17 12:14:45 -0800 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-17 21:14:45 +0100 | 
| commit | eb3d59126eff50c64c2108e308884a722e7ee32e (patch) | |
| tree | e8daf04427e84203e914675991a73669fe10335f /runtime/lua/vim/lsp/util.lua | |
| parent | c0efe49e78eca3a17a5934cc283199122d081467 (diff) | |
| download | rneovim-eb3d59126eff50c64c2108e308884a722e7ee32e.tar.gz rneovim-eb3d59126eff50c64c2108e308884a722e7ee32e.tar.bz2 rneovim-eb3d59126eff50c64c2108e308884a722e7ee32e.zip  | |
fix(lsp): change signature of buf_highlight_references (#16345)
the prior signature did not assume an active language client
this function can now be used directly by passing an offset encoding
defaults to utf-16 (standard for LSP)
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
| -rw-r--r-- | runtime/lua/vim/lsp/util.lua | 12 | 
1 files changed, 5 insertions, 7 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index a4b7b9922b..ba5c20ef9f 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -1341,19 +1341,17 @@ do --[[ References ]]    ---    ---@param bufnr buffer id    ---@param references List of `DocumentHighlight` objects to highlight +  ---@param offset_encoding string utf-8|utf-16|utf-32|nil defaults to utf-16    ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#documentHighlight -  function M.buf_highlight_references(bufnr, references, client_id) +  function M.buf_highlight_references(bufnr, references, offset_encoding)      validate { bufnr = {bufnr, 'n', true} } -    local client = vim.lsp.get_client_by_id(client_id) -    if not client then -      return -    end +    offset_encoding = offset_encoding or 'utf-16'      for _, reference in ipairs(references) do        local start_line, start_char = reference["range"]["start"]["line"], reference["range"]["start"]["character"]        local end_line, end_char = reference["range"]["end"]["line"], reference["range"]["end"]["character"] -      local start_idx = get_line_byte_from_position(bufnr, { line = start_line, character = start_char }, client.offset_encoding) -      local end_idx = get_line_byte_from_position(bufnr, { line = start_line, character = end_char }, client.offset_encoding) +      local start_idx = get_line_byte_from_position(bufnr, { line = start_line, character = start_char }, offset_encoding) +      local end_idx = get_line_byte_from_position(bufnr, { line = start_line, character = end_char }, offset_encoding)        local document_highlight_kind = {          [protocol.DocumentHighlightKind.Text] = "LspReferenceText";  | 
