-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_nvim
More file actions
executable file
·79 lines (62 loc) · 2.73 KB
/
update_nvim
File metadata and controls
executable file
·79 lines (62 loc) · 2.73 KB
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
#!/bin/bash
. ./functions
NVIM_REPO="https://github.com/neovim/neovim"
NVIM_CONFIG_URL="https://github.com/kthenrique/nvim.git"
function set_default_editor {
notify "WARNING" "Removing vi* & nano"
sudo apt purge nano vim* vi &> /dev/null
sudo rm -rf /usr/local/bin/nvim /usr/local/bin/vim /usr/local/bin/vi
sudo rm -rf /usr/bin/nvim /usr/bin/vim /usr/bin/vi
notify "INFO" "Configuring neovim as default editor . . ."
sudo ln -s /usr/local/bin/nvim /usr/bin/nvim
sudo ln -s $HOME/.local/bin/nvim /usr/local/bin/nvim
sudo update-alternatives --install /usr/bin/editor editor /usr/bin/nvim 100
#sudo update-alternatives --config editor
sudo update-alternatives --install /usr/bin/vi vi "$(command -v nvim)" 60
#sudo update-alternatives --config vi
sudo update-alternatives --install /usr/bin/vim vim "$(command -v nvim)" 60
#sudo update-alternatives --config vim
}
function set_personal_config {
notify "INFO" "Installing neovim init configs . . ."
(cd /home/$USER/.config/ && \
git clone "$NVIM_CONFIG_URL" && \
cd nvim && git checkout lua && \
nvim --cmd :PackerSync --cmd :qa && \
nvim --cmd :MasonInstallRequired --cmd :qa || return 1)
}
function install_build_dependencies {
notify "INFO" "Installing build dependencies . . ."
(install_dependency pkg-config automake libtool libtool-bin gettext global cmake) || \
(notify "ERROR" "Failed to install build dependencies for neovim" && return 1)
}
function install_runtime_dependencies {
notify "INFO" "Installing runtime dependencies . . ."
(install_dependency luarocks ripgrep fonts-powerline npm python3-pip xsel python3-pynvim && \
install_npm_dependency neovim) || \
(notify "ERROR" "Failed to install runtime dependencies for neovim" && return 1)
return $?
}
function build_neovim {
install_build_dependencies || return 1
notify "INFO" "Cloning neovim stable . . ."
( (git clone -q --depth 1 --branch stable "$NVIM_REPO" &>/dev/null) || \
(notify "ERROR" "Failed to clone neovim" && return 1) ) && \
( (notify "INFO" "Building neovim from sources. . .") && \
(cd neovim && make -j 12 CMAKE_BUILD_TYPE=Release CMAKE_INSTALL_PREFIX=$PWD/build/install install) &> /dev/null || \
(notify "ERROR" "Failed to build neovim" && (rm -rf ./neovim || exit 0) && return 1) )
}
# CD into the folder to hold the sources
RETURN=$PWD
mkdir -p $HOME/.local/bin
cd $HOME/.local/bin || exit 1
# Build neovim from sources
build_neovim || exit 1
# Link it to PATH and cd-return
notify "INFO" "Linking nvim in $HOME/.local/bin . . ."
ln -s $HOME/.local/bin/neovim/build/bin/nvim
cd $RETURN || exit 1
# Install other dependencies
install_runtime_dependencies
notify "INFO" "SUCCESS"
set_default_editor