aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/window.c
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2022-07-25 10:16:33 +0200
committerbfredl <bjorn.linse@gmail.com>2022-08-17 16:20:39 +0200
commitd879331b0dee66cb106b5bea9efc2f920caf9abd (patch)
tree05188f0b72e9aa7432f2f08516a6f239e491419f /src/nvim/api/window.c
parentf7cfca49d6f1380b2ec0b0f7723ea308d0810857 (diff)
downloadrneovim-d879331b0dee66cb106b5bea9efc2f920caf9abd.tar.gz
rneovim-d879331b0dee66cb106b5bea9efc2f920caf9abd.tar.bz2
rneovim-d879331b0dee66cb106b5bea9efc2f920caf9abd.zip
feat(ui): allow to set the highlight namespace per window
- reimplement 'winhl' in terms of highlight namespaces - check for EOF in screen tests (to indicate a likely crash)
Diffstat (limited to 'src/nvim/api/window.c')
-rw-r--r--src/nvim/api/window.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c
index 5a4ff70257..d0a2ff766e 100644
--- a/src/nvim/api/window.c
+++ b/src/nvim/api/window.c
@@ -426,3 +426,28 @@ Object nvim_win_call(Window window, LuaRef fun, Error *err)
try_end(err);
return res;
}
+
+/// Set highlight namespace for a window. This will use highlights defined in
+/// this namespace, but fall back to global highlights (ns=0) when missing.
+///
+/// This takes predecence over the 'winhighlight' option.
+///
+/// @param ns_id the namespace to use
+/// @param[out] err Error details, if any
+void nvim_win_set_hl_ns(Window window, Integer ns_id, Error *err)
+ FUNC_API_SINCE(10)
+{
+ win_T *win = find_window_by_handle(window, err);
+ if (!win) {
+ return;
+ }
+
+ // -1 is allowed as inherit global namespace
+ if (ns_id < -1) {
+ api_set_error(err, kErrorTypeValidation, "no such namespace");
+ }
+
+ win->w_ns_hl = (NS)ns_id;
+ win->w_hl_needs_update = true;
+ redraw_later(win, NOT_VALID);
+}