mirror of
https://github.com/LunarVim/LunarVim.git
synced 2024-09-20 10:35:08 +02:00
refactor: use a static lvim binary template (#1444)
This commit is contained in:
parent
eefc148313
commit
21b41688ee
5 changed files with 39 additions and 41 deletions
12
Makefile
12
Makefile
|
@ -1,15 +1,19 @@
|
|||
SHELL := /bin/bash
|
||||
|
||||
install:
|
||||
@echo Starting LunarVim Installer
|
||||
@echo starting LunarVim installer
|
||||
bash ./utils/installer/install.sh
|
||||
|
||||
install-bin:
|
||||
@echo starting LunarVim bin-installer
|
||||
bash ./utils/installer/install_bin.sh
|
||||
|
||||
install-neovim-binary:
|
||||
@echo Installing Neovim from github releases
|
||||
@echo installing Neovim from github releases
|
||||
bash ./utils/installer/install-neovim-from-release
|
||||
|
||||
uninstall:
|
||||
@echo Starting LunarVim Uninstaller
|
||||
@echo starting LunarVim uninstaller
|
||||
bash ./utils/installer/uninstall.sh
|
||||
|
||||
generate_plugins_sha:
|
||||
|
@ -30,7 +34,7 @@ style-lua:
|
|||
stylua --config-path .stylua.toml --check .
|
||||
|
||||
style-sh:
|
||||
shfmt -f . | grep -v jdtls | xargs shfmt -i 2 -ci -l -d
|
||||
shfmt -f . | grep -v jdtls | xargs shfmt -i 2 -ci -bn -l -d
|
||||
|
||||
test:
|
||||
bash ./utils/bin/test_runner.sh "$(TEST)"
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
export LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-$HOME/.local/share/lunarvim}"
|
||||
export LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-$HOME/.config/lvim}"
|
||||
|
||||
exec nvim -u "$LUNARVIM_RUNTIME_DIR/lvim/init.lua" "$@"
|
7
utils/bin/lvim.template
Normal file
7
utils/bin/lvim.template
Normal file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
export LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-RUNTIME_DIR_VAR}"
|
||||
export LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-CONFIG_DIR_VAR}"
|
||||
export LUNARVIM_CACHE_DIR="${LUNARVIM_CACHE_DIR:-CACHE_DIR_VAR}"
|
||||
|
||||
exec nvim -u "$LUNARVIM_RUNTIME_DIR/lvim/init.lua" "$@"
|
|
@ -352,18 +352,7 @@ function link_local_lvim() {
|
|||
}
|
||||
|
||||
function setup_shim() {
|
||||
if [ ! -d "$INSTALL_PREFIX/bin" ]; then
|
||||
mkdir -p "$INSTALL_PREFIX/bin"
|
||||
fi
|
||||
cat >"$INSTALL_PREFIX/bin/lvim" <<EOF
|
||||
#!/bin/sh
|
||||
|
||||
export LUNARVIM_CONFIG_DIR="\${LUNARVIM_CONFIG_DIR:-$LUNARVIM_CONFIG_DIR}"
|
||||
export LUNARVIM_RUNTIME_DIR="\${LUNARVIM_RUNTIME_DIR:-$LUNARVIM_RUNTIME_DIR}"
|
||||
|
||||
exec nvim -u "\$LUNARVIM_RUNTIME_DIR/lvim/init.lua" "\$@"
|
||||
EOF
|
||||
chmod +x "$INSTALL_PREFIX/bin/lvim"
|
||||
make -C "$LUNARVIM_BASE_DIR" install-bin
|
||||
}
|
||||
|
||||
function remove_old_cache_files() {
|
||||
|
|
|
@ -1,33 +1,37 @@
|
|||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
|
||||
declare -r INSTALL_PREFIX="${INSTALL_PREFIX:-"$HOME/.local"}"
|
||||
INSTALL_PREFIX="${INSTALL_PREFIX:-"$HOME/.local"}"
|
||||
|
||||
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"}"
|
||||
XDG_DATA_HOME="${XDG_DATA_HOME:-"$HOME/.local/share"}"
|
||||
XDG_CACHE_HOME="${XDG_CACHE_HOME:-"$HOME/.cache"}"
|
||||
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-"$HOME/.config"}"
|
||||
|
||||
declare -r LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-"$XDG_DATA_HOME/lunarvim"}"
|
||||
declare -r LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-"$XDG_CONFIG_HOME/lvim"}"
|
||||
LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-"$XDG_DATA_HOME/lunarvim"}"
|
||||
LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-"$XDG_CONFIG_HOME/lvim"}"
|
||||
LUNARVIM_CACHE_DIR="${LUNARVIM_CACHE_DIR:-"$XDG_CACHE_HOME/nvim"}"
|
||||
|
||||
# TODO: Use a dedicated cache directory #1256
|
||||
declare -r LUNARVIM_CACHE_DIR="$XDG_CACHE_HOME/nvim"
|
||||
LUNARVIM_BASE_DIR="${LUNARVIM_BASE_DIR:-"$LUNARVIM_RUNTIME_DIR/lvim"}"
|
||||
|
||||
function setup_shim() {
|
||||
if [ ! -d "$INSTALL_PREFIX/bin" ]; then
|
||||
mkdir -p "$INSTALL_PREFIX/bin"
|
||||
fi
|
||||
cat >"$INSTALL_PREFIX/bin/lvim" <<EOF
|
||||
#!/bin/sh
|
||||
local src="$LUNARVIM_BASE_DIR/utils/bin/lvim.template"
|
||||
local dst="$INSTALL_PREFIX/bin/lvim"
|
||||
|
||||
export LUNARVIM_CONFIG_DIR="\${LUNARVIM_CONFIG_DIR:-$LUNARVIM_CONFIG_DIR}"
|
||||
export LUNARVIM_RUNTIME_DIR="\${LUNARVIM_RUNTIME_DIR:-$LUNARVIM_RUNTIME_DIR}"
|
||||
export LUNARVIM_CACHE_DIR="\${LUNARVIM_CACHE_DIR:-$LUNARVIM_CACHE_DIR}"
|
||||
[ ! -d "$INSTALL_PREFIX/bin" ] && mkdir -p "$INSTALL_PREFIX/bin"
|
||||
|
||||
exec nvim -u "\$LUNARVIM_RUNTIME_DIR/lvim/init.lua" "\$@"
|
||||
EOF
|
||||
chmod +x "$INSTALL_PREFIX/bin/lvim"
|
||||
# remove outdated installation so that `cp` doesn't complain
|
||||
rm -f "$dst"
|
||||
|
||||
cp "$src" "$dst"
|
||||
|
||||
sed -e s"@RUNTIME_DIR_VAR@\"${LUNARVIM_RUNTIME_DIR}\"@"g \
|
||||
-e s"@CONFIG_DIR_VAR@\"${LUNARVIM_CONFIG_DIR}\"@"g \
|
||||
-e s"@CACHE_DIR_VAR@\"${LUNARVIM_CACHE_DIR}\"@"g "$src" \
|
||||
| tee "$dst" >/dev/null
|
||||
|
||||
chmod u+x "$dst"
|
||||
}
|
||||
|
||||
setup_shim "$@"
|
||||
|
||||
echo "You can start LunarVim by running: $INSTALL_PREFIX/bin/lvim"
|
||||
|
|
Loading…
Reference in a new issue