Setting multiple values for Vim command -complete attribute

I am trying to enable command completion for a custom command that I am setting up for a plugin in the following manner:

command! -complete=shellcmd -nargs=* EScratch call s:ShellScratch(<f-args>)

I would like to enable complete options for shellcmd and file. However it seems that the complete attribute would only take 1 option.

To give a bit more context as to what I am trying to achieve: I am working on a plugin to create a simple scratch buffer. I would like to be able to run a shell command from the command mode and copy the output to the scratch buffer. I have been able to achieve all this but it would be much more productive to have auto completion similar to shell. The complete script can be viewed here https://github.com/ifthikhan/vimscratch/blob/master/plugin/vimscratch.vim. Any pointers will be highly appreciated.

Answers


Unfortunately, you can't. If you really need this, you have to either

  • define two separate commands, e.g. :ScratchShell and :ScratchFile, with the corresponding completions, or
  • use a -complete=custom[list] and provide your own complete function, where you have to re-implement both sources yourself. Filename completion actually is quite easily done with glob(); I'm not so sure about shell commands.

Need Your Help

How to assign a function in Lua for a randomly generated numbers

function random lua corona

First I stored 10 images in array(i.e., table) from 1-10 as key values and I create a random number using math.random function between 0-9.,