Skip to content

Commit 68d4478

Browse files
committed
feat(clue)!: show clue of current query as window title
Details: - This shows current context and helps navigating through mappings. Should improve experience for new MiniMax users.
1 parent 2c7372f commit 68d4478

19 files changed

+251
-17
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ There are following change types:
7777

7878
## mini.clue
7979

80+
### Evolve
81+
82+
- Use current query clue (if not immediately after trigger) as a window title instead of showing keys verbatim. This shows extra context when navigating through mappings.
83+
8084
### Expand
8185

8286
- Add `gen_clues.square_brackets` to generate clues for `[` and `]` keys. By @TheLeoP, PR #1937.

lua/mini/clue.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1679,12 +1679,16 @@ H.window_get_config = function()
16791679
local max_height = vim.o.lines - vim.o.cmdheight - (has_tabline and 1 or 0) - (has_statusline and 1 or 0) - 2
16801680
max_height = math.max(max_height, 1)
16811681

1682+
local keys = H.query_to_keys(H.state.query)
1683+
local query_clue = (H.state.clues[keys] or {}).desc or ''
1684+
local title = (#H.state.query <= 1 or query_clue == '') and H.keytrans(keys) or query_clue
1685+
16821686
local buf_id = H.state.buf_id
16831687
local cur_config_fields = {
16841688
row = vim.o.lines - vim.o.cmdheight - (has_statusline and 1 or 0),
16851689
col = vim.o.columns,
16861690
height = math.min(vim.api.nvim_buf_line_count(buf_id), max_height),
1687-
title = ' ' .. H.keytrans(H.query_to_keys(H.state.query)) .. ' ',
1691+
title = ' ' .. title .. ' ',
16881692
border = (vim.fn.exists('+winborder') == 1 and vim.o.winborder ~= '') and vim.o.winborder or 'single',
16891693
}
16901694
local user_config = H.expand_callable(H.get_config().window.config, buf_id) or {}

tests/screenshots/tests-test_clue.lua---Clues---handles-showing-group-clues-after-executing-key-with-postkeys-002

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
02|~
44
03|~
55
04|~
6-
05|~ ┌ <Space>g ────────────────────┐
6+
05|~ ┌ Group ───────────────────────┐
77
06|~ │ a │ LHS: " ga" │
88
07|~ │ b │ LHS: " gb" │
99
08|~ └──────────────────────────────┘
@@ -15,7 +15,7 @@
1515
02|1111111111111111111111111111111111111111
1616
03|1111111111111111111111111111111111111111
1717
04|1111111111111111111111111111111111111111
18-
05|1111111123333333333222222222222222222222
18+
05|1111111123333333222222222222222222222222
1919
06|1111111124445666666666666666666666666662
2020
07|1111111124445666666666666666666666666662
2121
08|1111111122222222222222222222222222222222
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|~ ┌ <Space> ───────────┐
6+
05|~ │ a │ Group a │
7+
06|~ │ b │ +3 choices │
8+
07|~ │ c │ +1 choice │
9+
08|~ └────────────────────┘
10+
09|[No Name] 0,0-1
11+
10|
12+
13+
--|---------|---------|---------|
14+
01|000000000000000000000000000000
15+
02|111111111111111111111111111111
16+
03|111111111111111111111111111111
17+
04|111111112333333333222222222222
18+
05|111111112444566666666666666662
19+
06|111111112444566666666666666662
20+
07|111111112444577777777777777772
21+
08|111111112222222222222222222222
22+
09|888888888888888888888888888888
23+
10|999999999999999999999999999999
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|~ ┌ Group a ───────────┐
8+
07|~ │ a │ Subgroup aa │
9+
08|~ └────────────────────┘
10+
09|[No Name] 0,0-1
11+
10|
12+
13+
--|---------|---------|---------|
14+
01|000000000000000000000000000000
15+
02|111111111111111111111111111111
16+
03|111111111111111111111111111111
17+
04|111111111111111111111111111111
18+
05|111111111111111111111111111111
19+
06|111111112333333333222222222222
20+
07|111111112444566666666666666662
21+
08|111111112222222222222222222222
22+
09|777777777777777777777777777777
23+
10|888888888888888888888888888888
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|~ ┌ Subgroup aa ───────┐
7+
06|~ │ a │ Do aaa │
8+
07|~ │ b │ Do aab │
9+
08|~ └────────────────────┘
10+
09|[No Name] 0,0-1
11+
10|
12+
13+
--|---------|---------|---------|
14+
01|000000000000000000000000000000
15+
02|111111111111111111111111111111
16+
03|111111111111111111111111111111
17+
04|111111111111111111111111111111
18+
05|111111112333333333333322222222
19+
06|111111112444566666666666666662
20+
07|111111112444566666666666666662
21+
08|111111112222222222222222222222
22+
09|777777777777777777777777777777
23+
10|888888888888888888888888888888
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|~ ┌ Group a ───────────┐
8+
07|~ │ a │ Subgroup aa │
9+
08|~ └────────────────────┘
10+
09|[No Name] 0,0-1
11+
10|
12+
13+
--|---------|---------|---------|
14+
01|000000000000000000000000000000
15+
02|111111111111111111111111111111
16+
03|111111111111111111111111111111
17+
04|111111111111111111111111111111
18+
05|111111111111111111111111111111
19+
06|111111112333333333222222222222
20+
07|111111112444566666666666666662
21+
08|111111112222222222222222222222
22+
09|777777777777777777777777777777
23+
10|888888888888888888888888888888
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>b ──────────┐
8+
07|~ │ a │ Subgroup ba │
9+
08|~ └────────────────────┘
10+
09|[No Name] 0,0-1
11+
10|
12+
13+
--|---------|---------|---------|
14+
01|000000000000000000000000000000
15+
02|111111111111111111111111111111
16+
03|111111111111111111111111111111
17+
04|111111111111111111111111111111
18+
05|111111111111111111111111111111
19+
06|111111112333333333322222222222
20+
07|111111112444566666666666666662
21+
08|111111112222222222222222222222
22+
09|777777777777777777777777777777
23+
10|888888888888888888888888888888
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|~ ┌ Subgroup ba ───────┐
7+
06|~ │ a │ Do baa │
8+
07|~ │ b │ Do bab │
9+
08|~ └────────────────────┘
10+
09|[No Name] 0,0-1
11+
10|
12+
13+
--|---------|---------|---------|
14+
01|000000000000000000000000000000
15+
02|111111111111111111111111111111
16+
03|111111111111111111111111111111
17+
04|111111111111111111111111111111
18+
05|111111112333333333333322222222
19+
06|111111112444566666666666666662
20+
07|111111112444566666666666666662
21+
08|111111112222222222222222222222
22+
09|777777777777777777777777777777
23+
10|888888888888888888888888888888
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>c ──────────┐
8+
07|~ │ a │ +1 choice │
9+
08|~ └────────────────────┘
10+
09|[No Name] 0,0-1
11+
10|
12+
13+
--|---------|---------|---------|
14+
01|000000000000000000000000000000
15+
02|111111111111111111111111111111
16+
03|111111111111111111111111111111
17+
04|111111111111111111111111111111
18+
05|111111111111111111111111111111
19+
06|111111112333333333322222222222
20+
07|111111112444566666666666666662
21+
08|111111112222222222222222222222
22+
09|777777777777777777777777777777
23+
10|888888888888888888888888888888

0 commit comments

Comments
 (0)