Skip to content

Commit

Permalink
fix(cmdline): make completion work for <sid> and s: viml function
Browse files Browse the repository at this point in the history
  • Loading branch information
rainerborene committed Jan 7, 2025
1 parent 36ba8eb commit aacb98a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lua/blink/cmp/sources/cmdline/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,17 @@ function cmdline:get_completions(context, callback)
end

local completions = {}
local completion_type = vim.fn.getcmdcompltype()
local completion_args = vim.split(vim.fn.getcmdcompltype(), ',', { plain = true })
local completion_type = completion_args[1]
local completion_func = completion_args[2]

-- Handle custom completions explicitly, since otherwise they won't work in input() mode (getcmdtype() == '@')
if vim.startswith(completion_type, 'custom,') or vim.startswith(completion_type, 'customlist,') then
local fun = completion_type:gsub('custom,', ''):gsub('customlist,', '')
completions = vim.fn.call(fun, { current_arg_prefix, vim.fn.getcmdline(), vim.fn.getcmdpos() })
if
vim.startswith(completion_type, 'custom')
and not vim.startswith(completion_func, 's:')
and not vim.startswith(completion_func, '<sid>')
then
completions = vim.fn.call(completion_func, { current_arg_prefix, vim.fn.getcmdline(), vim.fn.getcmdpos() })
-- `custom,` type returns a string, delimited by newlines
if type(completions) == 'string' then completions = vim.split(completions, '\n') end
else
Expand Down

0 comments on commit aacb98a

Please sign in to comment.