Skip to content

Commit

Permalink
Support @ cmdtype
Browse files Browse the repository at this point in the history
  • Loading branch information
yehuohan committed Jun 29, 2023
1 parent 23c51b2 commit f3e7c93
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lua/cmp_cmdline/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ local definitions = {
target = target:sub(e + 1)
end
-- nvim_parse_cmd throw error when the cmdline contains range specifier.
return vim.api.nvim_parse_cmd(target, {}) or {}
return vim.api.nvim_parse_cmd(target, { mods = { silent = true } }) or {}
end)
parsed = parsed or {}

Expand Down Expand Up @@ -110,8 +110,11 @@ local definitions = {
local is_option_name_completion = OPTION_NAME_COMPLETION_REGEX:match_str(cmdline) ~= nil

local items = {}
local escaped = cmdline:gsub([[\\]], [[\\\\]]);
for _, word_or_item in ipairs(vim.fn.getcompletion(escaped, 'cmdline')) do
local cmdtype = vim.fn.getcmdcompltype()
if cmdtype == '' or vim.fn.getcmdtype() ~= '@' then
cmdtype = 'cmdline'
end
for _, word_or_item in ipairs(vim.fn.getcompletion(cmdline, cmdtype)) do
local word = type(word_or_item) == 'string' and word_or_item or word_or_item.word
local item = { word = word }
table.insert(items, item)
Expand Down

0 comments on commit f3e7c93

Please sign in to comment.