From fe986e5dd094b2f7e1d28e64e52ffbc5f7292191 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Mon, 20 Apr 2026 02:36:55 +0200 Subject: feat(options): add 'winpinned' to pin a window #39157 Problem: - Unable to "pin" a window to prevent closing without specifically being targeted. - :fclose closes hidden windows (even before visible windows). Solution: - Add 'winpinned' window-local option. When set, window is skipped by :fclose and :only. Pin the ui2 cmdline window (which should always be visible), so that it is not closed by :only/fclose. - Skip over hidden (and pinned) windows with :fclose. Co-authored-by: glepnir --- runtime/lua/vim/_core/ui2.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'runtime/lua/vim/_core') diff --git a/runtime/lua/vim/_core/ui2.lua b/runtime/lua/vim/_core/ui2.lua index 77ea7f57b3..4c7ceefda0 100644 --- a/runtime/lua/vim/_core/ui2.lua +++ b/runtime/lua/vim/_core/ui2.lua @@ -130,6 +130,8 @@ function M.check_targets() hl = 'Normal:MsgArea' elseif type == 'msg' then hl = search_hide + elseif type == 'cmd' then + api.nvim_set_option_value('winpinned', true, { scope = 'local' }) end api.nvim_set_option_value('winhighlight', hl, { scope = 'local' }) end) -- cgit