Skip to content

Commit eb4d6bd

Browse files
committed
feat(completion): conditionally remove "t" flag in 'complete' option
1 parent ccd7aed commit eb4d6bd

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

CHANGELOG.md

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

4040
## mini.completion
4141

42+
### Evolve
43+
44+
- Update `setup()` to remove "t" flag from 'complete' option (if not previously set and fallback action is default) as it leads to visible lags.
45+
4246
### Expand
4347

4448
- Add `MiniCompletionWindowOpen` and `MiniCompletionWindowUpdate` events.

doc/mini-completion.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ Some options are set automatically (if not set before |MiniCompletion.setup()|):
8888
To enable fuzzy matching, manually set to "menuone,noselect,fuzzy". Consider
8989
also adding "nosort" flag to preserve initial order when filtering.
9090
- 'shortmess' is appended with "c" flag for silent <C-n> fallback.
91+
- 'complete' gets removed "t" flag (if fallback action is default), as it
92+
leads to visible lags.
9193

9294
# Snippets ~
9395

lua/mini/completion.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@
8888
--- To enable fuzzy matching, manually set to "menuone,noselect,fuzzy". Consider
8989
--- also adding "nosort" flag to preserve initial order when filtering.
9090
--- - 'shortmess' is appended with "c" flag for silent <C-n> fallback.
91+
--- - 'complete' gets removed "t" flag (if fallback action is default), as it
92+
--- leads to visible lags.
9193
---
9294
--- # Snippets ~
9395
---
@@ -796,6 +798,10 @@ H.apply_config = function(config)
796798
local shortmess_flags = 'c' .. (vim.fn.has('nvim-0.10') == 0 and 'C' or '')
797799
was_set = vim.api.nvim_get_option_info2('shortmess', { scope = 'global' }).was_set
798800
if not was_set then vim.opt.shortmess:append(shortmess_flags) end
801+
802+
-- - Remove "t" flag to reduce visible lags
803+
was_set = vim.api.nvim_get_option_info2('complete', { scope = 'global' }).was_set
804+
if not was_set and config.fallback_action == '<C-n>' then vim.opt.complete:remove('t') end
799805
end
800806

801807
H.create_autocommands = function(config)

tests/test_completion.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,16 @@ T['setup()']['sets recommended option values'] = function()
276276
expect.match(child.o.shortmess, 'c')
277277
expect.match(child.o.shortmess, 'C')
278278
eq(child.o.completeopt, 'menuone,noselect')
279+
eq(child.o.complete:find('t'), nil)
279280

280281
-- Should not set if was previously set
281282
child.o.shortmess = 'ltToO'
282283
child.o.completeopt = 'menu,noinsert'
284+
child.o.complete = '.,w,b,u,t'
283285
reload_module()
284286
eq(child.o.shortmess, 'ltToO')
285287
eq(child.o.completeopt, 'menu,noinsert')
288+
eq(child.o.complete, '.,w,b,u,t')
286289
end
287290

288291
T['default_process_items()'] = new_set({

0 commit comments

Comments
 (0)