Skip to content

Commit

Permalink
rework(#5): state directory now wraps rtp dir
Browse files Browse the repository at this point in the history
  • Loading branch information
quantumfate committed Aug 20, 2023
1 parent dbe0496 commit fd25aba
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 10 deletions.
1 change: 1 addition & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ stds.nvim = {
"vim",
"join_paths",
"get_qvim_cache_dir",
"get_qvim_state_dir",
"get_qvim_config_dir",
"get_qvim_data_dir",
"get_qvim_rtp_dir",
Expand Down
15 changes: 12 additions & 3 deletions lua/qvim/bootstrap.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@diagnostic disable: param-type-mismatch, return-type-mismatch
local M = {}
M.__index = M

Expand Down Expand Up @@ -44,14 +45,20 @@ end

---Get the full path to `$QUANTUMVIM_STATE_DIR`
---@return string
function _G.get_qvim_rtp_dir()
local qvim_state_dir = os.getenv("QUANTUMVIM_RTP_DIR")
function _G.get_qvim_state_dir()
local qvim_state_dir = os.getenv("QUANTUMVIM_STATE_DIR")
if not qvim_state_dir then
return vim.call("stdpath", "state")
end
return qvim_state_dir
end

---Get the full path to `$QUANTUMVIM_RTP_DIR`
---@return string
function _G.get_qvim_rtp_dir()
return os.getenv("QUANTUMVIM_RTP_DIR")
end

---Get the full path to `$QUANTUMVIM_DATA_DIR`
---@return string
function _G.get_qvim_data_dir()
Expand Down Expand Up @@ -92,8 +99,10 @@ function M:init()
vim.fn.stdpath = function(what)
if what == "cache" then
return get_qvim_cache_dir()
elseif what == "state" then
elseif what == "rtp" then
return get_qvim_rtp_dir()
elseif what == "state" then
return get_qvim_state_dir()
elseif what == "data" then
return get_qvim_data_dir()
elseif what == "config" then
Expand Down
1 change: 1 addition & 0 deletions utils/bin/qvim.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash

export QUANTUMVIM_RTP_DIR="${QUANTUMVIM_RTP_DIR:-RTP_DIR_VAR}"
export QUANTUMVIM_STATE_DIR="${QUANTUMVIM_STATE_DIR:-STATE_DIR_VAR}"
export QUANTUMVIM_CONFIG_DIR="${QUANTUMVIM_CONFIG_DIR:-CONFIG_DIR_VAR}"
export QUANTUMVIM_DATA_DIR="${QUANTUMVIM_DATA_DIR:-DATA_DIR_VAR}"
export QUANTUMVIM_CACHE_DIR="${QUANTUMVIM_CACHE_DIR:-CACHE_DIR_VAR}"
Expand Down
9 changes: 6 additions & 3 deletions utils/ci/run_test.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
#!/usr/bin/env bash
set -e

qvim_state_name="quantumvim"
export XDG_STATE_HOME="$HOME/.local/state"

export QV_FIRST_TIME_SETUP=1
export NVIM_APPNAME="${NVIM_APPNAME:-"qvim"}"
export QUANTUMVIM_RTP_DIR="${QUANTUMVIM_RTP_DIR:-"$XDG_STATE_HOME/$NVIM_APPNAME"}"

QUANTUMVIM_STATE_DIR="${QUANTUMVIM_STATE_DIR:-"$XDG_STATE_HOME/$qvim_state_name"}"
QUANTUMVIM_RTP_DIR="${QUANTUMVIM_RTP_DIR:-"$QUANTUMVIM_STATE_DIR/$NVIM_APPNAME"}"
QUANTUMVIM_CONFIG_DIR="${QUANTUMVIM_CONFIG_DIR:-"$XDG_CONFIG_HOME/$NVIM_APPNAME"}"
QUANTUMVIM_CACHE_DIR="$(mktemp -d)"
QUANTUMVIM_DATA_DIR="$(mktemp -d)"
QUANTUMVIM_CONFIG_DIR="$(mktemp -d)"

export QUANTUMVIM_CACHE_DIR QUANTUMVIM_STATE_DIR QUANTUMVIM_DATA_DIR QUANTUMVIM_CONFIG_DIR
export QUANTUMVIM_CACHE_DIR QUANTUMVIM_STATE_DIR QUANTUMVIM_DATA_DIR QUANTUMVIM_CONFIG_DIR QUANTUMVIM_RTP_DIR

echo "state: $QUANTUMVIM_STATE_DIR"
echo "rtp: $QUANTUMVIM_RTP_DIR"
echo "cache: $QUANTUMVIM_CACHE_DIR"
echo "data: $QUANTUMVIM_DATA_DIR"
Expand Down
8 changes: 5 additions & 3 deletions utils/installer/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
set -eo pipefail

OS="$(uname -s)"
qvim_state_name="quantumvim"
declare -xr NVIM_APPNAME="${NVIM_APPNAME:-"qvim"}"

#Set branch to master unless specified by the user
Expand All @@ -14,7 +15,8 @@ declare -xr XDG_CACHE_HOME="${XDG_CACHE_HOME:-"$HOME/.cache"}"
declare -xr XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-"$HOME/.config"}"
declare -xr XDG_STATE_HOME="${XDG_STATE_HOME:-"$HOME/.local/state"}"

declare -xr QUANTUMVIM_RTP_DIR="${QUANTUMVIM_RTP_DIR:-"$XDG_STATE_HOME/$NVIM_APPNAME"}"
declare -xr QUANTUMVIM_STATE_DIR="${QUANTUMVIM_STATE_DIR:-"$XDG_STATE_HOME/$qvim_state_name"}"
declare -xr QUANTUMVIM_RTP_DIR="${QUANTUMVIM_RTP_DIR:-"$QUANTUMVIM_STATE_DIR/$NVIM_APPNAME"}"
declare -xr QUANTUMVIM_CACHE_DIR="${QUANTUMVIM_CACHE_DIR:-"$XDG_CACHE_HOME/$NVIM_APPNAME"}"
declare -xr QUANTUMVIM_CONFIG_DIR="${QUANTUMVIM_CONFIG_DIR:-"$XDG_CONFIG_HOME/$NVIM_APPNAME"}"
declare -xr QUANTUMVIM_LOG_LEVEL="${QUANTUMVIM_LOG_LEVEL:-warn}"
Expand All @@ -33,7 +35,7 @@ declare ADDITIONAL_WARNINGS=""
declare USE_SSH=0

declare -a __qvim_dirs=(
"$QUANTUMVIM_RTP_DIR"
"$QUANTUMVIM_STATE_DIR"
"$QUANTUMVIM_CACHE_DIR"
"$QUANTUMVIM_CONFIG_DIR"
# TODO log dir
Expand Down Expand Up @@ -156,7 +158,7 @@ function check_neovim_min_version() {

# exit with an error if min_version not found
if ! nvim --headless -u NONE -c "$verify_version_cmd"; then
echo "[ERROR]: LunarVim requires at least Neovim v0.8 or higher"
echo "[ERROR]: QuantimVim requires at least Neovim v0.8 or higher"
exit 1
fi
}
Expand Down
5 changes: 4 additions & 1 deletion utils/installer/install_bin.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
set -eo pipefail

qvim_state_name="quantumvim"
INSTALL_PREFIX="${INSTALL_PREFIX:-"$HOME/.local"}"

NVIM_APPNAME="${NVIM_APPNAME:-"qvim"}"
Expand All @@ -13,7 +14,8 @@ XDG_CACHE_HOME="${XDG_CACHE_HOME:-"$HOME/.cache"}"

QUANTUMVIM_CONFIG_DIR="${QUANTUMVIM_CONFIG_DIR:-"$XDG_CONFIG_HOME/$NVIM_APPNAME"}"
QUANTUMVIM_DATA_DIR="${QUANTUMVIM_DATA_DIR:-"$XDG_DATA_HOME/$NVIM_APPNAME"}"
QUANTUMVIM_RTP_DIR="${QUANTUMVIM_RTP_DIR:-"$XDG_STATE_HOME/$NVIM_APPNAME"}"
QUANTUMVIM_STATE_DIR="${QUANTUMVIM_STATE_DIR:-"$XDG_STATE_HOME/$qvim_state_name"}"
QUANTUMVIM_RTP_DIR="${QUANTUMVIM_RTP_DIR:-"$QUANTUMVIM_STATE_DIR/$NVIM_APPNAME"}"
QUANTUMVIM_CACHE_DIR="${QUANTUMVIM_CACHE_DIR:-"$XDG_CACHE_HOME/$NVIM_APPNAME"}"

function setup_qvim() {
Expand All @@ -30,6 +32,7 @@ function setup_qvim() {
sed -e s"#CONFIG_DIR_VAR#\"${QUANTUMVIM_CONFIG_DIR}\"#"g \
-e s"#DATA_DIR_VAR#\"${QUANTUMVIM_DATA_DIR}\"#"g \
-e s"#STATE_DIR_VAR#\"${QUANTUMVIM_STATE_DIR}\"#"g \
-e s"#RTP_DIR_VAR#\"${QUANTUMVIM_RTP_DIR}\"#"g \
-e s"#CACHE_DIR_VAR#\"${QUANTUMVIM_CACHE_DIR}\"#"g \
-e s"#APPNAME_VAR#\"${NVIM_APPNAME}\"#"g "$src" \
| tee "$dst" >/dev/null
Expand Down

0 comments on commit fd25aba

Please sign in to comment.