Currently, commands implementing -completion=custom[list] use a reference to a function like so, as shown in E1303 in map.txt
" The following example lists user names to a Finger command com -complete=custom,ListUsers -nargs=1 Finger !finger <args> fun ListUsers(A,L,P) return system("cut -d: -f1 /etc/passwd") endfun " The following example completes filenames from the directories specified in the 'path' option com -nargs=1 -bang -complete=customlist,EditFileComplete \ EditFile edit<bang> <args> fun EditFileComplete(A,L,P) return split(globpath(&path, a:A), "\n") endfun
Both of these are actually excellent examples of how in simple cases, a lambda could be used to inline the command implementation to a single declaration, as seen below.
" The following example lists user names to a Finger command com -nargs=1 -complete=custom,{A,L,P -> system("cut -d: -f1 /etc/passwd")} \ Finger !finger <args> " The following example completes filenames from the directories specified in the 'path' option com -nargs=1 -bang -complete=customlist,{A,L,P -> split(globpath(&path, a:A), "\n")} \ EditFile edit<bang> <args>
I wasn't able to find any other issues describing this request, which is surprising to me to the point of raising doubts about my own ability to find stuff on this platform, so apologies if this is a dupe of a closed issue.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Why not create a new function, like create_command()? With that way, Vimscript syntax doesn't have to update at all, but you can still pass a lambda as its parameter.
I think :command is almost never used directly in cmdline, so it has always made much more senses for it to be a function instead of a command.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Something like nvim's nvim_create_user_command?
That would definitely be useful, especially in a scripting context.
Also less work to implement, and less of a blast radius for testing/bugs.
I guess my only reservation is that it doesn't feel as 'vimmy' as using the existing command! ... syntax.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Vim9script support multi-line lambda without any line-continuation character, so I'm sure it will be a headache to implement this for :command
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()