Skip to content

Commit 7faa52f

Browse files
committed
Support @ cmdtype
1 parent 8ee981b commit 7faa52f

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

lua/cmp_cmdline/init.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ local definitions = {
9090
target = target:sub(e + 1)
9191
end
9292
-- nvim_parse_cmd throw error when the cmdline contains range specifier.
93-
return vim.api.nvim_parse_cmd(target, {}) or {}
93+
return vim.api.nvim_parse_cmd(target, { mods = { silent = true } }) or {}
9494
end)
9595
parsed = parsed or {}
9696

@@ -126,8 +126,11 @@ local definitions = {
126126
local is_option_name_completion = OPTION_NAME_COMPLETION_REGEX:match_str(cmdline) ~= nil
127127

128128
local items = {}
129-
local escaped = cmdline:gsub([[\\]], [[\\\\]]);
130-
for _, word_or_item in ipairs(vim.fn.getcompletion(escaped, 'cmdline')) do
129+
local cmdtype = vim.fn.getcmdcompltype()
130+
if cmdtype == '' or vim.fn.getcmdtype() ~= '@' then
131+
cmdtype = 'cmdline'
132+
end
133+
for _, word_or_item in ipairs(vim.fn.getcompletion(cmdline, cmdtype)) do
131134
local word = type(word_or_item) == 'string' and word_or_item or word_or_item.word
132135
local item = { label = word }
133136
table.insert(items, item)

0 commit comments

Comments
 (0)