LazyVim.LazyVim/lua/lazyvim/plugins/extras/util/octo.lua
Iordanis Petkakis 16a772452a
feat(octo): add support for snacks picker (#5625)
## Description
A [PR](https://github.com/pwntester/octo.nvim/pull/858) has landed in
`octo.nvim` that adds initial support for `snacks.picker`. Enable it in
`octo.nvim` Extra if user uses `snacks.picker`.

I also changed the checks to use `has_extra`. This was needed for
`snacks.picker`, since `has("snacks.nvim")` doesn't ensure that user
also has `snacks.picker` enabled. For the others I just changed it for
conformity, but if you think there might be something wrong about that
(that I'm unable to think of), please feel free to change them back.
<!-- Describe the big picture of your changes to communicate to the
maintainers
  why we should accept this pull request. -->

## Related Issue(s)
None
<!--
  If this PR fixes any issues, please link to the issue here.
  - Fixes #<issue_number>
-->

## Screenshots

<!-- Add screenshots of the changes if applicable. -->

## Checklist

- [x] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
2025-02-16 12:20:06 +01:00

70 lines
2.8 KiB
Lua

return {
-- depends on the git extra for highlighting and auto-completion of github issues/prs
{ import = "lazyvim.plugins.extras.lang.git" },
-- Octo
{
"pwntester/octo.nvim",
cmd = "Octo",
event = { { event = "BufReadCmd", pattern = "octo://*" } },
opts = {
enable_builtin = true,
default_to_projects_v2 = true,
default_merge_method = "squash",
picker = "telescope",
},
keys = {
{ "<leader>gi", "<cmd>Octo issue list<CR>", desc = "List Issues (Octo)" },
{ "<leader>gI", "<cmd>Octo issue search<CR>", desc = "Search Issues (Octo)" },
{ "<leader>gp", "<cmd>Octo pr list<CR>", desc = "List PRs (Octo)" },
{ "<leader>gP", "<cmd>Octo pr search<CR>", desc = "Search PRs (Octo)" },
{ "<leader>gr", "<cmd>Octo repo list<CR>", desc = "List Repos (Octo)" },
{ "<leader>gS", "<cmd>Octo search<CR>", desc = "Search (Octo)" },
{ "<localleader>a", "", desc = "+assignee (Octo)", ft = "octo" },
{ "<localleader>c", "", desc = "+comment/code (Octo)", ft = "octo" },
{ "<localleader>l", "", desc = "+label (Octo)", ft = "octo" },
{ "<localleader>i", "", desc = "+issue (Octo)", ft = "octo" },
{ "<localleader>r", "", desc = "+react (Octo)", ft = "octo" },
{ "<localleader>p", "", desc = "+pr (Octo)", ft = "octo" },
{ "<localleader>pr", "", desc = "+rebase (Octo)", ft = "octo" },
{ "<localleader>ps", "", desc = "+squash (Octo)", ft = "octo" },
{ "<localleader>v", "", desc = "+review (Octo)", ft = "octo" },
{ "<localleader>g", "", desc = "+goto_issue (Octo)", ft = "octo" },
{ "@", "@<C-x><C-o>", mode = "i", ft = "octo", silent = true },
{ "#", "#<C-x><C-o>", mode = "i", ft = "octo", silent = true },
},
},
-- Octo Picker
{
"pwntester/octo.nvim",
opts = function(_, opts)
vim.treesitter.language.register("markdown", "octo")
if LazyVim.has_extra("editor.telescope") then
opts.picker = "telescope"
elseif LazyVim.has_extra("editor.fzf") then
opts.picker = "fzf-lua"
elseif LazyVim.has_extra("editor.snacks_picker") then
opts.picker = "snacks"
else
LazyVim.error("`octo.nvim` requires `telescope.nvim` or `fzf-lua` or `snacks.nvim`")
end
-- Keep some empty windows in sessions
vim.api.nvim_create_autocmd("ExitPre", {
group = vim.api.nvim_create_augroup("octo_exit_pre", { clear = true }),
callback = function(ev)
local keep = { "octo" }
for _, win in ipairs(vim.api.nvim_list_wins()) do
local buf = vim.api.nvim_win_get_buf(win)
if vim.tbl_contains(keep, vim.bo[buf].filetype) then
vim.bo[buf].buftype = "" -- set buftype to empty to keep the window
end
end
end,
})
end,
},
}