Skip to content

Commit 416c86d

Browse files
committed
refactor(cmdcomplete): simplify command line completion trigger
Replaces manual wildcharm and feedkeys logic with vim.fn.wildtrigger(). Removes unnecessary configuration and streamlines the setup for command line completion. This improves maintainability and reduces complexity.
1 parent 9cb9bbd commit 416c86d

File tree

1 file changed

+1
-21
lines changed

1 file changed

+1
-21
lines changed

lua/myplugins/cmdcomplete.lua

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ function M.setup()
66
end
77

88
local group = vim.api.nvim_create_augroup('myplugins-cmdcomplete', { clear = true })
9-
local term = vim.api.nvim_replace_termcodes('<C-@>', true, true, true)
109

11-
vim.cmd([[set wildcharm=<C-@>]])
12-
vim.opt.wildmenu = true
1310
vim.opt.wildmode = 'noselect:lastused,full'
14-
1511
vim.keymap.set('c', '<Up>', '<End><C-U><Up>', { silent = true })
1612
vim.keymap.set('c', '<Down>', '<End><C-U><Down>', { silent = true })
1713

@@ -20,23 +16,7 @@ function M.setup()
2016
desc = 'Auto show command line completion',
2117
pattern = ':',
2218
callback = function()
23-
local cmdline = vim.fn.getcmdline()
24-
local curpos = vim.fn.getcmdpos()
25-
local last_char = cmdline:sub(curpos - 1, curpos - 1)
26-
27-
if
28-
curpos == #cmdline + 1
29-
and vim.fn.pumvisible() == 0
30-
and last_char:match('[%w%/%:- ]')
31-
and not cmdline:match('^%d+$')
32-
then
33-
vim.api.nvim_feedkeys(term, 'ti', false)
34-
vim.opt.eventignore:append('CmdlineChanged')
35-
vim.schedule(function()
36-
vim.fn.setcmdline(vim.fn.substitute(vim.fn.getcmdline(), '\\%x00', '', 'g'))
37-
vim.opt.eventignore:remove('CmdlineChanged')
38-
end)
39-
end
19+
vim.fn.wildtrigger()
4020
end,
4121
})
4222
end

0 commit comments

Comments
 (0)