Skip to content

Commit

Permalink
feat(#14): added structlag as a dependency and rtp integration
Browse files Browse the repository at this point in the history
  • Loading branch information
quantumfate committed Aug 22, 2023
1 parent 7bb6743 commit abd8a1c
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down
31 changes: 24 additions & 7 deletions lua/qvim/bootstrap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
})

Expand Down
2 changes: 2 additions & 0 deletions utils/bin/qvim.template
Original file line number Diff line number Diff line change
@@ -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}"
Expand Down
47 changes: 47 additions & 0 deletions utils/installer/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -336,6 +381,8 @@ function main() {

clone_qvim

clone_plugins

setup_qvim

msg "$ADDITIONAL_WARNINGS"
Expand Down
6 changes: 6 additions & 0 deletions utils/installer/install_bin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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 \
Expand Down

0 comments on commit abd8a1c

Please sign in to comment.