From a273c46eee751de4a61360ae0076ed4dac433e5d Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Fri, 1 Oct 2021 13:27:06 +0200 Subject: feat: add LvimUpdate command (#1634) * feat: add prelimenary LvimUpdate command * feat: use native process management * feat: add a telescope change-log utility * fix: update readme to include the new command --- lua/core/commands.lua | 2 ++ lua/core/telescope.lua | 45 +++++++++++++++++++++++++++++++++++++++++++++ lua/core/which-key.lua | 5 +++++ 3 files changed, 52 insertions(+) (limited to 'lua/core') diff --git a/lua/core/commands.lua b/lua/core/commands.lua index 22170c85..f732c9a2 100644 --- a/lua/core/commands.lua +++ b/lua/core/commands.lua @@ -12,6 +12,8 @@ M.defaults = { ]], -- :LvimInfo [[command! LvimInfo lua require('core.info').toggle_popup(vim.bo.filetype)]], + [[ command! LvimCacheReset lua require('bootstrap').reset_cache() ]], + [[ command! LvimUpdate lua require('bootstrap').update() ]], } M.load = function(commands) diff --git a/lua/core/telescope.lua b/lua/core/telescope.lua index e24a976e..eba27eec 100644 --- a/lua/core/telescope.lua +++ b/lua/core/telescope.lua @@ -114,6 +114,51 @@ function M.grep_lunarvim_files(opts) require("telescope.builtin").live_grep(opts) end +function M.view_lunarvim_changelog() + local finders = require "telescope.finders" + local make_entry = require "telescope.make_entry" + local pickers = require "telescope.pickers" + local previewers = require "telescope.previewers" + local actions = require "telescope.actions" + local opts = {} + + local conf = require("telescope.config").values + opts.entry_maker = make_entry.gen_from_git_commits(opts) + + pickers.new(opts, { + prompt_title = "LunarVim changelog", + + finder = finders.new_oneshot_job( + vim.tbl_flatten { + "git", + "log", + "--pretty=oneline", + "--abbrev-commit", + "--", + ".", + }, + 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", "", actions._close) + map("n", "", actions._close) + map("i", "", actions._close) + map("n", "", actions._close) + map("n", "q", actions._close) + return true + end, + sorter = conf.file_sorter(opts), + }):find() +end + function M.setup() local telescope = require "telescope" diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index 36949467..2e528048 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -192,6 +192,10 @@ M.config = function() "lua require('core.info').toggle_popup(vim.bo.filetype)", "Toggle LunarVim Info", }, + I = { + "lua require('core.telescope').view_lunarvim_changelog()", + "View LunarVim's changelog", + }, l = { name = "+logs", d = { @@ -210,6 +214,7 @@ M.config = function() P = { "exe 'edit '.stdpath('cache').'/packer.nvim.log'", "Open the Packer logfile" }, }, r = { "lua require('utils').reload_lv_config()", "Reload configurations" }, + u = { "LvimUpdate", "Update LunarVim" }, }, s = { name = "Search", -- cgit v1.2.3