|
@@ -13,6 +13,24 @@ vim.filetype.add({
|
|
|
})
|
|
|
|
|
|
-- file/buffer/etc picker
|
|
|
+local telescope_actions = require('telescope.actions')
|
|
|
+local action_state = require('telescope.actions.state')
|
|
|
+local actions = {}
|
|
|
+
|
|
|
+actions.git_show_commit = function(prompt_bufnr)
|
|
|
+ local selection = action_state.get_selected_entry()
|
|
|
+ local path = vim.fn.FugitiveFind(selection.value)
|
|
|
+ telescope_actions.close(prompt_bufnr)
|
|
|
+ vim.cmd.edit(path)
|
|
|
+end
|
|
|
+
|
|
|
+local commit_mappings = {
|
|
|
+ i = {
|
|
|
+ ['<CR>'] = actions.git_show_commit,
|
|
|
+ ['<C-r>c'] = telescope_actions.git_checkout,
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
require('telescope').setup({
|
|
|
defaults = {
|
|
|
mappings = {
|
|
@@ -81,6 +99,12 @@ require('telescope').setup({
|
|
|
find_files = {
|
|
|
find_command = { "fd", "--type", "f", "--strip-cwd-prefix" }
|
|
|
},
|
|
|
+ git_commits = {
|
|
|
+ mappings = commit_mappings,
|
|
|
+ },
|
|
|
+ git_bcommits = {
|
|
|
+ mappings = commit_mappings,
|
|
|
+ },
|
|
|
},
|
|
|
})
|
|
|
|
|
@@ -94,6 +118,13 @@ local telescope_previewers = require('telescope.previewers')
|
|
|
local telescope_putils = require('telescope.previewers.utils')
|
|
|
local telescope_conf = require('telescope.config').values
|
|
|
|
|
|
+-- arbitrary git log picker
|
|
|
+vim.api.nvim_create_user_command('GLg', function(opts)
|
|
|
+ local git_command = { "git", "log", "--pretty=oneline", "--abbrev-commit" }
|
|
|
+ vim.list_extend(git_command, opts.fargs)
|
|
|
+ telescope_builtin.git_commits({ git_command = git_command })
|
|
|
+end, { nargs = '*', complete = vim.fn['fugitive#LogComplete'] })
|
|
|
+
|
|
|
-- custom picker to fallback to files if no git
|
|
|
_G.project_files = function()
|
|
|
local ok = pcall(telescope_builtin.git_files, { show_untracked = true })
|