aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/api/window.c32
-rw-r--r--test/functional/api/window_spec.lua32
2 files changed, 59 insertions, 5 deletions
diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c
index 178375d7f1..8514ac6b5f 100644
--- a/src/nvim/api/window.c
+++ b/src/nvim/api/window.c
@@ -6,20 +6,21 @@
#include <stdlib.h>
#include <limits.h>
-#include "nvim/ascii.h"
-#include "nvim/globals.h"
-#include "nvim/api/window.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/lua/executor.h"
#include "nvim/ex_docmd.h"
#include "nvim/vim.h"
+#include "nvim/api/window.h"
+#include "nvim/ascii.h"
#include "nvim/buffer.h"
#include "nvim/cursor.h"
+#include "nvim/globals.h"
+#include "nvim/move.h"
#include "nvim/option.h"
-#include "nvim/window.h"
#include "nvim/screen.h"
-#include "nvim/move.h"
+#include "nvim/syntax.h"
+#include "nvim/window.h"
/// Gets the current buffer in a window
///
@@ -456,6 +457,27 @@ Dictionary nvim_win_get_config(Window window, Error *err)
PUT(rv, "row", FLOAT_OBJ(config->row));
PUT(rv, "col", FLOAT_OBJ(config->col));
}
+ if (config->border) {
+ Array border = ARRAY_DICT_INIT;
+ for (size_t i = 0; i < 8; i++) {
+ Array tuple = ARRAY_DICT_INIT;
+
+ String s = cstrn_to_string((const char *)config->border_chars[i], sizeof(schar_T));
+
+ int hi_id = config->border_hl_ids[i];
+ char_u *hi_name = syn_id2name(hi_id);
+ if (hi_name[0]) {
+ ADD(tuple, STRING_OBJ(s));
+ ADD(tuple, STRING_OBJ(cstr_to_string((const char *)hi_name)));
+ ADD(border, ARRAY_OBJ(tuple));
+ } else {
+ ADD(border, STRING_OBJ(s));
+ }
+ }
+ PUT(rv, "border", ARRAY_OBJ(border));
+ } else {
+ PUT(rv, "border", STRING_OBJ(cstr_to_string("none")));
+ }
}
const char *rel = (wp->w_floating && !config->external
diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua
index a57826f7e7..bb72b63b6c 100644
--- a/test/functional/api/window_spec.lua
+++ b/test/functional/api/window_spec.lua
@@ -401,4 +401,36 @@ describe('API/win', function()
eq(1, funcs.exists('g:fired'))
end)
end)
+
+ describe('get_config', function()
+ it('includes border', function()
+ local b = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' }
+ local win = meths.open_win(0, true, {
+ relative='win', row=3, col=3, width=12, height=3,
+ border = b,
+ })
+
+ local cfg = meths.win_get_config(win)
+ eq(b, cfg.border)
+ end)
+ it('includes border with highlight group', function()
+ local b = {
+ {'a', 'Normal'},
+ {'b', 'Special'},
+ {'c', 'String'},
+ {'d', 'Comment'},
+ {'e', 'Visual'},
+ {'f', 'Error'},
+ {'g', 'Constant'},
+ {'h', 'PreProc'},
+ }
+ local win = meths.open_win(0, true, {
+ relative='win', row=3, col=3, width=12, height=3,
+ border = b,
+ })
+
+ local cfg = meths.win_get_config(win)
+ eq(b, cfg.border)
+ end)
+ end)
end)