diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/api.txt | 35 | ||||
-rw-r--r-- | runtime/doc/news-0.10.txt | 2 | ||||
-rw-r--r-- | runtime/doc/news.txt | 2 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/api.lua | 51 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/api_keysets.lua | 3 | ||||
-rw-r--r-- | runtime/lua/vim/highlight.lua | 9 |
6 files changed, 34 insertions, 68 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 577329ad00..f92a69af4e 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -2758,8 +2758,6 @@ nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {opts}) • url: A URL to associate with this extmark. In the TUI, the OSC 8 control sequence is used to generate a clickable hyperlink to this URL. - • scoped: boolean (EXPERIMENTAL) enables "scoping" for the - extmark. See |nvim__win_add_ns()| Return: ~ Id of the created/updated extmark @@ -2841,41 +2839,26 @@ nvim_set_decoration_provider({ns_id}, {opts}) ["end", tick] < -nvim__win_add_ns({window}, {ns_id}) *nvim__win_add_ns()* +nvim__ns_get({ns_id}) *nvim__ns_get()* EXPERIMENTAL: this API will change in the future. - Scopes a namespace to the a window, so extmarks in the namespace will be - active only in the given window. + Get the properties for namespace Parameters: ~ - • {window} Window handle, or 0 for current window - • {ns_id} Namespace - - Return: ~ - true if the namespace was added, else false - -nvim__win_del_ns({window}, {ns_id}) *nvim__win_del_ns()* - EXPERIMENTAL: this API will change in the future. - - Unscopes a namespace (un-binds it from the given scope). - - Parameters: ~ - • {window} Window handle, or 0 for current window - • {ns_id} the namespace to remove + • {ns_id} Namespace Return: ~ - true if the namespace was removed, else false + Map defining the namespace properties, see |nvim__ns_set()| -nvim__win_get_ns({window}) *nvim__win_get_ns()* +nvim__ns_set({ns_id}, {opts}) *nvim__ns_set()* EXPERIMENTAL: this API will change in the future. - Gets the namespace scopes for a given window. + Set some properties for namespace Parameters: ~ - • {window} Window handle, or 0 for current window - - Return: ~ - a list of namespaces ids + • {ns_id} Namespace + • {opts} Optional parameters to set: + • wins: a list of windows to be scoped in ============================================================================== diff --git a/runtime/doc/news-0.10.txt b/runtime/doc/news-0.10.txt index d611eee242..bc868c1099 100644 --- a/runtime/doc/news-0.10.txt +++ b/runtime/doc/news-0.10.txt @@ -155,8 +155,6 @@ The following new features were added. • |nvim_input_mouse()| supports mouse buttons "x1" and "x2". • Added "force_crlf" option field in |nvim_open_term()|. • Added |nvim_tabpage_set_win()| to set the current window of a tabpage. - • |nvim__win_add_ns()| can bind a |namespace| to a window-local scope(s). - • Extmarks opt-in to this scoping via the `scoped` flag of |nvim_buf_set_extmark()|. • Mapping APIs now support abbreviations when mode short-name has suffix "a". • Floating windows can now show footer with new `footer` and `footer_pos` config fields. Uses |hl-FloatFooter| by default. diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 2fed1b6b29..b316cc7b04 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -83,7 +83,7 @@ The following new features were added. API -• TODO +• |nvim__ns_set()| can set properties for a namespace DEFAULTS diff --git a/runtime/lua/vim/_meta/api.lua b/runtime/lua/vim/_meta/api.lua index bb27ee4269..d91b2d08bf 100644 --- a/runtime/lua/vim/_meta/api.lua +++ b/runtime/lua/vim/_meta/api.lua @@ -100,6 +100,25 @@ function vim.api.nvim__inspect_cell(grid, row, col) end function vim.api.nvim__invalidate_glyph_cache() end --- @private +--- EXPERIMENTAL: this API will change in the future. +--- +--- Get the properties for namespace +--- +--- @param ns_id integer Namespace +--- @return vim.api.keyset.ns_opts +function vim.api.nvim__ns_get(ns_id) end + +--- @private +--- EXPERIMENTAL: this API will change in the future. +--- +--- Set some properties for namespace +--- +--- @param ns_id integer Namespace +--- @param opts vim.api.keyset.ns_opts Optional parameters to set: +--- • wins: a list of windows to be scoped in +function vim.api.nvim__ns_set(ns_id, opts) end + +--- @private --- EXPERIMENTAL: this API may change in the future. --- --- Instruct Nvim to redraw various components. @@ -144,36 +163,6 @@ function vim.api.nvim__stats() end --- @return any function vim.api.nvim__unpack(str) end ---- @private ---- EXPERIMENTAL: this API will change in the future. ---- ---- Scopes a namespace to the a window, so extmarks in the namespace will be ---- active only in the given window. ---- ---- @param window integer Window handle, or 0 for current window ---- @param ns_id integer Namespace ---- @return boolean -function vim.api.nvim__win_add_ns(window, ns_id) end - ---- @private ---- EXPERIMENTAL: this API will change in the future. ---- ---- Unscopes a namespace (un-binds it from the given scope). ---- ---- @param window integer Window handle, or 0 for current window ---- @param ns_id integer the namespace to remove ---- @return boolean -function vim.api.nvim__win_del_ns(window, ns_id) end - ---- @private ---- EXPERIMENTAL: this API will change in the future. ---- ---- Gets the namespace scopes for a given window. ---- ---- @param window integer Window handle, or 0 for current window ---- @return integer[] -function vim.api.nvim__win_get_ns(window) end - --- Adds a highlight to buffer. --- --- Useful for plugins that dynamically generate highlights to a buffer (like @@ -686,8 +675,6 @@ function vim.api.nvim_buf_line_count(buffer) end --- • url: A URL to associate with this extmark. In the TUI, the --- OSC 8 control sequence is used to generate a clickable --- hyperlink to this URL. ---- • scoped: boolean (EXPERIMENTAL) enables "scoping" for the ---- extmark. See `nvim__win_add_ns()` --- @return integer function vim.api.nvim_buf_set_extmark(buffer, ns_id, line, col, opts) end diff --git a/runtime/lua/vim/_meta/api_keysets.lua b/runtime/lua/vim/_meta/api_keysets.lua index f7cd92a3b2..2fe5c32faf 100644 --- a/runtime/lua/vim/_meta/api_keysets.lua +++ b/runtime/lua/vim/_meta/api_keysets.lua @@ -197,6 +197,9 @@ error('Cannot require a meta file') --- @field desc? string --- @field replace_keycodes? boolean +--- @class vim.api.keyset.ns_opts +--- @field wins? any[] + --- @class vim.api.keyset.open_term --- @field on_input? function --- @field force_crlf? boolean diff --git a/runtime/lua/vim/highlight.lua b/runtime/lua/vim/highlight.lua index e972ffaa8c..233bc50237 100644 --- a/runtime/lua/vim/highlight.lua +++ b/runtime/lua/vim/highlight.lua @@ -31,8 +31,6 @@ M.priorities = { --- Indicates priority of highlight --- (default: `vim.highlight.priorities.user`) --- @field priority? integer ---- ---- @field package _scoped? boolean --- Apply highlight group to range of text. --- @@ -47,7 +45,6 @@ function M.range(bufnr, ns, higroup, start, finish, opts) local regtype = opts.regtype or 'v' local inclusive = opts.inclusive or false local priority = opts.priority or M.priorities.user - local scoped = opts._scoped or false local v_maxcol = vim.v.maxcol @@ -114,7 +111,6 @@ function M.range(bufnr, ns, higroup, start, finish, opts) end_col = end_col, priority = priority, strict = false, - scoped = scoped, }) end end @@ -178,19 +174,18 @@ function M.on_yank(opts) yank_cancel() end - vim.api.nvim__win_add_ns(winid, yank_ns) + vim.api.nvim__ns_set(yank_ns, { wins = { winid } }) M.range(bufnr, yank_ns, higroup, "'[", "']", { regtype = event.regtype, inclusive = event.inclusive, priority = opts.priority or M.priorities.user, - _scoped = true, }) yank_cancel = function() yank_timer = nil yank_cancel = nil pcall(vim.api.nvim_buf_clear_namespace, bufnr, yank_ns, 0, -1) - pcall(vim.api.nvim__win_del_ns, winid, yank_ns) + pcall(vim.api.nvim__ns_set, { wins = {} }) end yank_timer = vim.defer_fn(yank_cancel, timeout) |