commit ef48104c31209a6ec7e2e175194ed83abc85926d
parent 798bb3f66ae9a400d0215285771343e2bffd01a7
Author: Lewis Russell <lewis6991@gmail.com>
Date: Sat, 6 Sep 2025 22:19:12 +0100
fix(types): nvim_get_win_config return type #35639
Diffstat:
4 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/runtime/lua/vim/_extui/shared.lua b/runtime/lua/vim/_extui/shared.lua
@@ -17,6 +17,7 @@ local M = {
},
},
}
+--- @type vim.api.keyset.win_config
local wincfg = { -- Default cfg for nvim_open_win().
relative = 'laststatus',
style = 'minimal',
diff --git a/runtime/lua/vim/_meta/api.lua b/runtime/lua/vim/_meta/api.lua
@@ -2415,7 +2415,7 @@ function vim.api.nvim_win_get_buf(window) end
--- `relative` is empty for normal windows.
---
--- @param window integer `window-ID`, or 0 for current window
---- @return vim.api.keyset.win_config # Map defining the window configuration, see |nvim_open_win()|
+--- @return vim.api.keyset.win_config_ret # Map defining the window configuration, see |nvim_open_win()|
function vim.api.nvim_win_get_config(window) end
--- Gets the (1,0)-indexed, buffer-relative cursor position for a given window
diff --git a/runtime/lua/vim/_meta/api_keysets_extra.lua b/runtime/lua/vim/_meta/api_keysets_extra.lua
@@ -247,3 +247,24 @@ error('Cannot require a meta file')
--- @field fill integer
--- @field end_row integer
--- @field end_vcol integer
+
+-- Inherit from vim.api.keyset.win_config so this type can be passed to nvim_open_win().
+-- Because of this we only need to define the fields with different types (nil or non-nil).
+
+--- @class vim.api.keyset.win_config_ret : vim.api.keyset.win_config
+--- @field focusable boolean
+--- @field external boolean
+--- @field hide boolean
+--- @field mouse boolean
+--- @field width integer
+--- @field height integer
+--- @field relative 'cursor'|'editor'|'laststatus'|'mouse'|'tabline'|'win'
+---
+--- @field noautocmd nil
+--- @field title nil
+--- @field title_pos nil
+--- @field footer nil
+--- @field footer_pos nil
+--- @field style nil
+--- @field fixed nil
+--- @field vertical nil
diff --git a/src/gen/gen_eval_files.lua b/src/gen/gen_eval_files.lua
@@ -24,6 +24,10 @@ local TEXT_WIDTH = 78
--- @field remote boolean
--- @field since integer
+local LUA_API_RETURN_OVERRIDES = {
+ nvim_win_get_config = 'vim.api.keyset.win_config_ret',
+}
+
local LUA_META_HEADER = {
'--- @meta _',
'-- THIS FILE IS GENERATED',
@@ -306,7 +310,8 @@ local function render_api_meta(_f, fun, write)
if fun.returns ~= 'nil' then
local ret_desc = fun.returns_desc and ' # ' .. fun.returns_desc or ''
- write(util.prefix_lines('--- ', '@return ' .. fun.returns .. ret_desc))
+ local ret = LUA_API_RETURN_OVERRIDES[fun.name] or fun.returns
+ write(util.prefix_lines('--- ', '@return ' .. ret .. ret_desc))
end
local param_str = table.concat(param_names, ', ')