Skip to content

Commit e04b5c6

Browse files
committed
fix(completion): make info window respect new 'pumblend' option
Resolve #2062
1 parent 8a7cf7e commit e04b5c6

5 files changed

+141
-3
lines changed

lua/mini/completion.lua

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,10 @@ H.keys = {
689689
ctrl_n = vim.api.nvim_replace_termcodes('<C-g><C-g><C-n>', true, false, true),
690690
}
691691

692+
-- Flags for whether there is support for dedicated options
693+
H.has_winborder = vim.fn.has('nvim-0.11') == 1
694+
H.has_pumborder = vim.fn.exists('+pumborder') == 1 -- Neovim>=0.12
695+
692696
-- Caches for different actions -----------------------------------------------
693697
-- Field `lsp` is a table describing state of all used LSP requests. It has the
694698
-- following structure:
@@ -1528,8 +1532,9 @@ end
15281532

15291533
H.info_window_options = function()
15301534
local win_config = H.get_config().window.info
1531-
local default_border = (vim.fn.exists('+winborder') == 1 and vim.o.winborder ~= '') and vim.o.winborder or 'single'
1535+
local default_border = (H.has_winborder and vim.o.winborder ~= '') and vim.o.winborder or 'single'
15321536
local border = win_config.border or default_border
1537+
local pumborder = H.has_pumborder and vim.o.pumborder or ''
15331538

15341539
-- Compute dimensions based on actually visible lines to be displayed
15351540
local lines = H.compute_visible_md_lines(vim.api.nvim_buf_get_lines(H.info.bufnr, 0, -1, false))
@@ -1538,7 +1543,8 @@ H.info_window_options = function()
15381543
-- Compute position
15391544
local event = H.info.event
15401545
local left_to_pum = event.col - 1
1541-
local right_to_pum = event.col + event.width + (event.scrollbar and 1 or 0)
1546+
local pumborder_offset = (pumborder == '' or pumborder == 'none') and 0 or 2
1547+
local right_to_pum = event.col + event.width + (event.scrollbar and 1 or 0) + pumborder_offset
15421548

15431549
local border_offset = border == 'none' and 0 or 2
15441550
local space_left = left_to_pum - border_offset
@@ -1702,7 +1708,7 @@ end
17021708

