diff options
| author | kylo252 <[email protected]> | 2022-03-19 20:02:45 +0100 | 
|---|---|---|
| committer | GitHub <[email protected]> | 2022-03-19 20:02:45 +0100 | 
| commit | c946ddda812c5c2d217061a9016eb8001970d659 (patch) | |
| tree | eec7964b135a160244f5ef919f28658c4a988237 /lua/lvim/utils | |
| parent | 7192b28a24d52b62029c414db46b9fd3a5de475e (diff) | |
feat: add alpha.nvim integration (#1906)
Diffstat (limited to 'lua/lvim/utils')
| -rw-r--r-- | lua/lvim/utils/git.lua | 53 | ||||
| -rw-r--r-- | lua/lvim/utils/hooks.lua | 6 | 
2 files changed, 19 insertions, 40 deletions
| diff --git a/lua/lvim/utils/git.lua b/lua/lvim/utils/git.lua index 8f25a2bb..ce323160 100644 --- a/lua/lvim/utils/git.lua +++ b/lua/lvim/utils/git.lua @@ -1,11 +1,12 @@  local M = {}  local Log = require "lvim.core.log" +local if_nil = vim.F.if_nil  local function git_cmd(opts)    local plenary_loaded, Job = pcall(require, "plenary.job")    if not plenary_loaded then -    vim.cmd "packadd plenary.nvim" +    return 1, { "" }    end    opts = opts or {} @@ -89,51 +90,27 @@ end  ---Get the current Lunarvim development branch  ---@return string|nil  function M.get_lvim_branch() -  local ret, branch = git_cmd { args = { "rev-parse", "--abbrev-ref", "HEAD" } } -  if ret ~= 0 or (not branch or branch[1] == "") then -    Log:error "Unable to retrieve the name of the current branch. Check the log for further information" -    return -  end -  return branch[1] +  local _, results = git_cmd { args = { "rev-parse", "--abbrev-ref", "HEAD" } } +  local branch = if_nil(results[1], "") +  return branch  end  ---Get currently checked-out tag of Lunarvim ----@param type string can be "short" ----@return string|nil -function M.get_lvim_tag(type) -  type = type or "" -  local ret, results = git_cmd { args = { "describe", "--tags" } } -  local lvim_full_ver = results[1] or "" +---@return string +function M.get_lvim_tag() +  local args = { "describe", "--tags", "--abbrev=0" } -  if ret ~= 0 or string.match(lvim_full_ver, "%d") == nil then -    return nil -  end -  if type == "short" then -    return vim.fn.split(lvim_full_ver, "-")[1] -  else -    return string.sub(lvim_full_ver, 1, #lvim_full_ver - 1) -  end +  local _, results = git_cmd { args = args } +  local tag = if_nil(results[1], "") +  return tag  end  ---Get the commit hash of currently checked-out commit of Lunarvim ----@param type string can be "short"  ---@return string|nil -function M.get_lvim_version(type) -  type = type or "" -  local branch = M.get_lvim_branch() -  if branch == "master" then -    return M.get_lvim_tag(type) -  end -  local ret, log_results = git_cmd { args = { "log", "--pretty=format:%h", "-1" } } -  local abbrev_version = log_results[1] or "" -  if ret ~= 0 or string.match(abbrev_version, "%d") == nil then -    Log:error "Unable to retrieve current version. Check the log for further information" -    return nil -  end -  if type == "short" then -    return abbrev_version -  end -  return branch .. "-" .. abbrev_version +function M.get_lvim_current_sha() +  local _, log_results = git_cmd { args = { "log", "--pretty=format:%h", "-1" } } +  local abbrev_version = if_nil(log_results[1], "") +  return abbrev_version  end  function M.generate_plugins_sha(output) diff --git a/lua/lvim/utils/hooks.lua b/lua/lvim/utils/hooks.lua index d28123ab..b40f2c23 100644 --- a/lua/lvim/utils/hooks.lua +++ b/lua/lvim/utils/hooks.lua @@ -12,8 +12,10 @@ function M.run_pre_reload()  end  function M.run_on_packer_complete() -  -- manually trigger event to fix colors -  vim.cmd [[ doautocmd ColorScheme ]] +  if not in_headless then +    -- manually trigger event to fix colors +    vim.cmd [[ doautocmd ColorScheme ]] +  end    Log:info "Reloaded configuration"  end | 
