Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the LazyVIM extras more modular based on the installed dev language #269

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 53 additions & 38 deletions install/terminal/select-dev-language.sh
Original file line number Diff line number Diff line change
@@ -1,45 +1,60 @@
# Install default programming languages
if [[ -v OMAKUB_FIRST_RUN_LANGUAGES ]]; then
languages=$OMAKUB_FIRST_RUN_LANGUAGES
languages=$OMAKUB_FIRST_RUN_LANGUAGES
else
AVAILABLE_LANGUAGES=("Ruby on Rails" "Node.js" "Go" "PHP" "Python" "Elixir" "Rust" "Java")
languages=$(gum choose "${AVAILABLE_LANGUAGES[@]}" --no-limit --height 10 --header "Select programming languages")
AVAILABLE_LANGUAGES=("Ruby on Rails" "Node.js" "Go" "PHP" "Python" "Elixir" "Rust" "Java")
languages=$(gum choose "${AVAILABLE_LANGUAGES[@]}" --no-limit --height 10 --header "Select programming languages")
fi

enable_lazyvim_extras() {
local config_file="$HOME/.config/nvim/lazyvim.json"
local extras=("$@")

local extras_json
extras_json=$(printf '"%s",' "${extras[@]}")
extras_json="[${extras_json%,}]"

# This is cheating to mimic an in-place editing of files (without a tmp file)...
{ rm "$config_file" && jq --argjson extras "$extras_json" '.extras |= (. + $extras | unique)' >"$config_file"; } <"$config_file"
}

if [[ -n "$languages" ]]; then
for language in $languages; do
case $language in
Ruby)
mise use --global [email protected]
mise x ruby -- gem install rails --no-document
;;
Node.js)
mise use --global node@lts
;;
Go)
mise use --global go@latest
;;
PHP)
sudo add-apt-repository -y ppa:ondrej/php
sudo apt -y install php8.4 php8.4-{curl,apcu,intl,mbstring,opcache,pgsql,mysql,sqlite3,redis,xml,zip}
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --quiet && sudo mv composer.phar /usr/local/bin/composer
rm composer-setup.php
;;
Python)
mise use --global python@latest
;;
Elixir)
mise use --global erlang@latest
mise use --global elixir@latest
mise x elixir -- mix local.hex --force
;;
Rust)
bash -c "$(curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs)" -- -y
;;
Java)
mise use --global java@latest
;;
esac
done
for language in $languages; do
case $language in
Ruby)
mise use --global [email protected]
mise x ruby -- gem install rails --no-document
;;
Node.js)
mise use --global node@lts
enable_lazyvim_extras "lazyvim.plugins.extras.lang.typescript"
;;
Go)
mise use --global go@latest
enable_lazyvim_extras "lazyvim.plugins.extras.lang.go"
;;
PHP)
sudo add-apt-repository -y ppa:ondrej/php
sudo apt -y install php8.4 php8.4-{curl,apcu,intl,mbstring,opcache,pgsql,mysql,sqlite3,redis,xml,zip}
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --quiet && sudo mv composer.phar /usr/local/bin/composer
rm composer-setup.php
enable_lazyvim_extras "lazyvim.plugins.extras.lang.php"
;;
Python)
mise use --global python@latest
;;
Elixir)
mise use --global erlang@latest
mise use --global elixir@latest
mise x elixir -- mix local.hex --force
;;
Rust)
bash -c "$(curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs)" -- -y
;;
Java)
mise use --global java@latest
;;
esac
done
fi