[bugfix] sourcing script will break variables

This commit is contained in:
Klesh Wong 2020-11-23 15:54:48 +08:00
parent 181ff8c759
commit a63bfa014d
8 changed files with 46 additions and 24 deletions

View File

@ -5,7 +5,7 @@ DIR=$(dirname "$(readlink -f "$0")")
. "$DIR/../env.sh"
if ! has_cmd python
. "$PDIR/devel/python.sh"
"$PDIR/devel/python.sh"
fi
log 'Setting up ranger'

View File

@ -9,32 +9,35 @@ log 'Setting up vim'
# check dependencies
if [ "$VIM_MODE" = "enhanced" ]; then
if ! has_cmd node; then
. "$PDIR/devel/nodejs.sh"
"$PDIR/devel/nodejs.sh"
fi
if ! has_cmd python; then
. "$PDIR/devel/python.sh"
"$PDIR/devel/python.sh"
fi
fi
# install nvim
case "$PM" in
apt)
sudo add-apt-repository ppa:neovim-ppa/stable -y
sudo apt update
sudo apt install -y neovim
if [ "$VIM_MODE" = "enhanced" ]; then
sudo pip3 install pyvim neovim
fi
;;
pacman)
sudo pacman -S --noconfirm --needed neovim
if [ "$VIM_MODE" = "enhanced" ]; then
sudo pip install pyvim neovim
fi
;;
esac
if ! has_cmd "$VIM"; then
case "$PM" in
apt)
sudo add-apt-repository ppa:neovim-ppa/stable -y
sudo apt update
sudo apt install -y neovim
if enhance_vim; then
sudo pip3 install pyvim neovim
fi
;;
pacman)
sudo pacman -S --noconfirm --needed neovim
if enhance_vim; then
sudo pip install pyvim neovim
fi
;;
esac
fi
# symlink configuration
sudo ln -sf "$(command -v nvim)" /usr/bin/v
lnsf "$DIR/vim/init.vim" "$XDG_CONFIG_HOME/nvim/init.vim"
lnsf "$DIR/vim/coc-settings.json" "$XDG_CONFIG_HOME/nvim/coc-settings.json"
lnsf "$DIR/vim/coc-settings.json" "$HOME/.vim/coc-settings.json"

View File

@ -15,9 +15,12 @@ case "$PM" in
esac
# live server for html previewing
. "$PDIR/devel/nodejs.sh"
sudo $NPM_BIN install -g live-server
"$PDIR/devel/nodejs.sh"
if in_china; then
sudo cnpm install -g live-server
else
sudo npm install -g live-server
fi
# convert to html with embeded <style>: cmark-gfm input.md --to html --unsafe > /path/to/output.html
# entr watch input.md and rerun convert command
# live-server to observe html file and reload browser

View File

@ -11,7 +11,7 @@ case "$PM" in
sudo snap remove --purge docker
sudo apt install -y docker.io
if ! has_cmd python; then
. "$PDIR/python/install.sh"
"$PDIR/python/install.sh"
fi
sudo pip3 install docker-compose
;;

View File

@ -22,6 +22,9 @@ lspkgs() {
| jq '.[] | "\(.version) \(if .lts then "(lts)" else "" end)"' -r
}
cocsetup() {
}
uninstall() {
if [ -f "$FILES_PATH" ]; then
tac "$FILES_PATH" | grep -v '/$' | xargs sudo rm -f
@ -63,6 +66,9 @@ install() {
if in_china; then
sudo npm install -g cnpm --registry=https://registry.npm.taobao.org
fi
if enhance_vim; then
v -c "CocInstall -sync coc-json coc-vetur coc-tsserver coc-eslint|qall"
fi
}

View File

@ -39,3 +39,9 @@ if has_cmd fish; then
source $HOME/.cargo/env
" | sed 's/^ *//' > "$XDG_CONFIG_HOME/fish/conf.d/cargo.fish"
fi
# coc.nvim
if enhance_vim; then
rustup component add rls rust-analysis rust-src
v -c "CocInstall -sync coc-rls|qall"
fi

4
env.sh
View File

@ -80,6 +80,10 @@ has_fish() {
has_cmd "$1"
}
enhance_vim() {
[ "$VIM_MODE" = "enhanced" ] && has_cmd nvim
}
sudo mkdir -p $PREFIX

View File

@ -5,7 +5,7 @@ DIR=$(dirname "$(readlink -f "$0")")
. "$DIR/../env.sh"
if ! has_cmd python; then
. "$PDIR/python/install.sh"
"$PDIR/python/install.sh"
fi
log 'Setting up picom'