Cmdline completion does not provide arg lead input to custom command completion
Make sure you have done the following
- [X] I have updated to the latest version of
blink.cmp - [X] I have read the README
Bug Description
New cmdline completion does not provide "arg_lead" to the custom command completion. Steps to reproduce:
- Open configuration below:
nvim -u mininit.lua - Type
:Find something - Type
:messages, you will see onlyARG LEAD
Expected:
To see ARG LEAD something in :messages.
Relevant configuration
vim.env.LAZY_STDPATH = '.repro'
load(vim.fn.system('curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua'))()
require('lazy.minit').repro({
spec = {
{
'Saghen/blink.cmp',
version = '0.*',
opts = {},
},
},
})
vim.api.nvim_create_user_command('Find', function() end, {
force = true,
nargs = '?',
complete = function(arg_lead)
print('ARG LEAD', arg_lead)
end,
})
neovim version
0.10.2
blink.cmp version: branch, tag, or commit
0.8.0
This was done intentionally to prevent the complete functions from filtering out items. If you type :Find foo=bar, it'll pass foo= as the arg lead. What's your use case for having the whole arg lead though?
I have a custom :Find command to use as a fuzzy finder (https://github.com/kristijanhusak/neovim-config/blob/master/nvim/after/plugin/find.lua). I use ripgrep to filter down the results. If I return all results instead of slicing them on half, it works, so that part is more/less solved.
The bigger issue for me is autocompletion on input() function. In orgmode, there is an option to move a specific headline to another file. This opens up an input prompt, and allows autocompleting files where the headline should be moved. With cmdline enabled, it is not working. If I set cmdline = {'cmdline'}, it autocompletes, but not what I set in the complete function.
I'm not sure if you are an orgmode user, so here's a simple example in vimscript:
function! DoAutocomplete(A,L,P) abort
return ['one', 'two', 'three']
endfunction
call input('test: ', '', 'customlist,DoAutocomplete')
With cmdline disabled, sourcing this file and pressing tab autocompletes "one,two,three". With cmdline with default value, or set to {'cmdline'}, it does not return anything.
Thanks for the fix. This fixes the issue with input, but it breaks the regular completion for commands. For example, if you use telescope, try doing :Telescope f. You get an error:
Error while fetching completions: Vim:E475: Invalid argument:
That's because getcmdcompltype() returns empty string in that case.
Fixed on main, thanks!
I'm still getting the following error on version 0.9.0 when I type commands such as :Telescope f
Error while fetching completions: Vim:E5108: Error executing Lua function: attempt to call a number value