summaryrefslogtreecommitdiff
path: root/lua/lvim/bootstrap.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/lvim/bootstrap.lua')
-rw-r--r--lua/lvim/bootstrap.lua27
1 files changed, 19 insertions, 8 deletions
diff --git a/lua/lvim/bootstrap.lua b/lua/lvim/bootstrap.lua
index 74a9bf45..702dfae1 100644
--- a/lua/lvim/bootstrap.lua
+++ b/lua/lvim/bootstrap.lua
@@ -2,6 +2,7 @@ local M = {}
local uv = vim.loop
local path_sep = uv.os_uname().version:match "Windows" and "\\" or "/"
+local in_headless = #vim.api.nvim_list_uis() == 0
---Join path segments that were passed as input
---@return string
@@ -46,7 +47,7 @@ end
function M:init(base_dir)
self.runtime_dir = get_runtime_dir()
self.config_dir = get_config_dir()
- self.cache_path = get_cache_dir()
+ self.cache_dir = get_cache_dir()
self.pack_dir = join_paths(self.runtime_dir, "site", "pack")
self.packer_install_dir = join_paths(self.runtime_dir, "site", "pack", "packer", "start", "packer.nvim")
self.packer_cache_path = join_paths(self.config_dir, "plugin", "packer_compiled.lua")
@@ -71,16 +72,13 @@ function M:init(base_dir)
-- TODO: we need something like this: vim.opt.packpath = vim.opt.rtp
vim.cmd [[let &packpath = &runtimepath]]
- vim.cmd("set spellfile=" .. join_paths(self.config_dir, "spell", "en.utf-8.add"))
end
- vim.fn.mkdir(get_cache_dir(), "p")
-
-- FIXME: currently unreliable in unit-tests
- if not os.getenv "LVIM_TEST_ENV" then
+ if not in_headless then
_G.PLENARY_DEBUG = false
require("lvim.impatient").setup {
- path = vim.fn.stdpath "cache" .. "/lvim_cache",
+ path = join_paths(self.cache_dir, "lvim_cache"),
enable_profiling = true,
}
end
@@ -174,10 +172,23 @@ end
function M:get_version(type)
type = type or ""
local opts = { cwd = get_lvim_base_dir() }
- local status_ok, results = git_cmd({ "describe", "--tags" }, opts)
+
+ local _, branch = git_cmd({ "branch", "--show-current" }, opts)
+
+ local is_on_master = branch == "master"
+ if not is_on_master then
+ local log_status_ok, log_results = git_cmd({ "log", "--pretty=format:%h", "-1" }, opts)
+ local abbrev_version = log_results[1] or ""
+ if not log_status_ok or string.match(abbrev_version, "%d") == nil then
+ return nil
+ end
+ return "dev-" .. abbrev_version
+ end
+
+ local tag_status_ok, results = git_cmd({ "describe", "--tags" }, opts)
local lvim_full_ver = results[1] or ""
- if not status_ok or string.match(lvim_full_ver, "%d") == nil then
+ if not tag_status_ok or string.match(lvim_full_ver, "%d") == nil then
return nil
end
if type == "short" then