Skip to content

Commit 22fec2b

Browse files
bronzehedwickrobbyoconnor
authored andcommitted
Preliminary support for neovim
A simple change to support neovim. Fixes spf13#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 spf13#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.
1 parent 1503a60 commit 22fec2b

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

bootstrap.sh

+20-4
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,21 @@ debug() {
4747

4848
program_exists() {
4949
local ret='0'
50-
type $1 >/dev/null 2>&1 || { local ret='1'; }
50+
command -v $1 >/dev/null 2>&1 || { local ret='1'; }
51+
52+
# fail on non-zero return value
53+
if [ "$ret" -ne 0 ]; then
54+
return 1
55+
fi
56+
57+
return 0
58+
}
59+
60+
program_must_exist() {
61+
program_exists $1
5162

5263
# throw error on non-zero return value
53-
if [ ! "$ret" -eq '0' ]; then
64+
if [ "$?" -ne 0 ]; then
5465
error "You must have '$1' installed to continue."
5566
fi
5667
}
@@ -115,6 +126,11 @@ create_symlinks() {
115126
lnif "$source_path/.vimrc.before" "$target_path/.vimrc.before"
116127
lnif "$source_path/.vim" "$target_path/.vim"
117128

129+
if program_exists "nvim"; then
130+
lnif "$source_path/.vim" "$target_path/.nvim"
131+
lnif "$source_path/.vimrc" "$target_path/.nvim/nvimrc"
132+
fi
133+
118134
touch "$target_path/.vimrc.local"
119135

120136
ret="$?"
@@ -160,8 +176,8 @@ setup_vundle() {
160176

161177
############################ MAIN()
162178
variable_set "$HOME"
163-
program_exists "vim"
164-
program_exists "git"
179+
program_must_exist "vim"
180+
program_must_exist "git"
165181

166182
do_backup "$HOME/.vim" \
167183
"$HOME/.vimrc" \

0 commit comments

Comments
 (0)