summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/lvim/bootstrap.lua17
-rw-r--r--lua/lvim/core/commands.lua1
-rw-r--r--lua/lvim/core/dashboard.lua2
-rw-r--r--lua/lvim/core/telescope/custom-finders.lua21
4 files changed, 31 insertions, 10 deletions
diff --git a/lua/lvim/bootstrap.lua b/lua/lvim/bootstrap.lua
index 7545b3be..44705a53 100644
--- a/lua/lvim/bootstrap.lua
+++ b/lua/lvim/bootstrap.lua
@@ -175,10 +175,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
diff --git a/lua/lvim/core/commands.lua b/lua/lvim/core/commands.lua
index a9dd51c0..6997795d 100644
--- a/lua/lvim/core/commands.lua
+++ b/lua/lvim/core/commands.lua
@@ -17,6 +17,7 @@ M.defaults = {
[[ command! LvimSyncCorePlugins lua require('lvim.plugin-loader'):sync_core_plugins() ]],
[[ command! LvimReload lua require('lvim.config'):reload() ]],
[[ command! LvimToggleFormatOnSave lua require('lvim.core.autocmds').toggle_format_on_save() ]],
+ [[ command! LvimVersion lua require('lvim.core.telescope.custom-finders').view_lunarvim_changelog() ]],
}
M.load = function(commands)
diff --git a/lua/lvim/core/dashboard.lua b/lua/lvim/core/dashboard.lua
index 22e5c9b6..0f62d973 100644
--- a/lua/lvim/core/dashboard.lua
+++ b/lua/lvim/core/dashboard.lua
@@ -84,7 +84,7 @@ M.setup = function()
if lvim_version then
table.insert(footer, 2, "")
- table.insert(footer, 3, "v" .. lvim_version)
+ table.insert(footer, 2, lvim_version)
end
local text = require "lvim.interface.text"
diff --git a/lua/lvim/core/telescope/custom-finders.lua b/lua/lvim/core/telescope/custom-finders.lua
index 68fd0b07..5ce1485c 100644
--- a/lua/lvim/core/telescope/custom-finders.lua
+++ b/lua/lvim/core/telescope/custom-finders.lua
@@ -39,12 +39,22 @@ function M.grep_lunarvim_files(opts)
builtin.live_grep(opts)
end
+local copy_to_clipboard_action = function(prompt_bufnr)
+ local _, action_state = pcall(require, "telescope.actions.state")
+ local entry = action_state.get_selected_entry()
+ local version = entry.value
+ vim.fn.setreg("+", version)
+ vim.fn.setreg('"', version)
+ vim.notify("Copied " .. version .. " to clipboard", vim.log.levels.INFO)
+ actions.close(prompt_bufnr)
+end
+
function M.view_lunarvim_changelog()
- local opts = { cwd = get_lvim_base_dir() }
+ local opts = themes.get_ivy { cwd = get_lvim_base_dir() }
opts.entry_maker = make_entry.gen_from_git_commits(opts)
pickers.new(opts, {
- prompt_title = "LunarVim changelog",
+ prompt_title = "~ LunarVim Changelog ~",
finder = finders.new_oneshot_job(
vim.tbl_flatten {
@@ -56,16 +66,13 @@ function M.view_lunarvim_changelog()
opts
),
previewer = {
- previewers.git_commit_diff_to_parent.new(opts),
- previewers.git_commit_diff_to_head.new(opts),
previewers.git_commit_diff_as_was.new(opts),
- previewers.git_commit_message.new(opts),
},
--TODO: consider opening a diff view when pressing enter
attach_mappings = function(_, map)
- map("i", "<enter>", actions._close)
- map("n", "<enter>", actions._close)
+ map("i", "<enter>", copy_to_clipboard_action)
+ map("n", "<enter>", copy_to_clipboard_action)
map("i", "<esc>", actions._close)
map("n", "<esc>", actions._close)
map("n", "q", actions._close)