From fb1379b7c23e84321625ac30365bb2bfff7f569a Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Sun, 15 Nov 2020 16:03:08 +0100 Subject: vim-plugins.bash completion --- bash/vim-plugins.bash | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/bash/vim-plugins.bash b/bash/vim-plugins.bash index f987531..1b8d7c6 100644 --- a/bash/vim-plugins.bash +++ b/bash/vim-plugins.bash @@ -4,10 +4,10 @@ function vim-add() { local NAME=$(basename "$1") [ -d "$DOTFILEBASE/.vim/bundle/$NAME" ] || return 1 # no such plugin + [ -L "$DOTFILEBASE/.vim/bundle-active/$NAME" ] && return 2 # Already exists local OLD_PWD=$(pwd) cd "$DOTFILEBASE/.vim/bundle-active/" - [ -L $NAME ] && cd "$OLD_PWD" && return 2 # Already exists ln -s "../bundle/$NAME" @@ -18,4 +18,44 @@ function vim-remove { source ~/.files local NAME=$(basename "$1") + + [ -L "$DOTFILEBASE/.vim/bundle-active/$NAME" ] || exit 1 + rm "$DOTFILEBASE/.vim/bundle-active/$NAME" +} + +function _vim_plugins { + source ~/.files + local cur prev opts plugin + + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="" + + for plugin in $DOTFILEBASE/.vim/bundle/*/; do + opts+=" $(basename $plugin)" + done + + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 } + +function _vim_plugins_active { + source ~/.files + local cur prev opts plugin + + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="" + + for plugin in $DOTFILEBASE/.vim/bundle-active/*/; do + opts+=" $(basename $plugin)" + done + + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 +} + +complete -F _vim_plugins vim-add +complete -F _vim_plugins_active vim-remove -- cgit v1.2.3