17031709
H.signature_window_opts = function()
17041710
local win_config = H.get_config().window.signature
1705-
local default_border = (vim.fn.exists('+winborder') == 1 and vim.o.winborder ~= '') and vim.o.winborder or 'single'
1711+
local default_border = (H.has_winborder and vim.o.winborder ~= '') and vim.o.winborder or 'single'
17061712
local border = win_config.border or default_border
17071713
local lines = vim.api.nvim_buf_get_lines(H.signature.bufnr, 0, -1, false)
17081714
local height, width = H.floating_dimensions(lines, win_config.height, win_config.width)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--|---------|---------|---------|--
2+
01| January
3+
02|~ ┌──────────────────┐┌…fo ┐
4+
03|~ │ January Text ││Mont│
5+
04|~ │ June Function ││h │
6+
05|~ │ July Function ││#01 │
7+
06|~ └──────────────────┘└────┘
8+
07|~
9+
08|~
10+
09|~
11+
10|~
12+
11|~
13+
12|~
14+
13|~
15+
14|[No Name] 1,15
16+
15|-- INSERT --
17+
18+
--|---------|---------|---------|--
19+
01|00000000000000000000000000000000
20+
02|11111122222222222222222222344443
21+
03|11111125555555555555555552366663
22+
04|11111122222222222222222222366663
23+
05|11111122222222222222222222366663
24+
06|11111122222222222222222222333333
25+
07|11111111111111111111111111111111
26+
08|11111111111111111111111111111111
27+
09|11111111111111111111111111111111
28+
10|11111111111111111111111111111111
29+
11|11111111111111111111111111111111
30+
12|11111111111111111111111111111111
31+
13|11111111111111111111111111111111
32+
14|77777777777777777777777777777777
33+
15|88888888888899999999999999999999
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--|---------|---------|---------|--
2+
01| January
3+
02|┌…nfo ┐┌──────────────────┐
4+
03|│Month││ January Text │
5+
04|│ #01 ││ June Function │
6+
05|└─────┘│ July Function │
7+
06|~ └──────────────────┘
8+
07|~
9+
08|~
10+
09|~
11+
10|~
12+
11|~
13+
12|~
14+
13|~
15+
14|[No Name] 1,16
16+
15|-- INSERT --
17+
18+
--|---------|---------|---------|--
19+
01|00000000000000000000000000000000
20+
02|12222213333333333333333333344444
21+
03|15555513666666666666666666344444
22+
04|15555513333333333333333333344444
23+
05|11111113333333333333333333344444
24+
06|44444443333333333333333333344444
25+
07|44444444444444444444444444444444
26+
08|44444444444444444444444444444444
27+
09|44444444444444444444444444444444
28+
10|44444444444444444444444444444444
29+
11|44444444444444444444444444444444
30+
12|44444444444444444444444444444444
31+
13|44444444444444444444444444444444
32+
14|77777777777777777777777777777777
33+
15|88888888888899999999999999999999
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--|---------|---------|---------|--
2+
01|January
3+
02|┌─────────────────┐Month #01
4+
03|│January Text │
5+
04|│June Function │
6+
05|│July Function │
7+
06|└─────────────────┘
8+
07|~
9+
08|~
10+
09|~
11+
10|~
12+
11|~
13+
12|~
14+
13|~
15+
14|[No Name] 1,8
16+
15|-- INSERT --
17+
18+
--|---------|---------|---------|--
19+
01|00000000000000000000000000000000
20+
02|11111111111111111112222222223333
21+
03|14444444444444444413333333333333
22+
04|11111111111111111113333333333333
23+
05|11111111111111111113333333333333
24+
06|11111111111111111113333333333333
25+
07|33333333333333333333333333333333
26+
08|33333333333333333333333333333333
27+
09|33333333333333333333333333333333
28+
10|33333333333333333333333333333333
29+
11|33333333333333333333333333333333
30+
12|33333333333333333333333333333333
31+
13|33333333333333333333333333333333
32+
14|55555555555555555555555555555555
33+
15|66666666666677777777777777777777

tests/test_completion.lua

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,6 +1622,39 @@ T['Information window']["respects 'winborder' option"] = function()
16221622
validate({ '', '', '', '', '', '', '', '' })
16231623
end
16241624

1625+
T['Information window']["respects 'pumborder' option"] = function()
1626+
if child.fn.has('nvim-0.12') == 0 then MiniTest.skip("'pumborder' option is present on Neovim>=0.12") end
1627+
child.set_size(15, 32)
1628+
1629+
local validate = function(offset, pumborder)
1630+
child.o.pumborder = pumborder
1631+
set_lines({ string.rep(' ', offset) })
1632+
type_keys('A', 'J', '<C-Space>')
1633+
type_keys('<C-n>')
1634+
sleep(default_info_delay + small_time)
1635+
child.expect_screenshot()
1636+
1637+
type_keys('<C-e>')
1638+
child.ensure_normal_mode()
1639+
set_lines({})
1640+
end
1641+
1642+
-- Should properly adjust coordinates and pick side
1643+
validate(7, 'single')
1644+
validate(8, 'single')
1645+
1646+
-- Should respect no border in both windows
1647+
-- NOTE: Does not fully work for `pumborder=none` due to Neovim issue:
1648+
-- https://github.com/neovim/neovim/issues/36246
1649+
-- TODO: Uncomment both `'none'` validations after the issue is resolved
1650+
--
1651+
-- validate(0, 'none')
1652+
1653+
child.lua('MiniCompletion.config.window.info.border = "none"')
1654+
validate(0, 'single')
1655+
-- validate(0, 'none')
1656+
end
1657+
16251658
T['Information window']['triggers relevant events'] = function()
16261659
mock_event_log()
16271660
local validate_log = function(ref)

0 commit comments

Comments
 (0)