diff options
author | Thomas Vigouroux <tomvig38@gmail.com> | 2021-08-04 09:28:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-04 09:28:38 +0200 |
commit | 3d183596720aeab874ceb475af23e390bbe9b8a3 (patch) | |
tree | 4c9c1c645b6881941fe70e565c0a0a4a51380354 | |
parent | 545e05d2fe98683494eb972e2661e348f2c0c290 (diff) | |
parent | 2093b12b82cfe0d982c092141fd77695c98b59f3 (diff) | |
download | rneovim-3d183596720aeab874ceb475af23e390bbe9b8a3.tar.gz rneovim-3d183596720aeab874ceb475af23e390bbe9b8a3.tar.bz2 rneovim-3d183596720aeab874ceb475af23e390bbe9b8a3.zip |
Merge pull request #15257 from gpanders/remove-set_virtual_text
refactor: remove remaining references to nvim_buf_set_virtual_text
-rw-r--r-- | runtime/doc/api.txt | 3 | ||||
-rw-r--r-- | runtime/doc/lsp.txt | 9 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/codelens.lua | 8 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/diagnostic.lua | 9 | ||||
-rw-r--r-- | src/nvim/api/vim.c | 2 |
5 files changed, 18 insertions, 13 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index c525ea7a3a..dae7986fdb 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -661,8 +661,7 @@ nvim_create_namespace({name}) *nvim_create_namespace()* Creates a new namespace, or gets an existing one. Namespaces are used for buffer highlights and virtual text, - see |nvim_buf_add_highlight()| and - |nvim_buf_set_virtual_text()|. + see |nvim_buf_add_highlight()| and |nvim_buf_set_extmark()|. Namespaces can be named or anonymous. If `name` matches an existing namespace, the associated id is returned. If `name` diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index 7daab4d6f1..9624f582a9 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -538,7 +538,7 @@ Highlight groups related to |lsp-codelens| functionality. *hl-LspCodeLens* LspCodeLens Used to color the virtual text of the codelens. See - |nvim_buf_set_virtual_text()|. + |nvim_buf_set_extmark()|. LspCodeLensSeparator *hl-LspCodeLensSeparator* Used to color the seperator between two or more code lens. @@ -1376,7 +1376,8 @@ get_prev_pos({opts}) *vim.lsp.diagnostic.get_prev_pos()* *vim.lsp.diagnostic.get_virtual_text_chunks_for_line()* get_virtual_text_chunks_for_line({bufnr}, {line}, {line_diags}, {opts}) - 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()|. Parameters: ~ {bufnr} number The buffer to display the virtual @@ -1388,7 +1389,9 @@ get_virtual_text_chunks_for_line({bufnr}, {line}, {line_diags}, {opts}) |vim.lsp.diagnostic.set_virtual_text()| Return: ~ - table chunks, as defined by |nvim_buf_set_virtual_text()| + an array of [text, hl_group] arrays. This can be passed + directly to the {virt_text} option of + |nvim_buf_set_extmark()|. goto_next({opts}) *vim.lsp.diagnostic.goto_next()* Move to the next diagnostic 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) diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index bbcfe173c5..58ee53a408 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -1557,7 +1557,7 @@ void nvim_set_current_tabpage(Tabpage tabpage, Error *err) /// Creates a new namespace, or gets an existing one. /// /// Namespaces are used for buffer highlights and virtual text, see -/// |nvim_buf_add_highlight()| and |nvim_buf_set_virtual_text()|. +/// |nvim_buf_add_highlight()| and |nvim_buf_set_extmark()|. /// /// Namespaces can be named or anonymous. If `name` matches an existing /// namespace, the associated id is returned. If `name` is an empty string |