summaryrefslogtreecommitdiff
path: root/lua/lvim/utils/init.lua
diff options
context:
space:
mode:
authorkylo252 <[email protected]>2021-12-13 17:58:35 +0100
committerGitHub <[email protected]>2021-12-13 17:58:35 +0100
commit6cf21e9ddec41addf01744176afb2e138b3e1b3f (patch)
tree4abf843da0e2ed38689c872694b13d7418536106 /lua/lvim/utils/init.lua
parent3a2d62ed2510ca05eb6ea87240a86df82338f5aa (diff)
parentb09ada89402e668ea1636bdbf671a89330199717 (diff)
Merge LunarVim/release-candidate
Diffstat (limited to 'lua/lvim/utils/init.lua')
-rw-r--r--lua/lvim/utils/init.lua62
1 files changed, 34 insertions, 28 deletions
diff --git a/lua/lvim/utils/init.lua b/lua/lvim/utils/init.lua
index cebbe75c..cafcf506 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
@@ -200,6 +174,38 @@ 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
+
+ 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]:gsub("\tHEAD", "")
+ end
+ end
+ utils.write_file(output, "local commit = " .. vim.inspect(list), "w")
+end
--- TODO: find a new home for these autocommands
+return utils