diff options
Diffstat (limited to 'src/nvim/api')
-rw-r--r-- | src/nvim/api/vim.c | 6 | ||||
-rw-r--r-- | src/nvim/api/window.c | 32 |
2 files changed, 26 insertions, 12 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 2034fea770..27344fc093 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -1059,6 +1059,12 @@ fail: /// - "SE" south-east /// - `height`: window height (in character cells). Minimum of 1. /// - `width`: window width (in character cells). Minimum of 1. +/// - 'bufpos': position float relative text inside the window `win` (only +/// when relative="win"). Takes a tuple of [line, column] where +/// both are zero-index. Note: `row` and `col` if present, still +/// applies relative this positio. By default `row=1` and `col=0` +/// is used (with default NW anchor), to make the float +/// behave like a tooltip under the buffer text. /// - `row`: row position. Screen cell height are used as unit. Can be /// floating point. /// - `col`: column position. Screen cell width is used as unit. Can be diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index e279edebde..02670c0513 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -503,25 +503,33 @@ Dictionary nvim_win_get_config(Window window, Error *err) return rv; } - PUT(rv, "focusable", BOOLEAN_OBJ(wp->w_float_config.focusable)); - PUT(rv, "external", BOOLEAN_OBJ(wp->w_float_config.external)); + FloatConfig *config = &wp->w_float_config; + + PUT(rv, "focusable", BOOLEAN_OBJ(config->focusable)); + PUT(rv, "external", BOOLEAN_OBJ(config->external)); if (wp->w_floating) { - PUT(rv, "width", INTEGER_OBJ(wp->w_float_config.width)); - PUT(rv, "height", INTEGER_OBJ(wp->w_float_config.height)); - if (!wp->w_float_config.external) { - if (wp->w_float_config.relative == kFloatRelativeWindow) { - PUT(rv, "win", INTEGER_OBJ(wp->w_float_config.window)); + PUT(rv, "width", INTEGER_OBJ(config->width)); + PUT(rv, "height", INTEGER_OBJ(config->height)); + if (!config->external) { + if (config->relative == kFloatRelativeWindow) { + PUT(rv, "win", INTEGER_OBJ(config->window)); + if (config->bufpos.lnum >= 0) { + Array pos = ARRAY_DICT_INIT; + ADD(pos, INTEGER_OBJ(config->bufpos.lnum)); + ADD(pos, INTEGER_OBJ(config->bufpos.col)); + PUT(rv, "bufpos", ARRAY_OBJ(pos)); + } } PUT(rv, "anchor", STRING_OBJ(cstr_to_string( - float_anchor_str[wp->w_float_config.anchor]))); - PUT(rv, "row", FLOAT_OBJ(wp->w_float_config.row)); - PUT(rv, "col", FLOAT_OBJ(wp->w_float_config.col)); + float_anchor_str[config->anchor]))); + PUT(rv, "row", FLOAT_OBJ(config->row)); + PUT(rv, "col", FLOAT_OBJ(config->col)); } } - const char *rel = (wp->w_floating && !wp->w_float_config.external - ? float_relative_str[wp->w_float_config.relative] : ""); + const char *rel = (wp->w_floating && !config->external + ? float_relative_str[config->relative] : ""); PUT(rv, "relative", STRING_OBJ(cstr_to_string(rel))); return rv; |