Skip to content

Commit 890f6a3

Browse files
committed
fix(ALL): make floating windows work with string array 'winborder'
Details: - Neovim>=0.12 allows 'winborder' to be a comma-separated list of characters (to be used as border characters). However, this is *not* a valid value of `border` for `nvim_open_win()` and `nvim_win_set_config()` (see Neovim's issue number 35065). The solution here is to not explicitly set `vim.o.winborder` as `border` field of floating window config. Instead, omit setting it at all if 'winborder' is not default (in which case it will be used as a fallback). The alternative is to explicitly split comma-separated string into Lua array, but there is usually no good way to do that concisely. However, it would allow supporting this type of border value in a per-module border value (which is somewhat nice to have, but deviates from Neovim core's decisions).
1 parent 68d4478 commit 890f6a3

21 files changed

+530
-48
lines changed

lua/mini/clue.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1689,7 +1689,7 @@ H.window_get_config = function()
16891689
col = vim.o.columns,
16901690
height = math.min(vim.api.nvim_buf_line_count(buf_id), max_height),
16911691
title = ' ' .. title .. ' ',
1692-
border = (vim.fn.exists('+winborder') == 1 and vim.o.winborder ~= '') and vim.o.winborder or 'single',
1692+
border = (vim.fn.exists('+winborder') == 0 or vim.o.winborder == '') and 'single' or nil,
16931693
}
16941694
local user_config = H.expand_callable(H.get_config().window.config, buf_id) or {}
16951695
local res = vim.tbl_deep_extend('force', H.default_win_config, cur_config_fields, user_config)

lua/mini/files.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,7 +1935,7 @@ H.explorer_show_help = function(explorer, explorer_buf_id, explorer_win_id)
19351935
config.height = #lines
19361936
config.title = " 'mini.files' help "
19371937
config.zindex = config.zindex + 1
1938-
local default_border = (vim.fn.exists('+winborder') == 1 and vim.o.winborder ~= '') and vim.o.winborder or 'single'
1938+
local default_border = (vim.fn.exists('+winborder') == 0 or vim.o.winborder == '') and 'single' or nil
19391939
config.border = config.border or default_border
19401940
config.style = 'minimal'
19411941

@@ -2411,7 +2411,7 @@ end
24112411
H.window_open = function(buf_id, config)
24122412
-- Add always the same extra data
24132413
config.anchor = 'NW'
2414-
config.border = (vim.fn.exists('+winborder') == 1 and vim.o.winborder ~= '') and vim.o.winborder or 'single'
2414+
config.border = (vim.fn.exists('+winborder') == 0 or vim.o.winborder == '') and 'single' or nil
24152415
config.focusable = true
24162416
config.relative = 'editor'
24172417
config.style = 'minimal'

