google / vim-maktaba

Consistent Vimscript
Apache License 2.0
591 stars 42 forks source link

Add helpers for command completion #26

Open dbarnett opened 10 years ago

dbarnett commented 10 years ago

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.

dbarnett commented 10 years ago

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.

chiphogg commented 10 years ago

This is a fantastic idea. It could do for command line completion what kana/vim-textobj-user did for text objects.