" Complete using bash-completion. Requires the bash script "docomplete", " available from http://s-z.org/neil/progs/docomplete . " " Copyright © 2007,2008 Neil Moore " All rights reserved. " " Redistribution and use, with or without modification, are permitted " provided that the following conditions are met: " " 1. Redistributions must retain the above copyright notice, this list " of conditions and the following disclaimer. " " 2. The name of the author may not be used to endorse or promote " products derived from this script without specific prior written " permission. " " THIS SCRIPT IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS " OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED " WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE " DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, " INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES " (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR " SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) " HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, " STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING " IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE " POSSIBILITY OF SUCH DAMAGE. " BUGS: " " Assumes Posix/Bourne shell, and probably has problems if 'sxq' is set. " Any bugs in docomplete (q.v.) will, of course, show up here. " Probably many, many others. " Return the single argument, quoted so it can be used as a shell argument. function! QuoteArg(arg) return "'" . substitute(a:arg, "'", "'\\\\''", "g") . "'" endfun " Call a command-line specified as a list. The first argument is the " command name; the remaining are the command arguments. The command " and arguments are all single-quoted to prevent shell mishaps. function! System(...) return system(join(map(copy(a:000), 'QuoteArg(v:val)'), " ")) endfun function! CompleteBash(findstart, base) if a:findstart return 0 else let l:butlast = substitute(a:base, "[^[:space:]]\\+$", "", "") let l:expr = "{'word': l:butlast . v:val, 'abbr': v:val}" return map(split(System("docomplete", a:base), "\n"), l:expr) endif endfun set completefunc=CompleteBash