Preliminary support for neovim

A simple change to support neovim. Fixes #774.

Move nvimrc file inside .nvim directory

Only install neovim support if neovim is being used

Use program_exists function instead of vimscript

Made a hasty mistake and added vimscript to a bash script :X

Neovim not existing no longer stops script

Also correct `endif` to `fi`.

Refactor program_exists naming

Changed `program_exists` to `program_must_exist`, which throws an error which halts the script if the program is not found, and refactored `nvim_exists` to be the more general `program_exists`, which does not throw an error if the program is not found.

Refactor program_exists and program_must_exist

`program_must_exist` uses `program_exists` now, instead of repeating code. Changed `type` to `command -v` in `program_exists` to be more POSIX compliant. Refactored status code conditional in `program_exists` to remove double negatives. Thanks to @mkwmms for the suggestions.

Preliminary support for neovim

A simple change to support neovim. Fixes #774.

Move nvimrc file inside .nvim directory

Refactor program_exists naming

Changed `program_exists` to `program_must_exist`, which throws an error which halts the script if the program is not found, and refactored `nvim_exists` to be the more general `program_exists`, which does not throw an error if the program is not found.

Refactor program_exists and program_must_exist

`program_must_exist` uses `program_exists` now, instead of repeating code. Changed `type` to `command -v` in `program_exists` to be more POSIX compliant. Refactored status code conditional in `program_exists` to remove double negatives. Thanks to @mkwmms for the suggestions.
This commit is contained in:
Chris DeLuca 2015-05-11 17:30:27 -04:00
parent 91d3d8edc6
commit 9f78da8736

View File

@ -47,10 +47,21 @@ debug() {
program_exists() {
local ret='0'
type $1 >/dev/null 2>&1 || { local ret='1'; }
command -v $1 >/dev/null 2>&1 || { local ret='1'; }
# fail on non-zero return value
if [ "$ret" -ne 0 ]; then
return 1
fi
return 0
}
program_must_exist() {
program_exists $1
# throw error on non-zero return value
if [ ! "$ret" -eq '0' ]; then
if [ "$?" -ne 0 ]; then
error "You must have '$1' installed to continue."
fi
}
@ -115,6 +126,11 @@ create_symlinks() {
lnif "$source_path/.vimrc.before" "$target_path/.vimrc.before"
lnif "$source_path/.vim" "$target_path/.vim"
if program_exists "nvim"; then
lnif "$source_path/.vim" "$target_path/.nvim"
lnif "$source_path/.vimrc" "$target_path/.nvim/nvimrc"
fi
touch "$target_path/.vimrc.local"
ret="$?"
@ -160,8 +176,8 @@ setup_vundle() {
############################ MAIN()
variable_set "$HOME"
program_exists "vim"
program_exists "git"
program_must_exist "vim"
program_must_exist "git"
do_backup "$HOME/.vim" \
"$HOME/.vimrc" \