diff options
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r-- | runtime/lua/vim/lsp/codelens.lua | 8 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/diagnostic.lua | 9 |
2 files changed, 10 insertions, 7 deletions
diff --git a/runtime/lua/vim/lsp/codelens.lua b/runtime/lua/vim/lsp/codelens.lua index 46e2078507..fe581e42ad 100644 --- a/runtime/lua/vim/lsp/codelens.lua +++ b/runtime/lua/vim/lsp/codelens.lua @@ -123,7 +123,7 @@ function M.display(lenses, bufnr, client_id) end end if #chunks > 0 then - api.nvim_buf_set_virtual_text(bufnr, ns, i, chunks, {}) + api.nvim_buf_set_extmark(bufnr, ns, i, 0, { virt_text = chunks }) end end end @@ -179,12 +179,12 @@ local function resolve_lenses(lenses, bufnr, client_id, callback) -- Eager display to have some sort of incremental feedback -- Once all lenses got resolved there will be a full redraw for all lenses -- So that multiple lens per line are properly displayed - api.nvim_buf_set_virtual_text( + api.nvim_buf_set_extmark( bufnr, ns, lens.range.start.line, - {{ lens.command.title, 'LspCodeLens' },}, - {} + 0, + { virt_text = {{ lens.command.title, 'LspCodeLens' }} } ) end countdown() diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua index 120320becc..5efd8d74a7 100644 --- a/runtime/lua/vim/lsp/diagnostic.lua +++ b/runtime/lua/vim/lsp/diagnostic.lua @@ -766,17 +766,20 @@ function M.set_virtual_text(diagnostics, bufnr, client_id, diagnostic_ns, opts) local virt_texts = M.get_virtual_text_chunks_for_line(bufnr, line, line_diagnostics, opts) if virt_texts then - api.nvim_buf_set_virtual_text(bufnr, diagnostic_ns, line, virt_texts, {}) + api.nvim_buf_set_extmark(bufnr, diagnostic_ns, line, 0, { + virt_text = virt_texts, + }) end end end ---- Default function to get text chunks to display using `nvim_buf_set_virtual_text`. +--- Default function to get text chunks to display using |nvim_buf_set_extmark()|. ---@param bufnr number The buffer to display the virtual text in ---@param line number The line number to display the virtual text on ---@param line_diags Diagnostic[] The diagnostics associated with the line ---@param opts table See {opts} from |vim.lsp.diagnostic.set_virtual_text()| ----@return table chunks, as defined by |nvim_buf_set_virtual_text()| +---@return an array of [text, hl_group] arrays. This can be passed directly to +--- the {virt_text} option of |nvim_buf_set_extmark()|. function M.get_virtual_text_chunks_for_line(bufnr, line, line_diags, opts) assert(bufnr or line) |