diff --git a/.luacheckrc b/.luacheckrc index bef024b..bd1481b 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -30,6 +30,8 @@ stds.nvim = { "get_qvim_data_dir", "get_qvim_rtp_dir", "get_qvim_base_dir", + "get_qvim_pack_dir", + "get_qvim_structlog_dir", "get_lazy_rtp_dir", "require_clean", }, diff --git a/lua/qvim/bootstrap.lua b/lua/qvim/bootstrap.lua index 7f75570..c650dfd 100644 --- a/lua/qvim/bootstrap.lua +++ b/lua/qvim/bootstrap.lua @@ -89,24 +89,34 @@ function _G.get_qvim_cache_dir() return qvim_cache_dir end +---Get the full path to `$QUANTUMVIM_PACK_DIR` +---@return string +function _G.get_qvim_pack_dir() + return os.getenv("QUANTUMVIM_PACK_DIR") +end + +---Get the full path to `$QUANTUMVIM_STRUCTLAG_DIR` +---@return string +function _G.get_qvim_structlog_dir() + return os.getenv("QUANTUMVIM_STRUCTLOG_DIR") +end + M.qvim_config_dir = get_qvim_config_dir() M.qvim_state_dir = get_qvim_state_dir() M.qvim_rtp_dir = get_qvim_rtp_dir() M.qvim_cache_dir = get_qvim_cache_dir() M.qvim_data_dir = get_qvim_data_dir() M.qvim_log_dir = get_qvim_log_dir() -M.opt_dir = join_paths(get_qvim_data_dir(), "after", "pack", "lazy", "opt") -M.lazy_install_dir = join_paths(M.opt_dir, "lazy.nvim") +M.qvim_pack_dir = get_qvim_pack_dir() +M.lazy_install_dir = join_paths(M.qvim_pack_dir, "lazy.nvim") function _G.get_lazy_rtp_dir() - return M.opt_dir + return M.qvim_pack_dir end ---Initialize the `&runtimepath` variables, load the globals and prepare for startup ---@return table function M:init() - local utils = require("qvim.utils") - ---@meta overridden ---@param what any ---@return string @@ -123,16 +133,23 @@ function M:init() return get_qvim_config_dir() elseif what == "log" then return get_qvim_log_dir() + elseif what == "pack" then + return get_qvim_pack_dir() + elseif what == "structlog" then + return get_qvim_structlog_dir() else return vim.call("stdpath", what) end end - local log_path = join_paths(self.opt_dir, "structlog") + local log_path = join_paths(self.qvim_pack_dir, "structlog") vim.opt.rtp:prepend(log_path) + local log = require("qvim.log") + log:setup() + require("qvim.core.manager"):init({ - package_root = self.opt_dir, + package_root = self.qvim_pack_dir, install_path = self.lazy_install_dir, }) diff --git a/utils/bin/qvim.template b/utils/bin/qvim.template index dedd70b..a40f961 100644 --- a/utils/bin/qvim.template +++ b/utils/bin/qvim.template @@ -1,6 +1,8 @@ #!/usr/bin/env bash export QUANTUMVIM_RTP_DIR="${QUANTUMVIM_RTP_DIR:-RTP_DIR_VAR}" +export QUANTUMVIM_PACK_DIR="${QUANTUMVIM_PACK_DIR:-PACK_DIR_VAR}" +export QUANTUMVIM_STRUCTLOG_DIR="${QUANTUMVIM_STRUCTLOG_DIR:-STRUCTLOG_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}" diff --git a/utils/installer/install.sh b/utils/installer/install.sh index a6210cf..451410b 100644 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -2,7 +2,10 @@ set -eo pipefail OS="$(uname -s)" + qvim_state_name="quantumvim" +structlog_url="https://github.com/Tastyep/structlog.nvim.git" + declare -xr NVIM_APPNAME="${NVIM_APPNAME:-"qvim"}" #Set branch to master unless specified by the user @@ -23,6 +26,9 @@ declare -xr QUANTUMVIM_CONFIG_DIR="${QUANTUMVIM_CONFIG_DIR:-"$XDG_CONFIG_HOME/$N declare -xr QUANTUMVIM_LOG_DIR="${QUANTUMVIM_LOG_DIR:-"$XDG_LOG_HOME/$NVIM_APPNAME"}" declare -xr QUANTUMVIM_LOG_LEVEL="${QUANTUMVIM_LOG_LEVEL:-warn}" +declare -xr QUANTUMVIM_PACK_DIR="${QUANTUMVIM_DATA_PROFILE}/after/pack/lazy/opt" +declare -xr QUANTUMVIM_STRUCTLOG_DIR="${QUANTUMVIM_PACK_DIR}/structlog" + declare -xir QV_FIRST_TIME_SETUP=1 declare BASEDIR @@ -100,6 +106,45 @@ function msg() { printf "%s\n" "$text" } +function clone_plugins() { + declare -a plugins=( + # order matters + "$structlog_url" + ) + + declare -a plugin_dirs=( + # order matters + "$QUANTUMVIM_STRUCTLOG_DIR" + ) + counter=0 + for i in "${!plugins[@]}"; do + if [ ! -d "${plugin_dirs[$i]}" ]; then + counter=$((counter+1)) + fi + done + + if [ "$counter" -eq 0 ]; then + return + fi + + msg "Cloning plugins..." + + mkdir -p "${QUANTUMVIM_PACK_DIR}" + for i in "${!plugins[@]}"; do + if [ ! -d "${plugin_dirs[$i]}" ]; then + msg "[INFO]: Cloning plugin: ${plugins[$i]} into: ${plugin_dirs[$i]}" + output=$(git clone "${plugins[$i]}" "${plugin_dirs[$i]}" 2>&1) + + if [ ! "$output" ]; then + echo "$output" | tail -n +2 | while IFS= read -r line; do + msg "$line" + done + fi + fi + done + msg "Plugins cloned successfully." +} + #function confirm() { # local question="$1" # while true; do @@ -336,6 +381,8 @@ function main() { clone_qvim + clone_plugins + setup_qvim msg "$ADDITIONAL_WARNINGS" diff --git a/utils/installer/install_bin.sh b/utils/installer/install_bin.sh index 8c76e27..796917c 100644 --- a/utils/installer/install_bin.sh +++ b/utils/installer/install_bin.sh @@ -19,6 +19,9 @@ 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"}" +QUANTUMVIM_PACK_DIR="${QUANTUMVIM_DATA_PROFILE}/after/pack/lazy/opt" +QUANTUMVIM_STRUCTLOG_DIR="${QUANTUMVIM_PACK_DIR}/structlog" + function setup_qvim() { local src="$QUANTUMVIM_RTP_DIR/utils/bin/${NVIM_APPNAME}.template" local dst="$INSTALL_PREFIX/bin/${NVIM_APPNAME}" @@ -31,6 +34,9 @@ function setup_qvim() { cp "$src" "$dst" sed -e s"#CONFIG_DIR_VAR#\"${QUANTUMVIM_CONFIG_DIR}\"#"g \ + -e s"#LOG_DIR_VAR#\"${QUANTUMVIM_LOG_DIR}\"#"g \ + -e s"#PACK_DIR_VAR#\"${QUANTUMVIM_PACK_DIR}\"#"g \ + -e s"#STRUCTLOG_DIR_VAR#\"${QUANTUMVIM_STRUCTLOG_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 \