vim-maktaba
vim-maktaba copied to clipboard
Add helpers for command completion
Vim's command completion interface is fine for simple commands, but pretty awkward for more complex commands like :Glaive that can't necessarily base completion just on ArgLead
(the last partial arg on the command line), and have to do complex processing on CmdLine
using CursorPos
and parse out the command name, leading modifiers and whatnot to handle command lines like ": ::4,'XGlaive! …".
Maktaba should include some utilities to bridge the gap between vim's completion interface and what you need to write powerful completion functions easily.
One utility that might help would be a maktaba#complete#ParseCmdline()
that would split out the command name, modifiers like range and bang, and the <f-args>
and <q-args>
values. Might also be important to be able to interpret CursorPos
in terms of that data so you know if it's e.g. at the end of the last arg, in the middle of the command, or whatever.
This is a fantastic idea. It could do for command line completion what kana/vim-textobj-user did for text objects.