-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy patheditor_setup
135 lines (99 loc) · 2.43 KB
/
editor_setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
#source environment
# Constants ########
readonly WAITLONG=3
readonly WAITSMALL=1
####################
# Install Neovim Code editor
# Main function
main(){
echo ">>> Installing Neovim ..."
echo "# Neovim is a robust terminal code editor that is forked from Vim"
install neovim
# Configure Neovim
configure_neovim
# Clean up
rm -rf env
}
# The installation function
install()
{
sleep $WAITLONG
pkg install -y $1
}
# Configure Neovim
configure_neovim()
{
echo ">>> Setup Neovim ..."
sleep $WAITSMALL
# Install vim-plug
curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
# Ensure ~/.config/nvim has been created
NVIMDIR=~/.config/nvim
if [[ ! -d "$NVIMDIR" ]]
then
mkdir -p $NVIMDIR
fi
# Ensure ~/env/init.vim exists
NVIMFILE=~/env/init.vim
if [[ ! -f "$NVIMFILE" ]]
then
git clone https://github.com/scripts/files/env ~/env
fi
# Copy the Neovim config file to ~/.config/nvim
cp $NVIMFILE $NVIMDIR
# Select Max or Mini
echo "Do you want the full installation? Y/n"
read SIZE
if [ "${SIZE,,}" = "y" ]; then
neovim_plugins
else
neovim_plugins mini
fi
}
# Configure COC on NVIM and enable language support
neovim_lang_support ()
{
if [ "${2,,}" = "y" ]; then
REPLY="Y"
else
echo "Enable $1 support for Neovim? Y/n"
read REPLY
fi
if [ "${REPLY,,}" = "y" ]; then
nvim +"CocInstall -sync coc-${1^^}" +qall
echo "Enabled $1
+++++++"
sleep $WAITSMALL
else
echo "${1^^} not enabled
-------"
fi
}
neovim_plugins()
{
# Run :PlugInstall on Neovim to install plugins in the config directory
echo ">>> Installing Neovim plugins ..."
sleep $WAITSMALL
nvim --headless +PlugInstall +qall
# Install Prettier
echo "Installing prettier ..."
nvim +'CocInstall -sync coc-prettier' +qall
# For a mini installation
if [ "${1,,}" != "mini" ]; then
# Install languages support for Neovim
languages=(css html tsserver pyright phpls yaml git sql json bash)
# Ascertain if user would like to autoinstall Neovim language support plugins
echo "Auto install all languages support in Neovim? Y/n"
read ALLYES
for lang in "${languages[@]}"; do neovim_lang_support $lang $ALLYES; done
fi
# Finalize config
echo "
Finalizing Neovim plugin configurations"
sleep $WAITLONG
nvim +CocUpdateSync +qall
}
# Main App
main