From b0a9ee720a64f4ec1563e7358d58506a714d39fe Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sun, 14 Nov 2021 13:44:00 +0100 Subject: refactor: more configurable format-on-save (#1937) --- lua/lvim/utils/init.lua | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'lua/lvim/utils') diff --git a/lua/lvim/utils/init.lua b/lua/lvim/utils/init.lua index cebbe75c..bf04e149 100644 --- a/lua/lvim/utils/init.lua +++ b/lua/lvim/utils/init.lua @@ -1,5 +1,4 @@ local utils = {} -local Log = require "lvim.core.log" local uv = vim.loop -- recursive Print (structure, limit, separator) @@ -58,31 +57,6 @@ function utils.generate_settings() io.close(file) end --- autoformat -function utils.toggle_autoformat() - if lvim.format_on_save then - require("lvim.core.autocmds").define_augroups { - autoformat = { - { - "BufWritePre", - "*", - ":silent lua vim.lsp.buf.formatting_sync()", - }, - }, - } - Log:debug "Format on save active" - end - - if not lvim.format_on_save then - vim.cmd [[ - if exists('#autoformat#BufWritePre') - :autocmd! autoformat - endif - ]] - Log:debug "Format on save off" - end -end - function utils.unrequire(m) package.loaded[m] = nil _G[m] = nil -- cgit v1.2.3 From 24be0ef1ef36b8cc725655e920104e9676b72f25 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sat, 27 Nov 2021 15:22:43 +0100 Subject: chore: bump core-plugins version (#1989) --- lua/lvim/utils/init.lua | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'lua/lvim/utils') diff --git a/lua/lvim/utils/init.lua b/lua/lvim/utils/init.lua index bf04e149..d7affd4b 100644 --- a/lua/lvim/utils/init.lua +++ b/lua/lvim/utils/init.lua @@ -174,6 +174,34 @@ function utils.log_contains(query) return false end -return utils +function utils.generate_plugins_sha(output) + local list = {} + output = output or "commits.lua" + + local function git_cmd(args) + local Job = require "plenary.job" + local stderr = {} + local stdout, ret = Job + :new({ + command = "git", + args = args, + on_stderr = function(_, data) + table.insert(stderr, data) + end, + }) + :sync() + return ret, stdout + end --- TODO: find a new home for these autocommands + for name, plugin in pairs(_G.packer_plugins) do + local retval, latest_sha = git_cmd { "-C", plugin.path, "rev-parse", "@{-1}" } + if retval == 0 then + -- replace dashes, remove postfixes and use lowercase + local normalize_name = (name:gsub("-", "_"):gsub("%.%S+", "")):lower() + list[normalize_name] = latest_sha[1] + end + end + utils.write_file(output, "local commits = " .. vim.inspect(list), "w") +end + +return utils -- cgit v1.2.3 From 8641c38c862d3e9818791673a9366831b81ff603 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Mon, 29 Nov 2021 09:12:13 +0100 Subject: fix(nvimtree): update settings (#2001) --- lua/lvim/utils/init.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lua/lvim/utils') diff --git a/lua/lvim/utils/init.lua b/lua/lvim/utils/init.lua index d7affd4b..8c0ad036 100644 --- a/lua/lvim/utils/init.lua +++ b/lua/lvim/utils/init.lua @@ -193,12 +193,16 @@ function utils.generate_plugins_sha(output) return ret, stdout end - for name, plugin in pairs(_G.packer_plugins) do - local retval, latest_sha = git_cmd { "-C", plugin.path, "rev-parse", "@{-1}" } + local core_plugins = require "lvim.plugins" + for _, plugin in pairs(core_plugins) do + local name = plugin[1]:match "/(%S*)" + local url = "https://github.com/" .. plugin[1] + print("checking: " .. name .. ", at: " .. url) + local retval, latest_sha = git_cmd { "ls-remote", url, "origin", "HEAD" } if retval == 0 then -- replace dashes, remove postfixes and use lowercase local normalize_name = (name:gsub("-", "_"):gsub("%.%S+", "")):lower() - list[normalize_name] = latest_sha[1] + list[normalize_name] = latest_sha[1]:gsub("\tHEAD", "") end end utils.write_file(output, "local commits = " .. vim.inspect(list), "w") -- cgit v1.2.3 From ef5ca00df50b7d7ece7a794bcfe8a3bd7d37720d Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sat, 4 Dec 2021 14:02:47 +0100 Subject: chore: bump core-plugins version (#2031) --- lua/lvim/utils/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua/lvim/utils') diff --git a/lua/lvim/utils/init.lua b/lua/lvim/utils/init.lua index 8c0ad036..cafcf506 100644 --- a/lua/lvim/utils/init.lua +++ b/lua/lvim/utils/init.lua @@ -205,7 +205,7 @@ function utils.generate_plugins_sha(output) list[normalize_name] = latest_sha[1]:gsub("\tHEAD", "") end end - utils.write_file(output, "local commits = " .. vim.inspect(list), "w") + utils.write_file(output, "local commit = " .. vim.inspect(list), "w") end return utils -- cgit v1.2.3 From 6770808bec1ffcada425ae514747f9380e3d3b8d Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Mon, 6 Dec 2021 17:04:46 +0100 Subject: feat: full compatibility with neovim v0.6 (#2037) --- lua/lvim/utils/hooks.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lua/lvim/utils') diff --git a/lua/lvim/utils/hooks.lua b/lua/lvim/utils/hooks.lua index 0fe4a7fd..1d265482 100644 --- a/lua/lvim/utils/hooks.lua +++ b/lua/lvim/utils/hooks.lua @@ -7,7 +7,9 @@ local in_headless = #vim.api.nvim_list_uis() == 0 function M.run_pre_update() Log:debug "Starting pre-update hook" _G.__luacache.clear_cache() - vim.cmd "LspStop" + if package.loaded["lspconfig"] then + vim.cmd [[ LspStop ]] + end end ---Reset any startup cache files used by Packer and Impatient @@ -34,9 +36,14 @@ function M.run_post_update() if not in_headless then vim.schedule(function() + if package.loaded["nvim-treesitter"] then + vim.cmd [[ TSUpdateSync ]] + end -- TODO: add a changelog vim.notify("Update complete", vim.log.levels.INFO) - vim.cmd "LspRestart" + if package.loaded["lspconfig"] then + vim.cmd [[ LspRestart ]] + end end) end end -- cgit v1.2.3 From 307db8936b291b82124f05bdcfeb85be5464f21d Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Thu, 9 Dec 2021 17:08:53 +0100 Subject: feat: multiple enhancements to lvim-reload (#2054) --- lua/lvim/utils/hooks.lua | 50 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 12 deletions(-) (limited to 'lua/lvim/utils') diff --git a/lua/lvim/utils/hooks.lua b/lua/lvim/utils/hooks.lua index 1d265482..9b02b958 100644 --- a/lua/lvim/utils/hooks.lua +++ b/lua/lvim/utils/hooks.lua @@ -1,38 +1,64 @@ local M = {} -local plugin_loader = require "lvim.plugin-loader" local Log = require "lvim.core.log" local in_headless = #vim.api.nvim_list_uis() == 0 function M.run_pre_update() Log:debug "Starting pre-update hook" - _G.__luacache.clear_cache() if package.loaded["lspconfig"] then vim.cmd [[ LspStop ]] end end +function M.run_pre_reload() + Log:debug "Starting pre-reload hook" + if package.loaded["lspconfig"] then + vim.cmd [[ LspStop ]] + end +end + +function M.run_on_packer_complete() + require("lvim.plugin-loader").recompile() + -- forcefully activate nvim-web-devicons + require("nvim-web-devicons").set_up_highlights() + Log:info "Reloaded configuration" +end + +function M.run_post_reload() + Log:debug "Starting post-reload hook" + if package.loaded["lspconfig"] then + vim.cmd [[ LspRestart ]] + end + + M.reset_cache() + require("lvim.plugin-loader").ensure_installed() +end + ---Reset any startup cache files used by Packer and Impatient ---It also forces regenerating any template ftplugin files ---Tip: Useful for clearing any outdated settings function M.reset_cache() - _G.__luacache.clear_cache() - require("lvim.plugin-loader").recompile() - package.loaded["lvim.lsp.templates"] = nil - - Log:debug "Re-generatring ftplugin template files" + local impatient = _G.__luacache + if impatient then + impatient.clear_cache() + end + local lvim_modules = {} + for module, _ in pairs(package.loaded) do + if module:match "lvim.core" or module:match "lvim.lsp" then + package.loaded[module] = nil + table.insert(lvim_modules, module) + end + end + Log:trace(string.format("Cache invalidated for core modules: { %s }", table.concat(lvim_modules, ", "))) require("lvim.lsp.templates").generate_templates() end function M.run_post_update() Log:debug "Starting post-update hook" - - Log:debug "Re-generatring ftplugin template files" - package.loaded["lvim.lsp.templates"] = nil - require("lvim.lsp.templates").generate_templates() + M.reset_cache() Log:debug "Updating core plugins" - plugin_loader:sync_core_plugins() + require("lvim.plugin-loader").ensure_installed() if not in_headless then vim.schedule(function() -- cgit v1.2.3