Skip to content

Commit 691c5f3

Browse files
committed
docs(completion): add note about vim.lsp.protocol.CompletionItemKind
1 parent 7d40fc5 commit 691c5f3

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

doc/mini-completion.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,16 @@ You can override runtime config settings locally to buffer inside
7373
`lsp_completion = {source_func = 'omnifunc', auto_setup = false}`.
7474
- In `on_attach()` of every LSP client set 'omnifunc' option to exactly
7575
`v:lua.MiniCompletion.completefunc_lsp`.
76+
77+
- Uses `vim.lsp.protocol.CompletionItemKind` map in LSP step to show a readable
78+
version of item's kind. Modify it directly to change what is displayed.
79+
If you have |mini.icons| enabled, take a look at |MiniIcons.tweak_lsp_kind()|.
80+
7681
- If you have trouble using custom (overridden) |vim.ui.input| (like from
7782
'stevearc/dressing.nvim'), make automated disable of 'mini.completion'
7883
for input buffer. For example, currently for 'dressing.nvim' it can be
7984
with `au FileType DressingInput lua vim.b.minicompletion_disable = true`.
85+
8086
- Support of `additionalTextEdits` tries to handle both types of servers:
8187
- When `additionalTextEdits` are supplied in response to
8288
'textDocument/completion' request (like currently in 'pyright').

lua/mini/completion.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,16 @@
7373
--- `lsp_completion = {source_func = 'omnifunc', auto_setup = false}`.
7474
--- - In `on_attach()` of every LSP client set 'omnifunc' option to exactly
7575
--- `v:lua.MiniCompletion.completefunc_lsp`.
76+
---
77+
--- - Uses `vim.lsp.protocol.CompletionItemKind` map in LSP step to show a readable
78+
--- version of item's kind. Modify it directly to change what is displayed.
79+
--- If you have |mini.icons| enabled, take a look at |MiniIcons.tweak_lsp_kind()|.
80+
---
7681
--- - If you have trouble using custom (overridden) |vim.ui.input| (like from
7782
--- 'stevearc/dressing.nvim'), make automated disable of 'mini.completion'
7883
--- for input buffer. For example, currently for 'dressing.nvim' it can be
7984
--- with `au FileType DressingInput lua vim.b.minicompletion_disable = true`.
85+
---
8086
--- - Support of `additionalTextEdits` tries to handle both types of servers:
8187
--- - When `additionalTextEdits` are supplied in response to
8288
--- 'textDocument/completion' request (like currently in 'pyright').
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--|---------|---------|---------|
2+
01|Jackpot
3+
02|
4+
03|January Text
5+
04|February Text
6+
05|March Method
7+
06|April Method
8+
07|May Method
9+
08|June S Something
10+
09|July S Something
11+
10|August S Something
12+
11|September Fallback
13+
12|October Fallback
14+
13|November Fallback
15+
14|December Text
16+
15|~
17+
16|[No Name] [+] 2,1 All
18+
17|-- INSERT --
19+
20+
--|---------|---------|---------|
21+
01|000000000000000000000000000000
22+
02|000000000000000000000000000000
23+
03|111111111111111111111122222222
24+
04|111111111111111111111122222222
25+
05|111111111111111111111122222222
26+
06|111111111111111111111122222222
27+
07|111111111111111111111122222222
28+
08|111111111111111111111122222222
29+
09|111111111111111111111122222222
30+
10|111111111111111111111122222222
31+
11|111111111111111111111122222222
32+
12|111111111111111111111122222222
33+
13|111111111111111111111122222222
34+
14|111111111111111111111122222222
35+
15|222222222222222222222222222222
36+
16|333333333333333333333333333333
37+
17|444444444444555555555555555555

tests/test_completion.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,20 @@ T['Manual completion']['works with two-step completion'] = function()
439439
eq(get_completion(), { 'Jackpot' })
440440
end
441441

442+
T['Manual completion']['uses `vim.lsp.protocol.CompletionItemKind` in LSP step'] = function()
443+
child.set_size(17, 30)
444+
child.lua([[vim.lsp.protocol = {
445+
CompletionItemKind = {
446+
[1] = 'Text', Text = 1,
447+
[2] = 'Method', Method = 2,
448+
[3] = 'S Something', ['S Something'] = 3,
449+
[4] = 'Fallback', Fallback = 4,
450+
},
451+
}]])
452+
type_keys('i', '<C-Space>')
453+
child.expect_screenshot()
454+
end
455+
442456
T['Manual completion']['works with fallback action'] = function()
443457
type_keys('i', 'J', '<M-Space>')
444458
eq(get_completion(), { 'Jackpot' })

0 commit comments

Comments
 (0)