I have a command line tool that requires three parameters in the form of:
command input1 input2
I'm trying to write a custom complete function that handles completion for different arguments... well, differently.
Determining which argument I'm on and returning a different set of completion options isn't hard; I've got that figured out:
function! CustomCompletion(argLead, line, pos) let argList = split(a:line) if len(argList) == 1 " Do completion for arg 1 (the command) elseif len(argList) == 2 " Do completion for arg 2 elseif len(argList) == 3 " Do completion for arg 3 endif endfunction
My problem is with the "argLead" variable.
:h command-completion-custom says this:
ArgLead: the leading portion of the argument currently being completed on.
Places Iv'e researched seem to imply that this variable contains the current white-space separated argument that the cursor is on. However whenever I use it, the variable contains the whole command line (spaces and all). Additionally when I press tab after say, the second argument, the tab completion tries to match the whole command line instead just the current argument.
Is there some way to tell the completion function to parse args based on white-space?
Oh, and I'm calling this function in the thrid paramater of input() if that makes any difference.
let user = input("Enter a command\n", "", "custom,CustomCompletion")