diff options
author | bfredl <bjorn.linse@gmail.com> | 2023-10-01 10:39:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-01 10:39:31 +0200 |
commit | 9b3045103f7d56e5ccd0574dcb93e953b72d5f50 (patch) | |
tree | 303dfcb93ac93664838e7c0d362a88aaf8b6b34f /src/nvim/api/vim.c | |
parent | 2da66f1f710523548ca0746d5f7ef945de6d8f6a (diff) | |
parent | 2615ed879e66a3d05920c47177e77383adc7aca0 (diff) | |
download | rneovim-9b3045103f7d56e5ccd0574dcb93e953b72d5f50.tar.gz rneovim-9b3045103f7d56e5ccd0574dcb93e953b72d5f50.tar.bz2 rneovim-9b3045103f7d56e5ccd0574dcb93e953b72d5f50.zip |
Merge pull request #25455 from bfredl/highlight_namespace_getters
feat(ui): allow to get the highlight namespace. closes #24390
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r-- | src/nvim/api/vim.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 9d9a5080e4..675aaf1006 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -173,6 +173,29 @@ void nvim_set_hl(Integer ns_id, String name, Dict(highlight) *val, Error *err) } } +/// Gets the active highlight namespace. +/// +/// @param opts Optional parameters +/// - winid: (number) |window-ID| for retrieving a window's highlight +/// namespace. A value of -1 is returned when |nvim_win_set_hl_ns()| +/// has not been called for the window (or was called with a namespace +/// of -1). +/// @param[out] err Error details, if any +/// @return Namespace id, or -1 +Integer nvim_get_hl_ns(Dict(get_ns) *opts, Error *err) + FUNC_API_SINCE(12) +{ + if (HAS_KEY(opts, get_ns, winid)) { + win_T *win = find_window_by_handle(opts->winid, err); + if (!win) { + return 0; + } + return win->w_ns_hl; + } else { + return ns_hl_global; + } +} + /// Set active namespace for highlights defined with |nvim_set_hl()|. This can be set for /// a single window, see |nvim_win_set_hl_ns()|. /// |