add snack
This commit is contained in:
parent
764b7a74e5
commit
e9664aed82
|
|
@ -18,6 +18,7 @@
|
||||||
"nvim-web-devicons": { "branch": "master", "commit": "803353450c374192393f5387b6a0176d0972b848" },
|
"nvim-web-devicons": { "branch": "master", "commit": "803353450c374192393f5387b6a0176d0972b848" },
|
||||||
"oil.nvim": { "branch": "master", "commit": "f55b25e493a7df76371cfadd0ded5004cb9cd48a" },
|
"oil.nvim": { "branch": "master", "commit": "f55b25e493a7df76371cfadd0ded5004cb9cd48a" },
|
||||||
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
||||||
|
"snacks.nvim": { "branch": "main", "commit": "fe7cfe9800a182274d0f868a74b7263b8c0c020b" },
|
||||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" },
|
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" },
|
||||||
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
|
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
|
||||||
"telescope.nvim": { "branch": "master", "commit": "0d8b6eaa0b5ae6bb3d9785f7a3ba4a4c6c1b1af2" },
|
"telescope.nvim": { "branch": "master", "commit": "0d8b6eaa0b5ae6bb3d9785f7a3ba4a4c6c1b1af2" },
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,6 @@ return {
|
||||||
-- setting the keybinding for LazyGit with 'keys' is recommended in
|
-- setting the keybinding for LazyGit with 'keys' is recommended in
|
||||||
-- order to load the plugin when the command is run for the first time
|
-- order to load the plugin when the command is run for the first time
|
||||||
keys = {
|
keys = {
|
||||||
{ "<leader>lg", "<cmd>LazyGit<cr>", desc = "LazyGit" }
|
{ "<leader>gl", "<cmd>LazyGit<cr>", desc = "LazyGit" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
local function open_pr_diff(picker, item, action)
|
||||||
|
-- Get the current item if not provided
|
||||||
|
item = item or picker:current()
|
||||||
|
if not item then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get the gh_item if available (for gh_pr picker)
|
||||||
|
local gh_item = item.gh_item or item
|
||||||
|
if not gh_item.baseRefName or not gh_item.headRefName then
|
||||||
|
Snacks.notify.error 'PR diff: Missing branch information'
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
picker:close()
|
||||||
|
|
||||||
|
local base_ref = gh_item.baseRefName
|
||||||
|
local head_ref = gh_item.headRefName
|
||||||
|
local pr_number = gh_item.number
|
||||||
|
|
||||||
|
-- Fetch the PR head branch using gh (this ensures the branch is available)
|
||||||
|
if pr_number then
|
||||||
|
-- Use gh to fetch the PR branch - this handles remote branches correctly
|
||||||
|
vim.fn.system('gh pr checkout ' .. pr_number .. ' --detach --force 2>&1')
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Fetch both branches from origin to ensure they're available
|
||||||
|
vim.fn.system('git fetch origin ' .. base_ref .. ' 2>&1')
|
||||||
|
vim.fn.system('git fetch origin ' .. head_ref .. ' 2>&1')
|
||||||
|
|
||||||
|
-- Use origin/ prefix for remote branches in DiffviewOpen
|
||||||
|
-- This ensures we reference the remote branches correctly
|
||||||
|
local diff_cmd = string.format('DiffviewOpen origin/%s...origin/%s', base_ref, head_ref)
|
||||||
|
vim.cmd(diff_cmd)
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
'folke/snacks.nvim',
|
||||||
|
priority = 1000,
|
||||||
|
lazy = false,
|
||||||
|
---@type snacks.Config
|
||||||
|
opts = {
|
||||||
|
-- your configuration comes here
|
||||||
|
-- or leave it empty to use the default settings
|
||||||
|
-- refer to the configuration section below
|
||||||
|
bigfile = { enabled = true },
|
||||||
|
dashboard = { enabled = true },
|
||||||
|
explorer = {
|
||||||
|
enabled = true,
|
||||||
|
show_hidden = true,
|
||||||
|
},
|
||||||
|
indent = { enabled = true },
|
||||||
|
input = { enabled = true },
|
||||||
|
picker = {
|
||||||
|
enabled = true,
|
||||||
|
sources = {
|
||||||
|
explorer = {
|
||||||
|
hidden = true, -- Show hidden files by default
|
||||||
|
ignored = false, -- Optional: show git-ignored files by default
|
||||||
|
},
|
||||||
|
gh_pr = {
|
||||||
|
actions = {
|
||||||
|
side_by_side = {
|
||||||
|
desc = 'Open PR diff side-by-side',
|
||||||
|
action = open_pr_diff,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
win = {
|
||||||
|
input = {
|
||||||
|
keys = {
|
||||||
|
-- <C-s> in PR picker: Open side-by-side diff in DiffviewOpen
|
||||||
|
['<C-s>'] = { 'side_by_side', mode = { 'n', 'i' }, desc = 'Open PR diff side-by-side' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
notifier = { enabled = true },
|
||||||
|
quickfile = { enabled = true },
|
||||||
|
scope = { enabled = true },
|
||||||
|
scroll = { enabled = false },
|
||||||
|
statuscolumn = { enabled = true },
|
||||||
|
words = { enabled = true },
|
||||||
|
},
|
||||||
|
keys = {
|
||||||
|
{
|
||||||
|
'<leader>gi',
|
||||||
|
function()
|
||||||
|
Snacks.picker.gh_issue()
|
||||||
|
end,
|
||||||
|
desc = 'GitHub Issues (open)',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'<leader>gI',
|
||||||
|
function()
|
||||||
|
Snacks.picker.gh_issue { state = 'all' }
|
||||||
|
end,
|
||||||
|
desc = 'GitHub Issues (all)',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'<leader>gp',
|
||||||
|
function()
|
||||||
|
Snacks.picker.gh_pr()
|
||||||
|
end,
|
||||||
|
desc = 'GitHub Pull Requests (open) - Press <C-s> in picker for side-by-side diff',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'<leader>gP',
|
||||||
|
function()
|
||||||
|
Snacks.picker.gh_pr { state = 'all' }
|
||||||
|
end,
|
||||||
|
desc = 'GitHub Pull Requests (all) - Press <C-s> in picker for side-by-side diff',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue