From f11909b5649f6169fe48b61a40def4924754c38e Mon Sep 17 00:00:00 2001 From: Christian Chiarulli Date: Mon, 19 Sep 2022 22:14:32 -0400 Subject: feat: breadcrumbs (#3043) --- lua/lvim/utils/functions.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lua/lvim/utils') diff --git a/lua/lvim/utils/functions.lua b/lua/lvim/utils/functions.lua index de46bc8a..1cb8ec8e 100644 --- a/lua/lvim/utils/functions.lua +++ b/lua/lvim/utils/functions.lua @@ -16,4 +16,17 @@ function M.smart_quit() end end +function M.isempty(s) + return s == nil or s == "" +end + +function M.get_buf_option(opt) + local status_ok, buf_option = pcall(vim.api.nvim_buf_get_option, 0, opt) + if not status_ok then + return nil + else + return buf_option + end +end + return M -- cgit v1.2.3 From 82f4b353b3c8ecb4f6cb216b00486643f1c07e67 Mon Sep 17 00:00:00 2001 From: ChristianChiarulli Date: Wed, 21 Sep 2022 14:01:39 -0400 Subject: feat: only show reloaded config on debug log level to decrease noise --- lua/lvim/utils/hooks.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua/lvim/utils') diff --git a/lua/lvim/utils/hooks.lua b/lua/lvim/utils/hooks.lua index f15f6729..00b07afb 100644 --- a/lua/lvim/utils/hooks.lua +++ b/lua/lvim/utils/hooks.lua @@ -19,7 +19,7 @@ function M.run_on_packer_complete() pcall(vim.cmd, "colorscheme " .. lvim.colorscheme) if M._reload_triggered then - Log:info "Reloaded configuration" + Log:debug "Reloaded configuration" M._reload_triggered = nil end end -- cgit v1.2.3 From 1c03ac80529d90c7a824a581172b6e41e6ae237b Mon Sep 17 00:00:00 2001 From: Christian Chiarulli Date: Mon, 3 Oct 2022 00:56:23 +0000 Subject: feat: reload and lir color update (#3123) --- lua/lvim/utils/reload.lua | 80 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 lua/lvim/utils/reload.lua (limited to 'lua/lvim/utils') diff --git a/lua/lvim/utils/reload.lua b/lua/lvim/utils/reload.lua new file mode 100644 index 00000000..46392349 --- /dev/null +++ b/lua/lvim/utils/reload.lua @@ -0,0 +1,80 @@ +local M = {} + +-- revisit this +-- function prequire(package) +-- local status, lib = pcall(require, package) +-- if status then +-- return lib +-- else +-- vim.notify("Failed to require '" .. package .. "' from " .. debug.getinfo(2).source) +-- return nil +-- end +-- end + +local function _assign(old, new, k) + local otype = type(old[k]) + local ntype = type(new[k]) + -- print("hi") + if (otype == "thread" or otype == "userdata") or (ntype == "thread" or ntype == "userdata") then + vim.notify(string.format("warning: old or new attr %s type be thread or userdata", k)) + end + old[k] = new[k] +end + +local function _replace(old, new, repeat_tbl) + if repeat_tbl[old] then + return + end + repeat_tbl[old] = true + + local dellist = {} + for k, _ in pairs(old) do + if not new[k] then + table.insert(dellist, k) + end + end + for _, v in ipairs(dellist) do + old[v] = nil + end + + for k, _ in pairs(new) do + if not old[k] then + old[k] = new[k] + else + if type(old[k]) ~= type(new[k]) then + vim.notify(string.format("warning: attr %s old type no equal new type!!!", k)) + _assign(old, new, k) + else + if type(old[k]) == "table" then + _replace(old[k], new[k], repeat_tbl) + else + _assign(old, new, k) + end + end + end + end +end + +M.reload = function(mod) + if not package.loaded[mod] then + local m = require(mod) + return m + end + -- vim.notify "begin reload!!!" + + local old = package.loaded[mod] + package.loaded[mod] = nil + local new = require(mod) + + if type(old) == "table" and type(new) == "table" then + -- vim.notify "pick object in new module to old module!!!" + local repeat_tbl = {} + _replace(old, new, repeat_tbl) + end + + package.loaded[mod] = old + -- vim.notify "finish reload!!!" + return old +end + +return M -- cgit v1.2.3 From 6a72ad281e598e445d37aaa87a9ef293d974bc40 Mon Sep 17 00:00:00 2001 From: chaesngmin Date: Mon, 3 Oct 2022 10:19:59 +0900 Subject: Fix: correct typos (#3117) --- lua/lvim/utils/hooks.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua/lvim/utils') diff --git a/lua/lvim/utils/hooks.lua b/lua/lvim/utils/hooks.lua index 00b07afb..fd78ef19 100644 --- a/lua/lvim/utils/hooks.lua +++ b/lua/lvim/utils/hooks.lua @@ -63,7 +63,7 @@ function M.run_post_update() end) local ret = require_clean("lvim.utils.git").switch_lvim_branch(compat_tag) if ret then - vim.notify("Reverted to the last known compatibile version: " .. compat_tag, vim.log.levels.WARN) + vim.notify("Reverted to the last known compatible version: " .. compat_tag, vim.log.levels.WARN) end return end -- cgit v1.2.3 From e5bcf01c759e7c833d8a5f1fcf665b6ea32a7c16 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Tue, 4 Oct 2022 19:23:52 +0200 Subject: refactor: more deliberate reload (#3133) --- lua/lvim/utils/hooks.lua | 2 +- lua/lvim/utils/modules.lua | 98 ++++++++++++++++++++++++++++++++++++++++++++++ lua/lvim/utils/reload.lua | 80 ------------------------------------- 3 files changed, 99 insertions(+), 81 deletions(-) create mode 100644 lua/lvim/utils/modules.lua delete mode 100644 lua/lvim/utils/reload.lua (limited to 'lua/lvim/utils') diff --git a/lua/lvim/utils/hooks.lua b/lua/lvim/utils/hooks.lua index fd78ef19..4101c573 100644 --- a/lua/lvim/utils/hooks.lua +++ b/lua/lvim/utils/hooks.lua @@ -61,7 +61,7 @@ function M.run_post_update() vim.wait(1000, function() return false end) - local ret = require_clean("lvim.utils.git").switch_lvim_branch(compat_tag) + local ret = reload("lvim.utils.git").switch_lvim_branch(compat_tag) if ret then vim.notify("Reverted to the last known compatible version: " .. compat_tag, vim.log.levels.WARN) end diff --git a/lua/lvim/utils/modules.lua b/lua/lvim/utils/modules.lua new file mode 100644 index 00000000..d5674483 --- /dev/null +++ b/lua/lvim/utils/modules.lua @@ -0,0 +1,98 @@ +local M = {} + +local Log = require "lvim.core.log" +-- revisit this +-- function prequire(package) +-- local status, lib = pcall(require, package) +-- if status then +-- return lib +-- else +-- vim.notify("Failed to require '" .. package .. "' from " .. debug.getinfo(2).source) +-- return nil +-- end +-- end + +local function _assign(old, new, k) + local otype = type(old[k]) + local ntype = type(new[k]) + -- print("hi") + if (otype == "thread" or otype == "userdata") or (ntype == "thread" or ntype == "userdata") then + vim.notify(string.format("warning: old or new attr %s type be thread or userdata", k)) + end + old[k] = new[k] +end + +local function _replace(old, new, repeat_tbl) + if repeat_tbl[old] then + return + end + repeat_tbl[old] = true + + local dellist = {} + for k, _ in pairs(old) do + if not new[k] then + table.insert(dellist, k) + end + end + for _, v in ipairs(dellist) do + old[v] = nil + end + + for k, _ in pairs(new) do + if not old[k] then + old[k] = new[k] + else + if type(old[k]) ~= type(new[k]) then + Log:debug( + string.format("Reloader: mismatch between old [%s] and new [%s] type for [%s]", type(old[k]), type(new[k]), k) + ) + _assign(old, new, k) + else + if type(old[k]) == "table" then + _replace(old[k], new[k], repeat_tbl) + else + _assign(old, new, k) + end + end + end + end +end + +M.require_clean = function(m) + package.loaded[m] = nil + _G[m] = nil + local _, module = pcall(require, m) + return module +end + +M.require_safe = function(mod) + local status_ok, module = pcall(require, mod) + if not status_ok then + local trace = debug.getinfo(2, "SL") + local shorter_src = trace.short_src + local lineinfo = shorter_src .. ":" .. (trace.currentline or trace.linedefined) + local msg = string.format("%s : skipped loading [%s]", lineinfo, mod) + Log:debug(msg) + end + return module +end + +M.reload = function(mod) + if not package.loaded[mod] then + return M.require_safe(mod) + end + + local old = package.loaded[mod] + package.loaded[mod] = nil + local new = M.require_safe(mod) + + if type(old) == "table" and type(new) == "table" then + local repeat_tbl = {} + _replace(old, new, repeat_tbl) + end + + package.loaded[mod] = old + return old +end + +return M diff --git a/lua/lvim/utils/reload.lua b/lua/lvim/utils/reload.lua deleted file mode 100644 index 46392349..00000000 --- a/lua/lvim/utils/reload.lua +++ /dev/null @@ -1,80 +0,0 @@ -local M = {} - --- revisit this --- function prequire(package) --- local status, lib = pcall(require, package) --- if status then --- return lib --- else --- vim.notify("Failed to require '" .. package .. "' from " .. debug.getinfo(2).source) --- return nil --- end --- end - -local function _assign(old, new, k) - local otype = type(old[k]) - local ntype = type(new[k]) - -- print("hi") - if (otype == "thread" or otype == "userdata") or (ntype == "thread" or ntype == "userdata") then - vim.notify(string.format("warning: old or new attr %s type be thread or userdata", k)) - end - old[k] = new[k] -end - -local function _replace(old, new, repeat_tbl) - if repeat_tbl[old] then - return - end - repeat_tbl[old] = true - - local dellist = {} - for k, _ in pairs(old) do - if not new[k] then - table.insert(dellist, k) - end - end - for _, v in ipairs(dellist) do - old[v] = nil - end - - for k, _ in pairs(new) do - if not old[k] then - old[k] = new[k] - else - if type(old[k]) ~= type(new[k]) then - vim.notify(string.format("warning: attr %s old type no equal new type!!!", k)) - _assign(old, new, k) - else - if type(old[k]) == "table" then - _replace(old[k], new[k], repeat_tbl) - else - _assign(old, new, k) - end - end - end - end -end - -M.reload = function(mod) - if not package.loaded[mod] then - local m = require(mod) - return m - end - -- vim.notify "begin reload!!!" - - local old = package.loaded[mod] - package.loaded[mod] = nil - local new = require(mod) - - if type(old) == "table" and type(new) == "table" then - -- vim.notify "pick object in new module to old module!!!" - local repeat_tbl = {} - _replace(old, new, repeat_tbl) - end - - package.loaded[mod] = old - -- vim.notify "finish reload!!!" - return old -end - -return M -- cgit v1.2.3 From 9def60f1dd09ac2244672b8570092229977b43b4 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Thu, 6 Oct 2022 08:55:06 +0200 Subject: feat: lock new installations to nvim 0.8+ (#3111) --- lua/lvim/utils/hooks.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lua/lvim/utils') diff --git a/lua/lvim/utils/hooks.lua b/lua/lvim/utils/hooks.lua index 4101c573..ce4335a9 100644 --- a/lua/lvim/utils/hooks.lua +++ b/lua/lvim/utils/hooks.lua @@ -52,8 +52,8 @@ end function M.run_post_update() Log:debug "Starting post-update hook" - if vim.fn.has "nvim-0.7" ~= 1 then - local compat_tag = "1.1.3" + if vim.fn.has "nvim-0.8" ~= 1 then + local compat_tag = "1.1.4" vim.notify( "Please upgrade your Neovim base installation. Newer version of Lunarvim requires v0.7+", vim.log.levels.WARN -- cgit v1.2.3 From f6402563abb3ace148168a27e7889c961dd94bfd Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Fri, 7 Oct 2022 04:51:09 +0200 Subject: feat: enable global installation (#3161) --- lua/lvim/utils/git.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'lua/lvim/utils') diff --git a/lua/lvim/utils/git.lua b/lua/lvim/utils/git.lua index 99c178f3..e1b5ccf2 100644 --- a/lua/lvim/utils/git.lua +++ b/lua/lvim/utils/git.lua @@ -1,6 +1,7 @@ local M = {} local Log = require "lvim.core.log" +local fmt = string.format local if_nil = vim.F.if_nil local function git_cmd(opts) @@ -43,9 +44,16 @@ local function safe_deep_fetch() local fetch_mode = result[1] == "true" and "--unshallow" or "--all" ret = git_cmd { args = { "fetch", fetch_mode } } if ret ~= 0 then - Log:error("Git fetch failed! Please pull the changes manually in " .. get_lvim_base_dir()) + Log:error(fmt "Git fetch %s failed! Please pull the changes manually in %s", fetch_mode, get_lvim_base_dir()) return end + if fetch_mode == "--unshallow" then + ret = git_cmd { args = { "remote", "set-branches", "origin", "*" } } + if ret ~= 0 then + Log:error(fmt "Git fetch %s failed! Please pull the changes manually in %s", fetch_mode, get_lvim_base_dir()) + return + end + end return true end @@ -53,6 +61,11 @@ end function M.update_base_lvim() Log:info "Checking for updates" + if not vim.loop.fs_access(get_lvim_base_dir(), "w") then + Log:warn(fmt("Lunarvim update aborted! cannot write to %s", get_lvim_base_dir())) + return + end + if not safe_deep_fetch() then return end -- cgit v1.2.3 From fcced1811ec45f0c3e58eef99dd962ef872be20b Mon Sep 17 00:00:00 2001 From: Ali Almohaya Date: Thu, 13 Oct 2022 03:35:48 +0300 Subject: fix: typo in git.lua --- lua/lvim/utils/git.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua/lvim/utils') diff --git a/lua/lvim/utils/git.lua b/lua/lvim/utils/git.lua index e1b5ccf2..c1bdca1b 100644 --- a/lua/lvim/utils/git.lua +++ b/lua/lvim/utils/git.lua @@ -40,7 +40,7 @@ local function safe_deep_fetch() Log:error(vim.inspect(error)) return end - -- git fetch --unshallow will cause an error on a a complete clone + -- git fetch --unshallow will cause an error on a complete clone local fetch_mode = result[1] == "true" and "--unshallow" or "--all" ret = git_cmd { args = { "fetch", fetch_mode } } if ret ~= 0 then -- cgit v1.2.3 From d433409995250f29437831d1961346821e364292 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Fri, 14 Oct 2022 14:09:08 +0200 Subject: feat: latest impatient updates from upstream (#3236) --- lua/lvim/utils/hooks.lua | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'lua/lvim/utils') diff --git a/lua/lvim/utils/hooks.lua b/lua/lvim/utils/hooks.lua index ce4335a9..bf0dac60 100644 --- a/lua/lvim/utils/hooks.lua +++ b/lua/lvim/utils/hooks.lua @@ -34,10 +34,7 @@ end ---It also forces regenerating any template ftplugin files ---Tip: Useful for clearing any outdated settings function M.reset_cache() - local impatient = _G.__luacache - if impatient then - impatient.clear_cache() - end + vim.cmd [[LuaCacheClear]] local lvim_modules = {} for module, _ in pairs(package.loaded) do if module:match "lvim.core" or module:match "lvim.lsp" then -- cgit v1.2.3