lua/mini/misc.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ MiniMisc.zoom = function(buf_id, config)
684684
local compute_config = function()
685685
-- Use precise dimensions for no Command line interactions (better scroll)
686686
local max_width, max_height = vim.o.columns, vim.o.lines - vim.o.cmdheight
687-
local default_border = (vim.fn.exists('+winborder') == 1 and vim.o.winborder ~= '') and vim.o.winborder or 'none'
687+
local default_border = (vim.fn.exists('+winborder') == 0 or vim.o.winborder == '') and 'none' or nil
688688
--stylua: ignore
689689
local default_config = {
690690
relative = 'editor', row = 0, col = 0,

lua/mini/notify.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ H.window_compute_config = function(buf_id, is_for_open)
806806
local default_config = { relative = 'editor', style = 'minimal', noautocmd = is_for_open, zindex = 999 }
807807
default_config.anchor, default_config.col, default_config.row = 'NE', vim.o.columns, has_tabline and 1 or 0
808808
default_config.width, default_config.height = H.buffer_default_dimensions(buf_id, config_win.max_width_share)
809-
default_config.border = (vim.fn.exists('+winborder') == 1 and vim.o.winborder ~= '') and vim.o.winborder or 'single'
809+
default_config.border = (vim.fn.exists('+winborder') == 0 or vim.o.winborder == '') and 'single' or nil
810810
default_config.title = ' Notifications '
811811
-- Don't allow focus to not disrupt window navigation
812812
default_config.focusable = false

lua/mini/pick.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2281,14 +2281,15 @@ H.picker_compute_win_config = function(win_config, is_for_open)
22812281
local max_height = vim.o.lines - vim.o.cmdheight - (has_tabline and 1 or 0) - (has_statusline and 1 or 0)
22822282
local max_width = vim.o.columns
22832283

2284+
local winborder = vim.fn.exists('+winborder') == 0 and '' or vim.o.winborder
22842285
local default_config = {
22852286
relative = 'editor',
22862287
anchor = 'SW',
22872288
width = math.floor(0.618 * max_width),
22882289
height = math.floor(0.618 * max_height),
22892290
col = 0,
22902291
row = max_height + (has_tabline and 1 or 0),
2291-
border = (vim.fn.exists('+winborder') == 1 and vim.o.winborder ~= '') and vim.o.winborder or 'single',
2292+
border = winborder == '' and 'single' or nil,
22922293
style = 'minimal',
22932294
noautocmd = is_for_open,
22942295
-- Use high enough value to be on top of built-in windows (pmenu, etc.)
@@ -2297,7 +2298,7 @@ H.picker_compute_win_config = function(win_config, is_for_open)
22972298
local config = vim.tbl_deep_extend('force', default_config, H.expand_callable(win_config) or {})
22982299

22992300
-- Tweak config values to ensure they are proper
2300-
if config.border == 'none' then config.border = { '', ' ', '', '', '', ' ', '', '' } end
2301+
if (config.border or winborder) == 'none' then config.border = { '', ' ', '', '', '', ' ', '', '' } end
23012302
-- - Adjust dimensions accounting for actually present border parts
23022303
local bor, n = config.border, type(config.border) == 'table' and #config.border or 0
23032304
local height_offset = n == 0 and 2 or ((bor[1 % n + 1] == '' and 0 or 1) + (bor[5 % n + 1] == '' and 0 or 1))

lua/mini/test.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2060,7 +2060,7 @@ H.buffer_reporter.default_window_opts = function()
20602060
height = math.floor(0.618 * vim.o.lines),
20612061
row = math.floor(0.191 * vim.o.lines),
20622062
col = math.floor(0.191 * vim.o.columns),
2063-
border = (vim.fn.exists('+winborder') == 1 and vim.o.winborder ~= '') and vim.o.winborder or 'single',
2063+
border = (vim.fn.exists('+winborder') == 0 or vim.o.winborder == '') and 'single' or nil,
20642064
title = ' Test results ',
20652065
}
20662066
end
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--|---------|---------|---------|---------|
2+
01|
3+
02|~
4+
03|~
5+
04|~
6+
05|~
7+
06|~ + <Space> ---------------------+
8+
07|~ | a │ LHS: " a" |
9+
08|~ +------------------------------+
10+
09|[No Name] 0,0-1
11+
10|
12+
13+
--|---------|---------|---------|---------|
14+
01|0000000000000000000000000000000000000000
15+
02|1111111111111111111111111111111111111111
16+
03|1111111111111111111111111111111111111111
17+
04|1111111111111111111111111111111111111111
18+
05|1111111111111111111111111111111111111111
19+
06|1111111123333333332222222222222222222222
20+
07|1111111124445666666666666666666666666662
21+
08|1111111122222222222222222222222222222222
22+
09|7777777777777777777777777777777777777777
23+
10|8888888888888888888888888888888888888888
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--|---------|---------|---------|---------|
2+
01|+MOCK_ROOT/tests/dir-files/common -----+
3+
02|| .a-dir |
4+
03|| a-dir |
5+
04|| b-dir |
6+
05|| .a-file |
7+
06|| a-file |
8+
07|| A-file-2 |
9+
08|| b-file |
10+
09|+--------------------------------------+
11+
10|~
12+
11|~
13+
12|~
14+
13|~
15+
14|~
16+
15| 1,9-7 All
17+
18+
--|---------|---------|---------|---------|
19+
01|0111111111111111111111111111111111000000
20+
02|0222222223333333333333333333333333333330
21+
03|0444444455555555555555555555555555555550
22+
04|0444444455555555555555555555555555555550
23+
05|0555555555555555555555555555555555555550
24+
06|0555555555555555555555555555555555555550
25+
07|0555555555555555555555555555555555555550
26+
08|0555555555555555555555555555555555555550
27+
09|0000000000000000000000000000000000000000
28+
10|6666666666666666666666666666666666666666
29+
11|6666666666666666666666666666666666666666
30+
12|6666666666666666666666666666666666666666
31+
13|6666666666666666666666666666666666666666
32+
14|6666666666666666666666666666666666666666
33+
15|7777777777777777777777777777777777777777
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--|---------|---------|---------|---------|
2+
01|╭╭ 'mini.files' help ────────────╮─────╮
3+
02|││Buffer mappings: │ │
4+
03|││ │ │
5+
04|││Close │ q │ │
6+
05|││Go in entry │ l │ │
7+
06|││Go in entry plus │ L │ │
8+
07|││Go out of directory │ h │ │
9+
08|││Go out of directory plus │ H │ │
10+
09|╰│Go to bookmark │ ' │─────╯
11+
10|~│Reset │ <BS>│
12+
11|~│Reveal cwd │ @ │
13+
12|~│Set bookmark │ m │
14+
13|~│Show Help │ g? │
15+
14|~│Synchronize │ = │
16+
15|~│Trim branch left │ < │
17+
16|~│Trim branch right │ > │
18+
17|~│ │
19+
18|~│(Press `q` to close) │
20+
19|~╰───────────────────────────────╯
21+
20| 1,1 All
22+
23+
--|---------|---------|---------|---------|
24+
01|0011111111111111111110000000000000000000
25+
02|0022222222222222222222222222222220222220
26+
03|0033333333333333333333333333333330333330
27+
04|0033333333333333333333333333333330333330
28+
05|0033333333333333333333333333333330333330
29+
06|0033333333333333333333333333333330333330
30+
07|0033333333333333333333333333333330333330
31+
08|0033333333333333333333333333333330333330
32+
09|0033333333333333333333333333333330000000
33+
10|4033333333333333333333333333333330444444
34+
11|4033333333333333333333333333333330444444
35+
12|4033333333333333333333333333333330444444
36+
13|4033333333333333333333333333333330444444
37+
14|4033333333333333333333333333333330444444
38+
15|4033333333333333333333333333333330444444
39+
16|4033333333333333333333333333333330444444
40+
17|4033333333333333333333333333333330444444
41+
18|4033333333333333333333333333333330444444
42+
19|4000000000000000000000000000000000444444
43+
20|5555555555555555555555555555555555555555
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--|---------|---------|---------|---------|
2+
01|╔╔ 'mini.files' help ════════════╗═════╗
3+
02|║║Buffer mappings: ║ ║
4+
03|║║ ║ ║
5+
04|║║Close │ q ║ ║
6+
05|║║Go in entry │ l ║ ║
7+
06|║║Go in entry plus │ L ║ ║
8+
07|║║Go out of directory │ h ║ ║
9+
08|║║Go out of directory plus │ H ║ ║
10+
09|╚║Go to bookmark │ ' ║═════╝
11+
10|~║Reset │ <BS>║
12+
11|~║Reveal cwd │ @ ║
13+
12|~║Set bookmark │ m ║
14+
13|~║Show Help │ g? ║
15+
14|~║Synchronize │ = ║
16+
15|~║Trim branch left │ < ║
17+
16|~║Trim branch right │ > ║
18+
17|~║ ║
19+
18|~║(Press `q` to close) ║
20+
19|~╚═══════════════════════════════╝
21+
20| 1,1 All
22+
23+
--|---------|---------|---------|---------|
24+
01|0011111111111111111110000000000000000000
25+
02|0022222222222222222222222222222220222220
26+
03|0033333333333333333333333333333330333330
27+
04|0033333333333333333333333333333330333330
28+
05|0033333333333333333333333333333330333330
29+
06|0033333333333333333333333333333330333330
30+
07|0033333333333333333333333333333330333330
31+
08|0033333333333333333333333333333330333330
32+
09|0033333333333333333333333333333330000000
33+
10|4033333333333333333333333333333330444444
34+
11|4033333333333333333333333333333330444444
35+
12|4033333333333333333333333333333330444444
36+
13|4033333333333333333333333333333330444444
37+
14|4033333333333333333333333333333330444444
38+
15|4033333333333333333333333333333330444444
39+
16|4033333333333333333333333333333330444444
40+
17|4033333333333333333333333333333330444444
41+
18|4033333333333333333333333333333330444444
42+
19|4000000000000000000000000000000000444444
43+
20|5555555555555555555555555555555555555555

0 commit comments

Comments
 (0)