Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rework for better scaling #10

Merged
merged 73 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
5dc38bd
health: warnings
quantumfate Aug 16, 2023
dbe0496
rework(#5): move qvim to rtp directory
quantumfate Aug 20, 2023
ef81b62
Merge pull request #19 from QuantumVim/5-feat-move-qvim-to-the-state-…
quantumfate Aug 20, 2023
fd25aba
rework(#5): state directory now wraps rtp dir
quantumfate Aug 20, 2023
8a63e6d
Merge pull request #20 from QuantumVim/5-feat-move-qvim-to-the-state-…
quantumfate Aug 20, 2023
47ea903
feat(#7): implemented rtp init
quantumfate Aug 21, 2023
2a32303
feat(#7): implemented rtp init
quantumfate Aug 21, 2023
1c98bd1
Merge branch '7-feat-runtime-path-modifications-and-user-config-after…
quantumfate Aug 21, 2023
eb4980c
feat(#7): implemented bootstrap function for rtp modifications
quantumfate Aug 21, 2023
0267ff3
Merge pull request #21 from QuantumVim/7-feat-runtime-path-modificati…
quantumfate Aug 21, 2023
c776b6f
feat(#7): updatet test init
quantumfate Aug 21, 2023
a61f095
Merge pull request #22 from QuantumVim/7-feat-runtime-path-modificati…
quantumfate Aug 21, 2023
b6b7f39
feat(#7): updatet test init
quantumfate Aug 21, 2023
3eac59a
Merge pull request #23 from QuantumVim/7-feat-runtime-path-modificati…
quantumfate Aug 21, 2023
554cfc5
feat(#7): updatet rtp tests
quantumfate Aug 21, 2023
81cae48
Merge pull request #24 from QuantumVim/7-feat-runtime-path-modificati…
quantumfate Aug 21, 2023
925516a
feat(#6): added log directory
quantumfate Aug 21, 2023
7bb6743
Merge pull request #25 from QuantumVim/6-feat-add-a-log-diroctory
quantumfate Aug 21, 2023
abd8a1c
feat(#14): added structlag as a dependency and rtp integration
quantumfate Aug 22, 2023
878f57f
feat(#14): added lsp factory
quantumfate Aug 22, 2023
e1744bc
Merge pull request #26 from QuantumVim/14-feat-configure-structlog-pr…
quantumfate Aug 22, 2023
af105d6
fix(#14): install script
quantumfate Aug 22, 2023
bd7fa37
Merge pull request #27 from QuantumVim/14-feat-configure-structlog-pr…
quantumfate Aug 22, 2023
b92ec38
fix(#14): install script
quantumfate Aug 22, 2023
e3b4926
Merge pull request #28 from QuantumVim/14-feat-configure-structlog-pr…
quantumfate Aug 22, 2023
be9639c
fix(#14): install script
quantumfate Aug 22, 2023
9b37874
Merge pull request #29 from QuantumVim/14-feat-configure-structlog-pr…
quantumfate Aug 22, 2023
d87b3f1
fix(#14): fix snapshot
quantumfate Aug 22, 2023
36cdd1b
Merge pull request #30 from QuantumVim/14-feat-configure-structlog-pr…
quantumfate Aug 22, 2023
d87d015
fix(#14): rtp
quantumfate Aug 22, 2023
c823290
Merge pull request #31 from QuantumVim/14-feat-configure-structlog-pr…
quantumfate Aug 22, 2023
ace646b
debug pipeline
quantumfate Aug 22, 2023
29c2206
fix(#14): pack dir path
quantumfate Aug 22, 2023
87872a9
debug pipeline
quantumfate Aug 22, 2023
0cf9ea9
fix(#14): lazy reset rtp
quantumfate Aug 22, 2023
4a530d2
fix(#14): fix pipeline
quantumfate Aug 22, 2023
6be0c52
fix(#14): fix pipeline
quantumfate Aug 22, 2023
7abc849
removed debug statements
quantumfate Aug 22, 2023
19eb89f
fix: fix pipeline lint
quantumfate Aug 22, 2023
005be94
fix: fix pipeline lint
quantumfate Aug 22, 2023
c62e0b0
fix: fix pipeline lint
quantumfate Aug 22, 2023
e5f7f1d
fix: fix pipeline lint
quantumfate Aug 22, 2023
8a3563b
feat(#9):updated gen script
quantumfate Nov 14, 2023
8e5744f
feat(#9):updated gen script
quantumfate Nov 15, 2023
a99c80c
feat(#15): updated install script
quantumfate Nov 16, 2023
d506593
feat(#18): harden dependencies
quantumfate Nov 16, 2023
9e0106d
Merge pull request #32 from QuantumVim/15-feat-implement-user-configu…
quantumfate Nov 16, 2023
5ef33b0
Fix stash
quantumfate Apr 23, 2024
36ee83e
Merge branch 'integration-distro-rework' of github.com:quantumfate/Qu…
quantumfate Apr 23, 2024
61e7d46
Update installer
quantumfate Apr 23, 2024
e85bd13
Update installer workflow
quantumfate Apr 23, 2024
ac4345b
Update installer workflow
quantumfate Apr 23, 2024
20829c5
Update installer workflow
quantumfate Apr 23, 2024
430f93c
Update installer workflow
quantumfate Apr 23, 2024
5223d38
Update installer workflow
quantumfate Apr 23, 2024
bd2876c
Log update with tests
quantumfate Apr 25, 2024
7634e84
Fix MacOS release name
quantumfate Apr 25, 2024
60288b3
Fix MacOS release name
quantumfate Apr 25, 2024
aaa187f
Fix MacOS release name
quantumfate Apr 25, 2024
5ed4ae5
Fix MacOS release name
quantumfate Apr 25, 2024
faea6b5
Hope this works lol
quantumfate Apr 29, 2024
0008671
Hope this works now lol
quantumfate Apr 29, 2024
46df245
Hope this works now lol
quantumfate Apr 29, 2024
6de4ca6
Hope this works now lol
quantumfate Apr 29, 2024
0fbbf4e
Hope this works now lol
quantumfate May 6, 2024
b0191d8
Hope this works now lol
quantumfate May 6, 2024
5873933
Hope this works now lol
quantumfate May 6, 2024
beaf054
Hope this works now lol
quantumfate May 6, 2024
84570ab
Hope this works now lol
quantumfate May 6, 2024
9e3fb06
Hope this works now lol
quantumfate May 6, 2024
c147bb9
Finished rework structlog
quantumfate May 6, 2024
bc877ff
Finished rework structlog
quantumfate May 6, 2024
98a19c4
Finished rework structlog
quantumfate May 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
125 changes: 105 additions & 20 deletions lua/qvim/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,73 @@ function Log:setup()
return nil
end
structlog.configure({
lsp = {
pipelines = {
{
level = structlog.level.INFO,
processors = {
structlog.processors.StackWriter(
{ "line", "file" },
{ max_parents = 0, stack_level = 0 }
),
structlog.processors.Timestamper("%H:%M:%S"),
},
formatter = structlog.formatters.FormatColorizer( --
"%s [%s] %s: %-30s",
{ "timestamp", "level", "logger_name", "msg" },
{
level = structlog.formatters.FormatColorizer.color_level(),
}
),
sink = structlog.sinks.Console(),
},
{
level = structlog.level.ERROR,
processors = {
structlog.processors.StackWriter(
{ "line", "file" },
{ max_parents = 3 }
),
structlog.processors.Timestamper("%H:%M:%S"),
},
formatter = structlog.formatters.Format( --
"%s [%s] %s: %-30s",
{ "timestamp", "level", "logger_name", "msg" }
),
sink = structlog.sinks.File(self:get_path("error", "lsp")),
},
{
level = structlog.level.DEBUG,
processors = {
structlog.processors.StackWriter(
{ "line", "file" },
{ max_parents = 3 }
),
structlog.processors.Timestamper("%H:%M:%S"),
},
formatter = structlog.formatters.Format( --
"%s [%s] %s: %-30s",
{ "timestamp", "level", "logger_name", "msg" }
),
sink = structlog.sinks.File(self:get_path("debug", "lsp")),
},
{
level = structlog.level.TRACE,
processors = {
structlog.processors.StackWriter(
{ "line", "file" },
{ max_parents = 3 }
),
structlog.processors.Timestamper("%H:%M:%S"),
},
formatter = structlog.formatters.Format( --
"%s [%s] %s: %-30s",
{ "timestamp", "level", "logger_name", "msg" }
),
sink = structlog.sinks.File(self:get_path("trace", "lsp")),
},
},
},
qvim = {
pipelines = {
{
Expand Down Expand Up @@ -122,17 +189,18 @@ end
---@param level integer [same as vim.log.levels]
---@param msg any
---@param event any
function Log:add_entry(level, msg, event)
function Log:add_entry(level, msg, event, pipeline)
pipeline = pipeline or "qvim"
if
not pcall(function()
local logger = self:get_logger()
local logger = self:get_logger(pipeline)
if not logger then
return
end
logger:log(level, vim.inspect(msg), event)
end)
then
vim.notify(msg, level, { title = "qvim" })
vim.notify(msg, level, { title = pipeline })
end
end

Expand All @@ -151,50 +219,67 @@ end

---Retrieves the path of the logfile
---@param variant string|nil
---@param pipeline string|nil
---@return string path of the logfile
function Log:get_path(variant)
function Log:get_path(variant, pipeline)
variant = variant or ""
return string.format(
"%s/%s-%s.log",
get_qvim_log_dir(),
variant:lower(),
"qvim"
)
pipeline = pipeline or "qvim"

if pipeline == "qvim" then
return string.format(
"%s/%s-%s.log",
get_qvim_log_dir(),
"qvim",
variant:lower()
)
else
return string.format(
"%s/%s/%s.log",
get_qvim_log_dir(),
pipeline,
variant:lower()
)
end
end

---Add a log entry at TRACE level
---@param msg any
---@param event any
function Log:trace(msg, event)
Log:add_entry(self.levels.TRACE, msg, event)
---@param pipeline string|nil
function Log:trace(msg, event, pipeline)
Log:add_entry(self.levels.TRACE, msg, event, pipeline)
end

---Add a log entry at DEBUG level
---@param msg any
---@param event any
function Log:debug(msg, event)
Log:add_entry(self.levels.DEBUG, msg, event)
---@param pipeline string|nil
function Log:debug(msg, event, pipeline)
Log:add_entry(self.levels.DEBUG, msg, event, pipeline)
end

---Add a log entry at INFO level
---@param msg any
---@param event any
function Log:info(msg, event)
Log:add_entry(self.levels.INFO, msg, event)
---@param pipeline string|nil
function Log:info(msg, event, pipeline)
Log:add_entry(self.levels.INFO, msg, event, pipeline)
end

---Add a log entry at WARN level
---@param msg any
---@param event any
function Log:warn(msg, event)
Log:add_entry(self.levels.WARN, msg, event)
---@param pipeline string|nil
function Log:warn(msg, event, pipeline)
Log:add_entry(self.levels.WARN, msg, event, pipeline)
end

---Add a log entry at ERROR level
---@param msg any
---@param event any
function Log:error(msg, event)
Log:add_entry(self.levels.ERROR, msg, event)
---@param pipeline string|nil
function Log:error(msg, event, pipeline)
Log:add_entry(self.levels.ERROR, msg, event, pipeline)
end

return setmetatable(Log, Log_mt)
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