diff options
author | kylo252 <[email protected]> | 2022-10-07 04:51:09 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2022-10-06 22:51:09 -0400 |
commit | f6402563abb3ace148168a27e7889c961dd94bfd (patch) | |
tree | 028cd4e2b397802d582ef7e9f35d3c8eb159f7a4 /lua/lvim | |
parent | 40e2d5a1715ab7cdb0c4b4d849f1628caadb6842 (diff) |
feat: enable global installation (#3161)
Diffstat (limited to 'lua/lvim')
-rw-r--r-- | lua/lvim/config/init.lua | 6 | ||||
-rw-r--r-- | lua/lvim/utils/git.lua | 15 |
2 files changed, 19 insertions, 2 deletions
diff --git a/lua/lvim/config/init.lua b/lua/lvim/config/init.lua index fae6c518..ea36a9a0 100644 --- a/lua/lvim/config/init.lua +++ b/lua/lvim/config/init.lua @@ -118,7 +118,11 @@ function M:load(config_path) if utils.is_file(user_config_file) then Log:warn("Invalid configuration: " .. err) else - vim.notify_once(string.format("Unable to find configuration file [%s]", config_path), vim.log.levels.WARN) + vim.notify_once( + string.format("User-configuration not found. Creating an example configuration in %s", config_path) + ) + local example_config = join_paths(get_lvim_base_dir(), "utils", "installer", "config.example.lua") + vim.loop.fs_copyfile(example_config, config_path) end end 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 |