From a3344203818658441d176fe279e1978505940432 Mon Sep 17 00:00:00 2001 From: Andrew Fridley <34749972+afridley@users.noreply.github.com> Date: Thu, 12 Aug 2021 00:49:37 -0500 Subject: Please... reverse history and cycle next telescope bindings (#1276) --- utils/installer/config.example-no-ts.lua | 13 +++++++++++++ utils/installer/config.example.lua | 13 +++++++++++++ 2 files changed, 26 insertions(+) (limited to 'utils') diff --git a/utils/installer/config.example-no-ts.lua b/utils/installer/config.example-no-ts.lua index 4303d264..b0de00f0 100644 --- a/utils/installer/config.example-no-ts.lua +++ b/utils/installer/config.example-no-ts.lua @@ -14,6 +14,19 @@ lvim.keys.normal_mode[""] = ":w" -- edit a default keymapping -- lvim.keys.normal_mode[""] = ":q" +-- Change Telescope navigation to use j and k for navigation and n and p for history in both input and normal mode. +-- lvim.builtin.telescope.on_config_done = function() +-- local actions = require "telescope.actions" +-- -- for input mode +-- lvim.builtin.telescope.defaults.mappings.i[""] = actions.move_selection_next +-- lvim.builtin.telescope.defaults.mappings.i[""] = actions.move_selection_previous +-- lvim.builtin.telescope.defaults.mappings.i[""] = actions.cycle_history_next +-- lvim.builtin.telescope.defaults.mappings.i[""] = actions.cycle_history_prev +-- -- for normal mode +-- lvim.builtin.telescope.defaults.mappings.n[""] = actions.move_selection_next +-- lvim.builtin.telescope.defaults.mappings.n[""] = actions.move_selection_previous +-- end + -- Use which-key to add extra bindings with the leader-key prefix -- lvim.builtin.which_key.mappings["P"] = { "lua require'telescope'.extensions.project.project{}", "Projects" } -- lvim.builtin.which_key.mappings["t"] = { diff --git a/utils/installer/config.example.lua b/utils/installer/config.example.lua index 0aee0275..1c39a571 100644 --- a/utils/installer/config.example.lua +++ b/utils/installer/config.example.lua @@ -23,6 +23,19 @@ lvim.keys.normal_mode[""] = ":w" -- edit a default keymapping -- lvim.keys.normal_mode[""] = ":q" +-- Change Telescope navigation to use j and k for navigation and n and p for history in both input and normal mode. +-- lvim.builtin.telescope.on_config_done = function() +-- local actions = require "telescope.actions" +-- -- for input mode +-- lvim.builtin.telescope.defaults.mappings.i[""] = actions.move_selection_next +-- lvim.builtin.telescope.defaults.mappings.i[""] = actions.move_selection_previous +-- lvim.builtin.telescope.defaults.mappings.i[""] = actions.cycle_history_next +-- lvim.builtin.telescope.defaults.mappings.i[""] = actions.cycle_history_prev +-- -- for normal mode +-- lvim.builtin.telescope.defaults.mappings.n[""] = actions.move_selection_next +-- lvim.builtin.telescope.defaults.mappings.n[""] = actions.move_selection_previous +-- end + -- Use which-key to add extra bindings with the leader-key prefix -- lvim.builtin.which_key.mappings["P"] = { "lua require'telescope'.extensions.project.project{}", "Projects" } -- lvim.builtin.which_key.mappings["t"] = { -- cgit v1.2.3 From 03b7da74eee555064741fbc54e667eb918e8aa52 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Thu, 12 Aug 2021 11:31:31 +0200 Subject: Fix formatting according to style-guide (#1057) --- utils/bin/jdtls | 62 ++++---- utils/installer/install.sh | 292 +++++++++++++++++++------------------- utils/installer/install_stylua.sh | 76 +++++----- utils/installer/uninstall.sh | 8 +- 4 files changed, 219 insertions(+), 219 deletions(-) (limited to 'utils') diff --git a/utils/bin/jdtls b/utils/bin/jdtls index adfd5e20..2b0f226a 100755 --- a/utils/bin/jdtls +++ b/utils/bin/jdtls @@ -8,31 +8,31 @@ # to point to the `config_mac' or `config_win` folders depending on your system. case Darwin in -Linux) - CONFIG="$HOME/.local/share/nvim/lspinstall/java/config_linux" - ;; -Darwin) - CONFIG="$HOME/.local/share/nvim/lspinstall/java/config_mac" - ;; + Linux) + CONFIG="$HOME/.local/share/nvim/lspinstall/java/config_linux" + ;; + Darwin) + CONFIG="$HOME/.local/share/nvim/lspinstall/java/config_mac" + ;; esac # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ]; then - if [ -x "$JAVA_HOME/jre/sh/java" ]; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ]; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ]; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME Please set the JAVA_HOME variable in your environment to match the location of your Java installation." - fi + fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." @@ -41,20 +41,20 @@ fi # JAR="$HOME/.config/nvim/.language-servers/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/plugins/org.eclipse.equinox.launcher_*.jar" JAR="$HOME/.local/share/nvim/lspinstall/java/plugins/org.eclipse.equinox.launcher_*.jar" GRADLE_HOME=$HOME/gradle "$JAVACMD" \ - -Declipse.application=org.eclipse.jdt.ls.core.id1 \ - -Dosgi.bundles.defaultStartLevel=4 \ - -Declipse.product=org.eclipse.jdt.ls.core.product \ - -Dlog.protocol=true \ - -Dlog.level=ALL \ - -javaagent:$HOME/.local/share/nvim/lspinstall/java/lombok.jar \ - -Xms1g \ - -Xmx2G \ - -jar $(echo "$JAR") \ - -configuration "$CONFIG" \ - -data "${1:-$HOME/workspace}" \ - --add-modules=ALL-SYSTEM \ - --add-opens java.base/java.util=ALL-UNNAMED \ - --add-opens java.base/java.lang=ALL-UNNAMED + -Declipse.application=org.eclipse.jdt.ls.core.id1 \ + -Dosgi.bundles.defaultStartLevel=4 \ + -Declipse.product=org.eclipse.jdt.ls.core.product \ + -Dlog.protocol=true \ + -Dlog.level=ALL \ + -javaagent:$HOME/.local/share/nvim/lspinstall/java/lombok.jar \ + -Xms1g \ + -Xmx2G \ + -jar $(echo "$JAR") \ + -configuration "$CONFIG" \ + -data "${1:-$HOME/workspace}" \ + --add-modules=ALL-SYSTEM \ + --add-opens java.base/java.util=ALL-UNNAMED \ + --add-opens java.base/java.lang=ALL-UNNAMED # for older java versions if you wanna use lombok # -Xbootclasspath/a:/usr/local/share/lombok/lombok.jar \ diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 25b67f12..98040344 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -6,227 +6,227 @@ set -o nounset # error when referencing undefined variable set -o errexit # exit when command fails installnodemac() { - brew install lua - brew install node - brew install yarn + brew install lua + brew install node + brew install yarn } installnodeubuntu() { - sudo apt install nodejs - sudo apt install npm + sudo apt install nodejs + sudo apt install npm } installnodetermux() { - apt install nodejs + apt install nodejs } moveoldlvim() { - echo "Not installing LunarVim" - echo "Please move your ~/.local/share/lunarvim folder before installing" - exit + echo "Not installing LunarVim" + echo "Please move your ~/.local/share/lunarvim folder before installing" + exit } installnodearch() { - sudo pacman -S nodejs - sudo pacman -S npm + sudo pacman -S nodejs + sudo pacman -S npm } installnodefedora() { - sudo dnf install -y nodejs - sudo dnf install -y npm + sudo dnf install -y nodejs + sudo dnf install -y npm } installnodegentoo() { - echo "Printing current node status..." - emerge -pqv net-libs/nodejs - echo "Make sure the npm USE flag is enabled for net-libs/nodejs" - echo "If it isn't enabled, would you like to enable it with flaggie? (Y/N)" - read -r answer - [ "$answer" != "${answer#[Yy]}" ] && sudo flaggie net-libs/nodejs +npm - sudo emerge -avnN net-libs/nodejs + echo "Printing current node status..." + emerge -pqv net-libs/nodejs + echo "Make sure the npm USE flag is enabled for net-libs/nodejs" + echo "If it isn't enabled, would you like to enable it with flaggie? (Y/N)" + read -r answer + [ "$answer" != "${answer#[Yy]}" ] && sudo flaggie net-libs/nodejs +npm + sudo emerge -avnN net-libs/nodejs } installnode() { - echo "Installing node..." - [ "$(uname)" = "Darwin" ] && installnodemac - grep -q Ubuntu /etc/os-release && installnodeubuntu - [ -f "/etc/arch-release" ] && installnodearch - [ -f "/etc/artix-release" ] && installnodearch - [ -f "/etc/fedora-release" ] && installnodefedora - [ -f "/etc/gentoo-release" ] && installnodegentoo - [ -d "/data/data/com.termux" ] && installnodetermux - [ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported" - sudo npm i -g neovim + echo "Installing node..." + [ "$(uname)" = "Darwin" ] && installnodemac + grep -q Ubuntu /etc/os-release && installnodeubuntu + [ -f "/etc/arch-release" ] && installnodearch + [ -f "/etc/artix-release" ] && installnodearch + [ -f "/etc/fedora-release" ] && installnodefedora + [ -f "/etc/gentoo-release" ] && installnodegentoo + [ -d "/data/data/com.termux" ] && installnodetermux + [ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported" + sudo npm i -g neovim } installpiponmac() { - sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py - python3 get-pip.py - rm get-pip.py + sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py + python3 get-pip.py + rm get-pip.py } installpiponubuntu() { - sudo apt install python3-pip >/dev/null + sudo apt install python3-pip >/dev/null } installpipontermux() { - apt install python + apt install python } installpiponarch() { - sudo pacman -S python-pip + sudo pacman -S python-pip } installpiponfedora() { - sudo dnf install -y pip >/dev/null + sudo dnf install -y pip >/dev/null } installpipongentoo() { - sudo emerge -avn dev-python/pip + sudo emerge -avn dev-python/pip } installpip() { - echo "Installing pip..." - [ "$(uname)" = "Darwin" ] && installpiponmac - grep -q Ubuntu /etc/os-release && installpiponubuntu - [ -f "/etc/arch-release" ] && installpiponarch - [ -f "/etc/fedora-release" ] && installpiponfedora - [ -f "/etc/gentoo-release" ] && installpipongentoo - [ -d "/data/data/com.termux" ] && installpipontermux - [ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported" + echo "Installing pip..." + [ "$(uname)" = "Darwin" ] && installpiponmac + grep -q Ubuntu /etc/os-release && installpiponubuntu + [ -f "/etc/arch-release" ] && installpiponarch + [ -f "/etc/fedora-release" ] && installpiponfedora + [ -f "/etc/gentoo-release" ] && installpipongentoo + [ -d "/data/data/com.termux" ] && installpipontermux + [ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported" } installpynvim() { - echo "Installing pynvim..." - if [ -f "/etc/gentoo-release" ]; then - echo "Installing using Portage" - sudo emerge -avn dev-python/pynvim - else - pip3 install pynvim --user - fi + echo "Installing pynvim..." + if [ -f "/etc/gentoo-release" ]; then + echo "Installing using Portage" + sudo emerge -avn dev-python/pynvim + else + pip3 install pynvim --user + fi } installpacker() { - git clone https://github.com/wbthomason/packer.nvim ~/.local/share/lunarvim/site/pack/packer/start/packer.nvim + git clone https://github.com/wbthomason/packer.nvim ~/.local/share/lunarvim/site/pack/packer/start/packer.nvim } cloneconfig() { - if [ -d "/data/data/com.termux" ]; then - sudo() { - eval "$@" - } - USER_BIN_DIR="$HOME/../usr/bin" - fi - echo "Cloning LunarVim configuration" - mkdir -p ~/.local/share/lunarvim - case "$@" in - - *--testing*) - cp -r "$(pwd)" ~/.local/share/lunarvim/lvim - ;; - *) - git clone --branch "$LVBRANCH" https://github.com/lunarvim/lunarvim.git ~/.local/share/lunarvim/lvim - ;; - esac - mkdir -p "$HOME/.config/lvim" - sudo cp "$HOME/.local/share/lunarvim/lvim/utils/bin/lvim" "$USER_BIN_DIR" - sudo chmod a+rx "$USER_BIN_DIR"/lvim - cp "$HOME/.local/share/lunarvim/lvim/utils/installer/config.example-no-ts.lua" "$HOME/.config/lvim/config.lua" - - nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" --headless \ - +'autocmd User PackerComplete sleep 100m | qall' \ - +PackerInstall - - nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" --headless \ - +'autocmd User PackerComplete sleep 100m | qall' \ - +PackerSync - - printf "\nCompile Complete\n" - - if [ -e "$HOME/.local/share/lunarvim/lvim/init.lua" ]; then - echo 'config.lua already present' - else - cp "$HOME/.local/share/lunarvim/lvim/utils/installer/config.example.lua" "$HOME/.config/lvim/config.lua" - fi + if [ -d "/data/data/com.termux" ]; then + sudo() { + eval "$@" + } + USER_BIN_DIR="$HOME/../usr/bin" + fi + echo "Cloning LunarVim configuration" + mkdir -p ~/.local/share/lunarvim + case "$@" in + + *--testing*) + cp -r "$(pwd)" ~/.local/share/lunarvim/lvim + ;; + *) + git clone --branch "$LVBRANCH" https://github.com/lunarvim/lunarvim.git ~/.local/share/lunarvim/lvim + ;; + esac + mkdir -p "$HOME/.config/lvim" + sudo cp "$HOME/.local/share/lunarvim/lvim/utils/bin/lvim" "$USER_BIN_DIR" + sudo chmod a+rx "$USER_BIN_DIR"/lvim + cp "$HOME/.local/share/lunarvim/lvim/utils/installer/config.example-no-ts.lua" "$HOME/.config/lvim/config.lua" + + nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" --headless \ + +'autocmd User PackerComplete sleep 100m | qall' \ + +PackerInstall + + nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" --headless \ + +'autocmd User PackerComplete sleep 100m | qall' \ + +PackerSync + + printf "\nCompile Complete\n" + + if [ -e "$HOME/.local/share/lunarvim/lvim/init.lua" ]; then + echo 'config.lua already present' + else + cp "$HOME/.local/share/lunarvim/lvim/utils/installer/config.example.lua" "$HOME/.config/lvim/config.lua" + fi } asktoinstallnode() { - echo "node not found" - printf "Would you like to install node now (y/n)? " - read -r answer - [ "$answer" != "${answer#[Yy]}" ] && installnode + echo "node not found" + printf "Would you like to install node now (y/n)? " + read -r answer + [ "$answer" != "${answer#[Yy]}" ] && installnode } asktoinstallgit() { - echo "git not found, please install git" - exit + echo "git not found, please install git" + exit } asktoinstallpip() { - # echo "pip not found" - # echo -n "Would you like to install pip now (y/n)? " - # read answer - # [ "$answer" != "${answer#[Yy]}" ] && installpip - echo "Please install pip3 before continuing with install" - exit + # echo "pip not found" + # echo -n "Would you like to install pip now (y/n)? " + # read answer + # [ "$answer" != "${answer#[Yy]}" ] && installpip + echo "Please install pip3 before continuing with install" + exit } installonmac() { - brew install ripgrep fzf - npm install -g tree-sitter-cli + brew install ripgrep fzf + npm install -g tree-sitter-cli } installonubuntu() { - sudo apt install ripgrep fzf - sudo apt install libjpeg8-dev zlib1g-dev python-dev python3-dev libxtst-dev - pip3 install neovim-remote - npm install -g tree-sitter-cli + sudo apt install ripgrep fzf + sudo apt install libjpeg8-dev zlib1g-dev python-dev python3-dev libxtst-dev + pip3 install neovim-remote + npm install -g tree-sitter-cli } installtermux() { - apt install ripgrep fzf - pip install neovim-remote - npm install -g tree-sitter-cli + apt install ripgrep fzf + pip install neovim-remote + npm install -g tree-sitter-cli } installonarch() { - sudo pacman -S ripgrep fzf - pip3 install neovim-remote - npm install -g tree-sitter-cli + sudo pacman -S ripgrep fzf + pip3 install neovim-remote + npm install -g tree-sitter-cli } installonfedora() { - sudo dnf groupinstall "X Software Development" - sudo dnf install -y fzf ripgrep + sudo dnf groupinstall "X Software Development" + sudo dnf install -y fzf ripgrep } installongentoo() { - sudo emerge -avn sys-apps/ripgrep app-shells/fzf dev-python/neovim-remote virtual/jpeg sys-libs/zlib - npm install -g tree-sitter-cli + sudo emerge -avn sys-apps/ripgrep app-shells/fzf dev-python/neovim-remote virtual/jpeg sys-libs/zlib + npm install -g tree-sitter-cli } installextrapackages() { - [ "$(uname)" = "Darwin" ] && installonmac - grep -q Ubuntu /etc/os-release && installonubuntu - [ -f "/etc/arch-release" ] && installonarch - [ -f "/etc/artix-release" ] && installonarch - [ -f "/etc/fedora-release" ] && installonfedora - [ -f "/etc/gentoo-release" ] && installongentoo - [ -d "/data/data/com.termux" ] && installtermux - [ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported" + [ "$(uname)" = "Darwin" ] && installonmac + grep -q Ubuntu /etc/os-release && installonubuntu + [ -f "/etc/arch-release" ] && installonarch + [ -f "/etc/artix-release" ] && installonarch + [ -f "/etc/fedora-release" ] && installonfedora + [ -f "/etc/gentoo-release" ] && installongentoo + [ -d "/data/data/com.termux" ] && installtermux + [ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported" } # Welcome echo 'Installing LunarVim' case "$@" in -*--overwrite*) - echo '!!Warning!! -> Removing all lunarvim related config because of the --overwrite flag' - rm -rf "$HOME/.local/share/lunarvim" - rm -rf "$HOME/.cache/nvim" - rm -rf "$HOME/.config/lvim" - ;; + *--overwrite*) + echo '!!Warning!! -> Removing all lunarvim related config because of the --overwrite flag' + rm -rf "$HOME/.local/share/lunarvim" + rm -rf "$HOME/.cache/nvim" + rm -rf "$HOME/.config/lvim" + ;; esac # move old lvim directory if it exists @@ -245,27 +245,27 @@ esac (pip3 list | grep pynvim >/dev/null && echo "pynvim installed, moving on...") || installpynvim if [ -e "$HOME/.local/share/lunarvim/site/pack/packer/start/packer.nvim" ]; then - echo 'packer already installed' + echo 'packer already installed' else - installpacker + installpacker fi if [ -e "$HOME/.local/share/lunarvim/lvim/init.lua" ]; then - echo 'LunarVim already installed' + echo 'LunarVim already installed' else - # clone config down - cloneconfig "$@" - # echo 'export PATH=$HOME/.config/nvim/utils/bin:$PATH' >>~/.zshrc - # echo 'export PATH=$HOME/.config/lunarvim/utils/bin:$PATH' >>~/.bashrc + # clone config down + cloneconfig "$@" + # echo 'export PATH=$HOME/.config/nvim/utils/bin:$PATH' >>~/.zshrc + # echo 'export PATH=$HOME/.config/lunarvim/utils/bin:$PATH' >>~/.bashrc fi if [ "$(uname)" != "Darwin" ]; then - if [ -e "$HOME/.local/share/applications/lvim.desktop" ]; then - echo 'Desktop file already available' - else - mkdir -p "$HOME/.local/share/applications" - cp "$HOME/.local/share/lunarvim/lvim/utils/desktop/lvim.desktop" "$HOME/.local/share/applications/lvim.desktop" - fi + if [ -e "$HOME/.local/share/applications/lvim.desktop" ]; then + echo 'Desktop file already available' + else + mkdir -p "$HOME/.local/share/applications" + cp "$HOME/.local/share/lunarvim/lvim/utils/desktop/lvim.desktop" "$HOME/.local/share/applications/lvim.desktop" + fi fi echo "I recommend you also install and activate a font from here: https://github.com/ryanoasis/nerd-fonts" diff --git a/utils/installer/install_stylua.sh b/utils/installer/install_stylua.sh index 2a33de7e..963416ea 100755 --- a/utils/installer/install_stylua.sh +++ b/utils/installer/install_stylua.sh @@ -11,53 +11,53 @@ declare -r FILENAME="stylua-$RELEASE-$OS" declare -a __deps=("curl" "unzip") function check_deps() { - for dep in "${__deps[@]}"; do - if ! command -v "$dep" >/dev/null; then - echo "Missing depdendecy!" - echo "The \"$dep\" command was not found!. Please install and try again." - fi - done + for dep in "${__deps[@]}"; do + if ! command -v "$dep" >/dev/null; then + echo "Missing depdendecy!" + echo "The \"$dep\" command was not found!. Please install and try again." + fi + done } function download_stylua() { - local DOWNLOAD_DIR - local URL="https://github.com/JohnnyMorganz/StyLua/releases/download/v$RELEASE/$FILENAME.zip" - - DOWNLOAD_DIR="$(mktemp -d)" - echo "Initiating download for Stylua v$RELEASE" - if ! curl --progress-bar --fail -L "$URL" -o "$DOWNLOAD_DIR/$FILENAME.zip"; then - echo "Download failed. Check that the release/filename are correct." - exit 1 - fi - - echo "Installation in progress.." - unzip -q "$DOWNLOAD_DIR/$FILENAME.zip" -d "$DOWNLOAD_DIR" - - if [ -f "$DOWNLOAD_DIR/stylua" ]; then - mv "$DOWNLOAD_DIR/stylua" "$INSTALL_DIR/stylua" - else - mv "$DOWNLOAD_DIR/$FILENAME/stylua" "$INSTALL_DIR/." - fi - - chmod u+x "$INSTALL_DIR/stylua" + local DOWNLOAD_DIR + local URL="https://github.com/JohnnyMorganz/StyLua/releases/download/v$RELEASE/$FILENAME.zip" + + DOWNLOAD_DIR="$(mktemp -d)" + echo "Initiating download for Stylua v$RELEASE" + if ! curl --progress-bar --fail -L "$URL" -o "$DOWNLOAD_DIR/$FILENAME.zip"; then + echo "Download failed. Check that the release/filename are correct." + exit 1 + fi + + echo "Installation in progress.." + unzip -q "$DOWNLOAD_DIR/$FILENAME.zip" -d "$DOWNLOAD_DIR" + + if [ -f "$DOWNLOAD_DIR/stylua" ]; then + mv "$DOWNLOAD_DIR/stylua" "$INSTALL_DIR/stylua" + else + mv "$DOWNLOAD_DIR/$FILENAME/stylua" "$INSTALL_DIR/." + fi + + chmod u+x "$INSTALL_DIR/stylua" } function verify_install() { - echo "Verifying installation.." - local DOWNLOADED_VER - DOWNLOADED_VER="$("$INSTALL_DIR/stylua" -V | awk '{ print $2 }')" - if [ "$DOWNLOADED_VER" != "$RELEASE" ]; then - echo "Mismatched version!" - echo "Expected: v$RELEASE but got v$DOWNLOADED_VER" - exit 1 - fi - echo "Verification complete!" + echo "Verifying installation.." + local DOWNLOADED_VER + DOWNLOADED_VER="$("$INSTALL_DIR/stylua" -V | awk '{ print $2 }')" + if [ "$DOWNLOADED_VER" != "$RELEASE" ]; then + echo "Mismatched version!" + echo "Expected: v$RELEASE but got v$DOWNLOADED_VER" + exit 1 + fi + echo "Verification complete!" } function main() { - check_deps - download_stylua - verify_install + check_deps + download_stylua + verify_install } main "$@" diff --git a/utils/installer/uninstall.sh b/utils/installer/uninstall.sh index b9a27252..8d9d039a 100755 --- a/utils/installer/uninstall.sh +++ b/utils/installer/uninstall.sh @@ -1,10 +1,10 @@ #!/bin/sh USER_BIN_DIR="/usr/local/bin" if [ -d "/data/data/com.termux" ]; then - sudo() { - eval "$@" - } - USER_BIN_DIR="$HOME/../usr/bin" + sudo() { + eval "$@" + } + USER_BIN_DIR="$HOME/../usr/bin" fi rm -rf ~/.local/share/lunarvim sudo rm "$USER_BIN_DIR"/lvim -- cgit v1.2.3 From 988c74ec5665250c572dcc6bae018ed0ea180c25 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Fri, 13 Aug 2021 12:11:18 +0200 Subject: feat: Add pre-commit hook for linting and formatting (#1132) * feat: Add pre-commit hook for linting and formatting * format with prettier --- utils/bin/jdtls | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'utils') diff --git a/utils/bin/jdtls b/utils/bin/jdtls index 2b0f226a..961d2df5 100755 --- a/utils/bin/jdtls +++ b/utils/bin/jdtls @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# shellcheck disable=SC2116 # NOTE: # This doesn't work as is on Windows. You'll need to create an equivalent `.bat` file instead @@ -7,7 +8,8 @@ # If you're not using Linux you'll need to adjust the `-configuration` option # to point to the `config_mac' or `config_win` folders depending on your system. -case Darwin in +OS="$(uname -s)" +case "$OS" in Linux) CONFIG="$HOME/.local/share/nvim/lspinstall/java/config_linux" ;; @@ -32,7 +34,7 @@ location of your Java installation." fi else JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + command -v java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." @@ -46,10 +48,10 @@ GRADLE_HOME=$HOME/gradle "$JAVACMD" \ -Declipse.product=org.eclipse.jdt.ls.core.product \ -Dlog.protocol=true \ -Dlog.level=ALL \ - -javaagent:$HOME/.local/share/nvim/lspinstall/java/lombok.jar \ + -javaagent:"$HOME/.local/share/nvim/lspinstall/java/lombok.jar" \ -Xms1g \ -Xmx2G \ - -jar $(echo "$JAR") \ + -jar "$(echo "$JAR")" \ -configuration "$CONFIG" \ -data "${1:-$HOME/workspace}" \ --add-modules=ALL-SYSTEM \ -- cgit v1.2.3 From 1fbc34cf1d3c2ec5500ddb6e14f04751680d969f Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sun, 15 Aug 2021 18:01:37 +0200 Subject: Fix slow CI by installing a neovim binary directly (#1059) --- utils/bin/install-latest-neovim | 9 ---- utils/installer/install-neovim-from-release | 83 +++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 9 deletions(-) delete mode 100755 utils/bin/install-latest-neovim create mode 100755 utils/installer/install-neovim-from-release (limited to 'utils') diff --git a/utils/bin/install-latest-neovim b/utils/bin/install-latest-neovim deleted file mode 100755 index 8d1d95fd..00000000 --- a/utils/bin/install-latest-neovim +++ /dev/null @@ -1,9 +0,0 @@ -!#/bin/bash -cd ~ -sudo rm -r neovim -git clone --branch master --depth 1 https://github.com/neovim/neovim -cd neovim -sudo make CMAKE_BUILD_TYPE=Release install -cd ~ -sudo rm -r neovim - diff --git a/utils/installer/install-neovim-from-release b/utils/installer/install-neovim-from-release new file mode 100755 index 00000000..a2ba0513 --- /dev/null +++ b/utils/installer/install-neovim-from-release @@ -0,0 +1,83 @@ +#!/usr/bin/env bash + +set -eu pipefall + +declare -r LV_INSTALL_PREFIX="${INSTALL_PREFIX:-"$HOME/.local"}" +declare -r RELEASE_VER="${RELEASE_VER:-latest}" # can be set to nightly + +declare ARCHIVE_NAME +declare RELEASE_NAME +declare OS + +OS="$(uname -s)" + +if [ "$OS" == "Linux" ]; then + ARCHIVE_NAME="nvim-linux64" + RELEASE_NAME="nvim-linux64" +elif [ "$OS" == "Darwin" ]; then + ARCHIVE_NAME="nvim-macos" + # for some reason the archive has a different name + RELEASE_NAME="nvim-osx64" +else + echo "$OS platform is not supported currently" + exit 1 +fi + +declare -r RELEASE_URL="https://github.com/neovim/neovim/releases/$RELEASE_VER/download/$ARCHIVE_NAME.tar.gz" +declare -r CHECKSUM_URL="$RELEASE_URL.sha256sum" + +DOWNLOAD_DIR="$(mktemp -d)" +readonly DOWNLOAD_DIR + +RELEASE_SHA="$(curl -Ls "$CHECKSUM_URL" | awk '{print $1}')" +readonly RELEASE_SHA + +function main() { + if [ ! -d "$LV_INSTALL_PREFIX" ]; then + mkdir -p "$LV_INSTALL_PREFIX" || __invalid__prefix__handler + fi + download_neovim + verify_neovim + install_neovim +} + +function download_neovim() { + echo "Downloading Neovim's binary from $RELEASE_VER release.." + if ! curl --progress-bar --fail -L "$RELEASE_URL" -o "$DOWNLOAD_DIR/$ARCHIVE_NAME.tar.gz"; then + echo "Download failed. Check that the release/filename are correct." + exit 1 + fi + echo "Download complete!" +} + +function verify_neovim() { + echo "Verifying the installation.." + DOWNLOADED_SHA="$(sha256sum "$DOWNLOAD_DIR/$ARCHIVE_NAME.tar.gz" | awk '{print $1}')" + + if [ "$RELEASE_SHA" != "$DOWNLOADED_SHA" ]; then + echo "Error! checksum mis-match." + echo "Expected: $RELEASE_SHA but got: $DOWNLOADED_SHA" + exit 1 + fi + echo "Verification complete!" +} + +function install_neovim() { + + echo "Installing Neovim.." + pushd "$DOWNLOAD_DIR" + tar -xzf "$DOWNLOAD_DIR/$ARCHIVE_NAME.tar.gz" + popd + # https://dev.to/ackshaey/macos-vs-linux-the-cp-command-will-trip-you-up-2p00 + cp -r "$DOWNLOAD_DIR/$RELEASE_NAME/." "$LV_INSTALL_PREFIX" + echo "Installation complete!" + echo "Now you can run $LV_INSTALL_PREFIX/bin/nvim" +} + +function __invalid__prefix__handler() { + echo "Error! Invalid value for LV_INSTALL_PREFIX: [$INSTALL_PREFIX]" + echo "Please verify that the folder exists and re-run the installer!" + exit 1 +} + +main "$@" -- cgit v1.2.3 From ae1dea8b6499afbc35d3386654f9d0d8d208d342 Mon Sep 17 00:00:00 2001 From: dklymenk <64093836+dklymenk@users.noreply.github.com> Date: Mon, 16 Aug 2021 16:31:03 +0300 Subject: [Feature] Expose null ls setup to user config (#1323) * expose null_ls setup to user config * add new config to example configs * fix tabs with stylua * change else statement in the example --- utils/installer/config.example-no-ts.lua | 15 +++++++++++++++ utils/installer/config.example.lua | 15 +++++++++++++++ 2 files changed, 30 insertions(+) (limited to 'utils') diff --git a/utils/installer/config.example-no-ts.lua b/utils/installer/config.example-no-ts.lua index b0de00f0..e5c24274 100644 --- a/utils/installer/config.example-no-ts.lua +++ b/utils/installer/config.example-no-ts.lua @@ -61,6 +61,21 @@ lvim.builtin.treesitter.highlight.enabled = true -- --Enable completion triggered by -- buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") -- end +-- you can overwrite the null_ls setup table (useful for setting the root_dir function) +-- lvim.lsp.null_ls.setup = { +-- root_dir = require("lspconfig").util.root_pattern("Makefile", ".git", "node_modules"), +-- } +-- or if you need something more advanced +-- lvim.lsp.null_ls.setup.root_dir = function(fname) +-- if vim.bo.filetype == "javascript" then +-- return require("lspconfig/util").root_pattern("Makefile", ".git", "node_modules")(fname) +-- or require("lspconfig/util").path.dirname(fname) +-- elseif vim.bo.filetype == "php" then +-- return require("lspconfig/util").root_pattern("Makefile", ".git", "composer.json")(fname) or vim.fn.getcwd() +-- else +-- return require("lspconfig/util").root_pattern("Makefile", ".git")(fname) or require("lspconfig/util").path.dirname(fname) +-- end +-- end -- set a formatter if you want to override the default lsp one (if it exists) -- lvim.lang.python.formatters = { diff --git a/utils/installer/config.example.lua b/utils/installer/config.example.lua index 1c39a571..2f8984bb 100644 --- a/utils/installer/config.example.lua +++ b/utils/installer/config.example.lua @@ -70,6 +70,21 @@ lvim.builtin.treesitter.highlight.enabled = true -- --Enable completion triggered by -- buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") -- end +-- you can overwrite the null_ls setup table (useful for setting the root_dir function) +-- lvim.lsp.null_ls.setup = { +-- root_dir = require("lspconfig").util.root_pattern("Makefile", ".git", "node_modules"), +-- } +-- or if you need something more advanced +-- lvim.lsp.null_ls.setup.root_dir = function(fname) +-- if vim.bo.filetype == "javascript" then +-- return require("lspconfig/util").root_pattern("Makefile", ".git", "node_modules")(fname) +-- or require("lspconfig/util").path.dirname(fname) +-- elseif vim.bo.filetype == "php" then +-- return require("lspconfig/util").root_pattern("Makefile", ".git", "composer.json")(fname) or vim.fn.getcwd() +-- else +-- return require("lspconfig/util").root_pattern("Makefile", ".git")(fname) or require("lspconfig/util").path.dirname(fname) +-- end +-- end -- set a formatter if you want to override the default lsp one (if it exists) -- lvim.lang.python.formatters = { -- cgit v1.2.3 From c76cc0ea8ae793b4feb0c28407d0f0de104aef43 Mon Sep 17 00:00:00 2001 From: christianchiarulli Date: Mon, 16 Aug 2021 20:10:53 -0400 Subject: fix java again, this file cannot be formatted, don't ask me why, because I have no idea --- utils/bin/jdtls | 66 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 34 deletions(-) (limited to 'utils') diff --git a/utils/bin/jdtls b/utils/bin/jdtls index 961d2df5..adfd5e20 100755 --- a/utils/bin/jdtls +++ b/utils/bin/jdtls @@ -1,5 +1,4 @@ #!/usr/bin/env bash -# shellcheck disable=SC2116 # NOTE: # This doesn't work as is on Windows. You'll need to create an equivalent `.bat` file instead @@ -8,33 +7,32 @@ # If you're not using Linux you'll need to adjust the `-configuration` option # to point to the `config_mac' or `config_win` folders depending on your system. -OS="$(uname -s)" -case "$OS" in - Linux) - CONFIG="$HOME/.local/share/nvim/lspinstall/java/config_linux" - ;; - Darwin) - CONFIG="$HOME/.local/share/nvim/lspinstall/java/config_mac" - ;; +case Darwin in +Linux) + CONFIG="$HOME/.local/share/nvim/lspinstall/java/config_linux" + ;; +Darwin) + CONFIG="$HOME/.local/share/nvim/lspinstall/java/config_mac" + ;; esac # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ]; then - if [ -x "$JAVA_HOME/jre/sh/java" ]; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ]; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ]; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME Please set the JAVA_HOME variable in your environment to match the location of your Java installation." - fi + fi else - JAVACMD="java" - command -v java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." @@ -43,20 +41,20 @@ fi # JAR="$HOME/.config/nvim/.language-servers/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/plugins/org.eclipse.equinox.launcher_*.jar" JAR="$HOME/.local/share/nvim/lspinstall/java/plugins/org.eclipse.equinox.launcher_*.jar" GRADLE_HOME=$HOME/gradle "$JAVACMD" \ - -Declipse.application=org.eclipse.jdt.ls.core.id1 \ - -Dosgi.bundles.defaultStartLevel=4 \ - -Declipse.product=org.eclipse.jdt.ls.core.product \ - -Dlog.protocol=true \ - -Dlog.level=ALL \ - -javaagent:"$HOME/.local/share/nvim/lspinstall/java/lombok.jar" \ - -Xms1g \ - -Xmx2G \ - -jar "$(echo "$JAR")" \ - -configuration "$CONFIG" \ - -data "${1:-$HOME/workspace}" \ - --add-modules=ALL-SYSTEM \ - --add-opens java.base/java.util=ALL-UNNAMED \ - --add-opens java.base/java.lang=ALL-UNNAMED + -Declipse.application=org.eclipse.jdt.ls.core.id1 \ + -Dosgi.bundles.defaultStartLevel=4 \ + -Declipse.product=org.eclipse.jdt.ls.core.product \ + -Dlog.protocol=true \ + -Dlog.level=ALL \ + -javaagent:$HOME/.local/share/nvim/lspinstall/java/lombok.jar \ + -Xms1g \ + -Xmx2G \ + -jar $(echo "$JAR") \ + -configuration "$CONFIG" \ + -data "${1:-$HOME/workspace}" \ + --add-modules=ALL-SYSTEM \ + --add-opens java.base/java.util=ALL-UNNAMED \ + --add-opens java.base/java.lang=ALL-UNNAMED # for older java versions if you wanna use lombok # -Xbootclasspath/a:/usr/local/share/lombok/lombok.jar \ -- cgit v1.2.3 From 33640834e4b07a8e9c5a6707ec0eadd863011ac0 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Fri, 20 Aug 2021 22:59:40 +0200 Subject: fix: set runtime directories correctly (#1354) * fix: set runtime directories correctly This also simplifies the way to invoke LunarVim to just be: `nvim -u "$LUNARVIM_RUNTIME_DIR/lvim/init.lua"` Fixes #1352 * use libuv to get homedir path --- utils/bin/lvim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'utils') diff --git a/utils/bin/lvim b/utils/bin/lvim index b94d544f..c55ddda7 100755 --- a/utils/bin/lvim +++ b/utils/bin/lvim @@ -1,3 +1,5 @@ #!/bin/sh -exec nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" "$@" +LUNARVIM_RUNTIME_DIR=${LUNARVIM_RUNTIME_DIR:-"$HOME/.local/share/lunarvim"} + +exec nvim -u "$LUNARVIM_RUNTIME_DIR"/lvim/init.lua "$@" -- cgit v1.2.3 From 10091859a29e16f38b6eaca64db59308ddf24138 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Mon, 23 Aug 2021 08:21:17 +0430 Subject: Update config.example.lua --- utils/installer/config.example.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils') diff --git a/utils/installer/config.example.lua b/utils/installer/config.example.lua index 2f8984bb..c2c75fbb 100644 --- a/utils/installer/config.example.lua +++ b/utils/installer/config.example.lua @@ -37,7 +37,7 @@ lvim.keys.normal_mode[""] = ":w" -- end -- Use which-key to add extra bindings with the leader-key prefix --- lvim.builtin.which_key.mappings["P"] = { "lua require'telescope'.extensions.project.project{}", "Projects" } +-- lvim.builtin.which_key.mappings["P"] = { "Telescope projects", "Projects" } -- lvim.builtin.which_key.mappings["t"] = { -- name = "+Trouble", -- r = { "Trouble lsp_references", "References" }, -- cgit v1.2.3 From cc166d05039ac0dda71c4d17f2378f9c5bf2b4eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Vl=C4=8Dinsk=C3=BD?= Date: Mon, 23 Aug 2021 11:36:12 +0200 Subject: fix telescope.project call in sample config (without ts) (#1380) --- utils/installer/config.example-no-ts.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils') diff --git a/utils/installer/config.example-no-ts.lua b/utils/installer/config.example-no-ts.lua index e5c24274..aad13fe0 100644 --- a/utils/installer/config.example-no-ts.lua +++ b/utils/installer/config.example-no-ts.lua @@ -28,7 +28,7 @@ lvim.keys.normal_mode[""] = ":w" -- end -- Use which-key to add extra bindings with the leader-key prefix --- lvim.builtin.which_key.mappings["P"] = { "lua require'telescope'.extensions.project.project{}", "Projects" } +-- lvim.builtin.which_key.mappings["P"] = { "Telescope projects", "Projects" } -- lvim.builtin.which_key.mappings["t"] = { -- name = "+Trouble", -- r = { "Trouble lsp_references", "References" }, -- cgit v1.2.3 From 101c6834333ffb06856155054ea77747819ef5fc Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Mon, 23 Aug 2021 17:18:42 +0200 Subject: [Refactor] Installer v2 with support for backup (#1052) --- utils/bin/lvim | 5 +- utils/installer/install.sh | 456 +++++++++++++++++++++++---------------------- 2 files changed, 239 insertions(+), 222 deletions(-) mode change 100755 => 100644 utils/bin/lvim (limited to 'utils') diff --git a/utils/bin/lvim b/utils/bin/lvim old mode 100755 new mode 100644 index c55ddda7..2303be3c --- a/utils/bin/lvim +++ b/utils/bin/lvim @@ -1,5 +1,6 @@ #!/bin/sh -LUNARVIM_RUNTIME_DIR=${LUNARVIM_RUNTIME_DIR:-"$HOME/.local/share/lunarvim"} +export LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-$HOME/.local/share/lunarvim}" +export LUNARVIM_CONFIG_DIR="${LUNARVIM_RUNTIME_DIR:-$HOME/.config/lvim}" -exec nvim -u "$LUNARVIM_RUNTIME_DIR"/lvim/init.lua "$@" +exec nvim -u "$LUNARVIM_RUNTIME_DIR/lvim/init.lua" "$@" diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 98040344..989f5595 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -1,272 +1,288 @@ -#!/bin/sh -#Set Variable to master is not set differently -LVBRANCH="${LVBRANCH:-master}" -USER_BIN_DIR="/usr/local/bin" -set -o nounset # error when referencing undefined variable -set -o errexit # exit when command fails - -installnodemac() { - brew install lua - brew install node - brew install yarn -} +#!/usr/bin/env bash +set -eo pipefail -installnodeubuntu() { - sudo apt install nodejs - sudo apt install npm -} +#Set branch to master unless specified by the user +declare -r LV_BRANCH="${LV_BRANCH:-rolling}" +declare -r LV_REMOTE="${LV_REMOTE:-lunarvim/lunarvim.git}" +declare -r INSTALL_PREFIX="${INSTALL_PREFIX:-"$HOME/.local"}" -installnodetermux() { - apt install nodejs -} +declare -r XDG_DATA_HOME="${XDG_DATA_HOME:-"$HOME/.local/share"}" +declare -r XDG_CACHE_HOME="${XDG_CACHE_HOME:-"$HOME/.cache"}" +declare -r XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-"$HOME/.config"}" -moveoldlvim() { - echo "Not installing LunarVim" - echo "Please move your ~/.local/share/lunarvim folder before installing" - exit -} +# TODO: Use a dedicated cache directory #1256 +declare -r NEOVIM_CACHE_DIR="$XDG_CACHE_HOME/nvim" -installnodearch() { - sudo pacman -S nodejs - sudo pacman -S npm -} +declare -r LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-"$XDG_DATA_HOME/lunarvim"}" +declare -r LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-"$XDG_CONFIG_HOME/lvim"}" -installnodefedora() { - sudo dnf install -y nodejs - sudo dnf install -y npm -} +declare -a __lvim_dirs=( + "$LUNARVIM_CONFIG_DIR" + "$LUNARVIM_RUNTIME_DIR" + "$NEOVIM_CACHE_DIR" # for now this is shared with neovim +) -installnodegentoo() { - echo "Printing current node status..." - emerge -pqv net-libs/nodejs - echo "Make sure the npm USE flag is enabled for net-libs/nodejs" - echo "If it isn't enabled, would you like to enable it with flaggie? (Y/N)" - read -r answer - [ "$answer" != "${answer#[Yy]}" ] && sudo flaggie net-libs/nodejs +npm - sudo emerge -avnN net-libs/nodejs -} +declare -a __npm_deps=( + "neovim" + "tree-sitter-cli" +) -installnode() { - echo "Installing node..." - [ "$(uname)" = "Darwin" ] && installnodemac - grep -q Ubuntu /etc/os-release && installnodeubuntu - [ -f "/etc/arch-release" ] && installnodearch - [ -f "/etc/artix-release" ] && installnodearch - [ -f "/etc/fedora-release" ] && installnodefedora - [ -f "/etc/gentoo-release" ] && installnodegentoo - [ -d "/data/data/com.termux" ] && installnodetermux - [ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported" - sudo npm i -g neovim -} +declare -a __pip_deps=( + "pynvim" +) -installpiponmac() { - sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py - python3 get-pip.py - rm get-pip.py -} +function main() { + cat <<'EOF' -installpiponubuntu() { - sudo apt install python3-pip >/dev/null -} + 88\ 88\ + 88 | \__| + 88 |88\ 88\ 888888$\ 888888\ 888888\ 88\ 88\ 88\ 888888\8888\ + 88 |88 | 88 |88 __88\ \____88\ 88 __88\\88\ 88 |88 |88 _88 _88\ + 88 |88 | 88 |88 | 88 | 888888$ |88 | \__|\88\88 / 88 |88 / 88 / 88 | + 88 |88 | 88 |88 | 88 |88 __88 |88 | \88$ / 88 |88 | 88 | 88 | + 88 |\888888 |88 | 88 |\888888$ |88 | \$ / 88 |88 | 88 | 88 | + \__| \______/ \__| \__| \_______|\__| \_/ \__|\__| \__| \__| -installpipontermux() { - apt install python -} +EOF -installpiponarch() { - sudo pacman -S python-pip -} + __add_separator "80" -installpiponfedora() { - sudo dnf install -y pip >/dev/null -} + echo "Detecting platform for managing any additional neovim dependencies" + detect_platform -installpipongentoo() { - sudo emerge -avn dev-python/pip -} + # skip this in a Github workflow + if [ -z "$GITHUB_ACTIONS" ]; then + check_system_deps -installpip() { - echo "Installing pip..." - [ "$(uname)" = "Darwin" ] && installpiponmac - grep -q Ubuntu /etc/os-release && installpiponubuntu - [ -f "/etc/arch-release" ] && installpiponarch - [ -f "/etc/fedora-release" ] && installpiponfedora - [ -f "/etc/gentoo-release" ] && installpipongentoo - [ -d "/data/data/com.termux" ] && installpipontermux - [ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported" -} + __add_separator "80" + + echo "Would you like to check lunarvim's NodeJS dependencies?" + read -p "[y]es or [n]o (default: no) : " -r answer + [ "$answer" != "${answer#[Yy]}" ] && install_nodejs_deps + + echo "Would you like to check lunarvim's Python dependencies?" + read -p "[y]es or [n]o (default: no) : " -r answer + [ "$answer" != "${answer#[Yy]}" ] && install_python_deps + + echo "Would you like to check lunarvim's Rust dependencies?" + read -p "[y]es or [n]o (default: no) : " -r answer + [ "$answer" != "${answer#[Yy]}" ] && install_rust_deps -installpynvim() { - echo "Installing pynvim..." - if [ -f "/etc/gentoo-release" ]; then - echo "Installing using Portage" - sudo emerge -avn dev-python/pynvim + __add_separator "80" + + echo "Backing up old LunarVim configuration" + backup_old_config + + __add_separator "80" + + fi + + case "$@" in + *--overwrite*) + echo "!!Warning!! -> Removing all lunarvim related config \ + because of the --overwrite flag" + read -p "Would you like to continue? [y]es or [n]o : " -r answer + [ "$answer" == "${answer#[Yy]}" ] && exit 1 + for dir in "${__lvim_dirs[@]}"; do + [ -d "$dir" ] && rm -rf "$dir" + done + ;; + esac + + if [ -e "$LUNARVIM_RUNTIME_DIR/site/pack/packer/start/packer.nvim" ]; then + echo "Packer already installed" else - pip3 install pynvim --user + install_packer fi -} -installpacker() { - git clone https://github.com/wbthomason/packer.nvim ~/.local/share/lunarvim/site/pack/packer/start/packer.nvim -} + __add_separator "80" -cloneconfig() { - if [ -d "/data/data/com.termux" ]; then - sudo() { - eval "$@" - } - USER_BIN_DIR="$HOME/../usr/bin" + if [ -e "$LUNARVIM_RUNTIME_DIR/lvim/init.lua" ]; then + echo "Updating LunarVim" + update_lvim + else + clone_lvim + setup_lvim fi - echo "Cloning LunarVim configuration" - mkdir -p ~/.local/share/lunarvim - case "$@" in - *--testing*) - cp -r "$(pwd)" ~/.local/share/lunarvim/lvim + __add_separator "80" + +} + +function detect_platform() { + OS="$(uname -s)" + case "$OS" in + Linux) + if [ -f "/etc/arch-release" ] || [ -f "/etc/artix-release" ]; then + RECOMMEND_INSTALL="sudo pacman -S" + elif [ -f "/etc/fedora-release" ] || [ -f "/etc/redhat-release" ]; then + RECOMMEND_INSTALL="sudo dnf install -y" + elif [ -f "/etc/gentoo-release" ]; then + RECOMMEND_INSTALL="emerge install -y" + else # assume debian based + RECOMMEND_INSTALL="sudo apt install -y" + fi + ;; + Darwin) + RECOMMEND_INSTALL="brew install" ;; *) - git clone --branch "$LVBRANCH" https://github.com/lunarvim/lunarvim.git ~/.local/share/lunarvim/lvim + echo "OS $OS is not currently supported." + exit 1 ;; esac - mkdir -p "$HOME/.config/lvim" - sudo cp "$HOME/.local/share/lunarvim/lvim/utils/bin/lvim" "$USER_BIN_DIR" - sudo chmod a+rx "$USER_BIN_DIR"/lvim - cp "$HOME/.local/share/lunarvim/lvim/utils/installer/config.example-no-ts.lua" "$HOME/.config/lvim/config.lua" - - nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" --headless \ - +'autocmd User PackerComplete sleep 100m | qall' \ - +PackerInstall - - nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" --headless \ - +'autocmd User PackerComplete sleep 100m | qall' \ - +PackerSync +} - printf "\nCompile Complete\n" +function print_missing_dep_msg() { + echo "[ERROR]: Unable to find dependency [$1]" + echo "Please install it first and re-run the installer. Try: $RECOMMEND_INSTALL $1" +} - if [ -e "$HOME/.local/share/lunarvim/lvim/init.lua" ]; then - echo 'config.lua already present' - else - cp "$HOME/.local/share/lunarvim/lvim/utils/installer/config.example.lua" "$HOME/.config/lvim/config.lua" +function check_dep() { + if ! command -v "$1" &>/dev/null; then + print_missing_dep_msg "$1" + exit 1 fi - } -asktoinstallnode() { - echo "node not found" - printf "Would you like to install node now (y/n)? " - read -r answer - [ "$answer" != "${answer#[Yy]}" ] && installnode +function check_system_deps() { + if ! command -v git &>/dev/null; then + print_missing_dep_msg "git" + exit 1 + fi + if ! command -v nvim &>/dev/null; then + print_missing_dep_msg "neovim" + exit 1 + fi } -asktoinstallgit() { - echo "git not found, please install git" - exit +function install_nodejs_deps() { + check_dep "npm" + echo "Installing node modules with npm.." + for dep in "${__npm_deps[@]}"; do + if ! npm ls -g "$dep" &>/dev/null; then + printf "installing %s .." "$dep" + npm install -g "$dep" + fi + done + echo "All NodeJS dependencies are succesfully installed" } -asktoinstallpip() { - # echo "pip not found" - # echo -n "Would you like to install pip now (y/n)? " - # read answer - # [ "$answer" != "${answer#[Yy]}" ] && installpip - echo "Please install pip3 before continuing with install" - exit +function install_python_deps() { + echo "Verifying that pip is available.." + if ! python3 -m ensurepip &>/dev/null; then + print_missing_dep_msg "pip" + exit 1 + fi + echo "Installing with pip.." + for dep in "${__pip_deps[@]}"; do + pip3 install --user "$dep" + done + echo "All Python dependencies are succesfully installed" } -installonmac() { - brew install ripgrep fzf - npm install -g tree-sitter-cli +function __attempt_to_install_with_cargo() { + if ! command -v cargo &>/dev/null; then + echo "Installing missing Rust dependency with cargo" + cargo install "$1" + else + echo "[WARN]: Unable to find fd. Make sure to install it to avoid any problems" + fi } -installonubuntu() { - sudo apt install ripgrep fzf - sudo apt install libjpeg8-dev zlib1g-dev python-dev python3-dev libxtst-dev - pip3 install neovim-remote - npm install -g tree-sitter-cli +# we try to install the missing one with cargo even though it's unlikely to be found +function install_rust_deps() { + if ! command -v fd &>/dev/null; then + __attempt_to_install_with_cargo "fd-find" + fi + if ! command -v rg &>/dev/null; then + __attempt_to_install_with_cargo "ripgrep" + fi + echo "All Rust dependencies are succesfully installed" } -installtermux() { - apt install ripgrep fzf - pip install neovim-remote - npm install -g tree-sitter-cli +function backup_old_config() { + for dir in "${__lvim_dirs[@]}"; do + # we create an empty folder for subsequent commands \ + # that require an existing directory + mkdir -p "$dir" "$dir.bak" + if command -v rsync &>/dev/null; then + rsync --archive -hh --partial --info=stats1 --info=progress2 \ + --modify-window=1 "$dir" "$dir.bak" + else + cp -R "$dir/*" "$dir.bak/." + fi + done + echo "Backup operation complete" } -installonarch() { - sudo pacman -S ripgrep fzf - pip3 install neovim-remote - npm install -g tree-sitter-cli +function install_packer() { + git clone --progress --depth 1 https://github.com/wbthomason/packer.nvim \ + "$LUNARVIM_RUNTIME_DIR/site/pack/packer/start/packer.nvim" } -installonfedora() { - sudo dnf groupinstall "X Software Development" - sudo dnf install -y fzf ripgrep +function clone_lvim() { + echo "Cloning LunarVim configuration" + if ! git clone --progress --branch "$LV_BRANCH" \ + --depth 1 "https://github.com/${LV_REMOTE}" "$LUNARVIM_RUNTIME_DIR/lvim"; then + echo "Failed to clone repository. Installation failed." + exit 1 + fi } -installongentoo() { - sudo emerge -avn sys-apps/ripgrep app-shells/fzf dev-python/neovim-remote virtual/jpeg sys-libs/zlib - npm install -g tree-sitter-cli +function setup_shim() { + if [ ! -d "$INSTALL_PREFIX/bin" ]; then + mkdir -p "$INSTALL_PREFIX/bin" + fi + cat >"$INSTALL_PREFIX/bin/lvim" < Removing all lunarvim related config because of the --overwrite flag' - rm -rf "$HOME/.local/share/lunarvim" - rm -rf "$HOME/.cache/nvim" - rm -rf "$HOME/.config/lvim" - ;; -esac - -# move old lvim directory if it exists -[ -d "$HOME/.local/share/lunarvim" ] && moveoldlvim - -# install node and neovim support -(command -v git >/dev/null && echo "git installed, moving on...") || asktoinstallgit - -# install pip -(command -v pip3 >/dev/null && echo "pip installed, moving on...") || asktoinstallpip - -# install node and neovim support -(command -v node >/dev/null && echo "node installed, moving on...") || asktoinstallnode - -# install pynvim -(pip3 list | grep pynvim >/dev/null && echo "pynvim installed, moving on...") || installpynvim - -if [ -e "$HOME/.local/share/lunarvim/site/pack/packer/start/packer.nvim" ]; then - echo 'packer already installed' -else - installpacker -fi - -if [ -e "$HOME/.local/share/lunarvim/lvim/init.lua" ]; then - echo 'LunarVim already installed' -else - # clone config down - cloneconfig "$@" - # echo 'export PATH=$HOME/.config/nvim/utils/bin:$PATH' >>~/.zshrc - # echo 'export PATH=$HOME/.config/lunarvim/utils/bin:$PATH' >>~/.bashrc -fi - -if [ "$(uname)" != "Darwin" ]; then - if [ -e "$HOME/.local/share/applications/lvim.desktop" ]; then - echo 'Desktop file already available' - else - mkdir -p "$HOME/.local/share/applications" - cp "$HOME/.local/share/lunarvim/lvim/utils/desktop/lvim.desktop" "$HOME/.local/share/applications/lvim.desktop" +function update_lvim() { + if ! git -C "$LUNARVIM_RUNTIME_DIR/lvim" status -uno &>/dev/null; then + git -C "$LUNARVIM_RUNTIME_DIR/lvim" pull --ff-only --progress || + echo "Unable to guarantee data integrity while updating. Please do that manually instead." && exit 1 fi -fi + echo "Your LunarVim installation is now up to date!" +} + +function __add_separator() { + local DIV_WIDTH="$1" + printf "%${DIV_WIDTH}s\n" ' ' | tr ' ' - +} -echo "I recommend you also install and activate a font from here: https://github.com/ryanoasis/nerd-fonts" -# echo 'export PATH=/home/$USER/.config/lunarvim/utils/bin:$PATH appending to zshrc/bashrc' +main "$@" -- cgit v1.2.3 From f6c706ac0c346491cc79bdea46a52ee7a8694e0d Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Tue, 24 Aug 2021 09:05:39 +0200 Subject: fix unrecognized rsync flag on osx --- utils/installer/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'utils') diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 989f5595..28ed990c 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -207,8 +207,8 @@ function backup_old_config() { # that require an existing directory mkdir -p "$dir" "$dir.bak" if command -v rsync &>/dev/null; then - rsync --archive -hh --partial --info=stats1 --info=progress2 \ - --modify-window=1 "$dir" "$dir.bak" + rsync --archive -hh --partial --progress \ + --modify-window=1 "$dir"/ "$dir.bak" else cp -R "$dir/*" "$dir.bak/." fi -- cgit v1.2.3 From cfefddde9e9376e68ad8fcad3b1cf8cf139456e6 Mon Sep 17 00:00:00 2001 From: Chris Deligeorgis <59939524+chrisdlg@users.noreply.github.com> Date: Thu, 26 Aug 2021 12:08:48 +0200 Subject: Add a fallback for "ensurepip" on Debian based distros (#1396) --- utils/installer/install.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'utils') diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 28ed990c..355b0ecc 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -171,8 +171,10 @@ function install_nodejs_deps() { function install_python_deps() { echo "Verifying that pip is available.." if ! python3 -m ensurepip &>/dev/null; then - print_missing_dep_msg "pip" - exit 1 + if ! command -v pip3 &>/dev/null; then + print_missing_dep_msg "pip" + exit 1 + fi fi echo "Installing with pip.." for dep in "${__pip_deps[@]}"; do -- cgit v1.2.3 From 14f129cf26a9814dc8f5fa46f483a588b5a813b0 Mon Sep 17 00:00:00 2001 From: Chris Deligeorgis <59939524+chrisdlg@users.noreply.github.com> Date: Thu, 26 Aug 2021 12:53:29 +0200 Subject: [Refactor]: use "python3 -m pip" in the install script (#1398) --- utils/installer/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'utils') diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 355b0ecc..beef47fd 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -171,14 +171,14 @@ function install_nodejs_deps() { function install_python_deps() { echo "Verifying that pip is available.." if ! python3 -m ensurepip &>/dev/null; then - if ! command -v pip3 &>/dev/null; then + if ! python3 -m pip --version &>/dev/null; then print_missing_dep_msg "pip" exit 1 fi fi echo "Installing with pip.." for dep in "${__pip_deps[@]}"; do - pip3 install --user "$dep" + python3 -m pip install --user "$dep" done echo "All Python dependencies are succesfully installed" } -- cgit v1.2.3 From 27679f988fe187f9831ba7895c9c3a7ce2dd14f4 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Thu, 26 Aug 2021 20:32:16 +0200 Subject: [Refactor]: only allow a single logger (#1405) --- utils/installer/install.sh | 50 ++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 26 deletions(-) (limited to 'utils') diff --git a/utils/installer/install.sh b/utils/installer/install.sh index beef47fd..4392635d 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -50,32 +50,34 @@ EOF echo "Detecting platform for managing any additional neovim dependencies" detect_platform - # skip this in a Github workflow - if [ -z "$GITHUB_ACTIONS" ]; then - check_system_deps + if [ -n "$GITHUB_ACTIONS" ]; then + install_packer + setup_lvim + exit 0 + fi - __add_separator "80" + check_system_deps - echo "Would you like to check lunarvim's NodeJS dependencies?" - read -p "[y]es or [n]o (default: no) : " -r answer - [ "$answer" != "${answer#[Yy]}" ] && install_nodejs_deps + __add_separator "80" - echo "Would you like to check lunarvim's Python dependencies?" - read -p "[y]es or [n]o (default: no) : " -r answer - [ "$answer" != "${answer#[Yy]}" ] && install_python_deps + echo "Would you like to check lunarvim's NodeJS dependencies?" + read -p "[y]es or [n]o (default: no) : " -r answer + [ "$answer" != "${answer#[Yy]}" ] && install_nodejs_deps - echo "Would you like to check lunarvim's Rust dependencies?" - read -p "[y]es or [n]o (default: no) : " -r answer - [ "$answer" != "${answer#[Yy]}" ] && install_rust_deps + echo "Would you like to check lunarvim's Python dependencies?" + read -p "[y]es or [n]o (default: no) : " -r answer + [ "$answer" != "${answer#[Yy]}" ] && install_python_deps - __add_separator "80" + echo "Would you like to check lunarvim's Rust dependencies?" + read -p "[y]es or [n]o (default: no) : " -r answer + [ "$answer" != "${answer#[Yy]}" ] && install_rust_deps - echo "Backing up old LunarVim configuration" - backup_old_config + __add_separator "80" - __add_separator "80" + echo "Backing up old LunarVim configuration" + backup_old_config - fi + __add_separator "80" case "$@" in *--overwrite*) @@ -219,13 +221,13 @@ function backup_old_config() { } function install_packer() { - git clone --progress --depth 1 https://github.com/wbthomason/packer.nvim \ + git clone --depth 1 https://github.com/wbthomason/packer.nvim \ "$LUNARVIM_RUNTIME_DIR/site/pack/packer/start/packer.nvim" } function clone_lvim() { echo "Cloning LunarVim configuration" - if ! git clone --progress --branch "$LV_BRANCH" \ + if ! git clone --branch "$LV_BRANCH" \ --depth 1 "https://github.com/${LV_REMOTE}" "$LUNARVIM_RUNTIME_DIR/lvim"; then echo "Failed to clone repository. Installation failed." exit 1 @@ -258,12 +260,8 @@ function setup_lvim() { "$LUNARVIM_CONFIG_DIR/config.lua" nvim -u "$LUNARVIM_RUNTIME_DIR/lvim/init.lua" --headless \ - +'autocmd User PackerComplete sleep 100m | qall' \ - +PackerInstall - - nvim -u "$LUNARVIM_RUNTIME_DIR/lvim/init.lua" --headless \ - +'autocmd User PackerComplete sleep 100m | qall' \ - +PackerSync + -c 'autocmd User PackerComplete quitall' \ + -c 'PackerSync' echo "Packer setup complete" -- cgit v1.2.3 From 21d04257a8c306fbb0c17486791bc46d6212e611 Mon Sep 17 00:00:00 2001 From: Lee Marlow Date: Fri, 27 Aug 2021 13:46:11 -0600 Subject: [Feature] Fetch from git before update in install script (#1409) --- utils/installer/install.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'utils') diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 4392635d..9e198274 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -211,7 +211,7 @@ function backup_old_config() { # that require an existing directory mkdir -p "$dir" "$dir.bak" if command -v rsync &>/dev/null; then - rsync --archive -hh --partial --progress \ + rsync --archive -hh --partial --progress --cvs-exclude \ --modify-window=1 "$dir"/ "$dir.bak" else cp -R "$dir/*" "$dir.bak/." @@ -273,8 +273,9 @@ function setup_lvim() { } function update_lvim() { - if ! git -C "$LUNARVIM_RUNTIME_DIR/lvim" status -uno &>/dev/null; then - git -C "$LUNARVIM_RUNTIME_DIR/lvim" pull --ff-only --progress || + git -C "$LUNARVIM_RUNTIME_DIR/lvim" fetch --quiet + if ! git -C "$LUNARVIM_RUNTIME_DIR/lvim" diff --quiet "@{upstream}"; then + git -C "$LUNARVIM_RUNTIME_DIR/lvim" merge --ff-only --progress || echo "Unable to guarantee data integrity while updating. Please do that manually instead." && exit 1 fi echo "Your LunarVim installation is now up to date!" -- cgit v1.2.3