---@param kind 'issue'|'pr' ---@param state 'all'|'open'|'closed' local function gh_picker(kind, state) if vim.fn.executable('gh') ~= 1 then vim.notify('gh CLI not found', vim.log.levels.WARN) return end local next_state = ({ all = 'open', open = 'closed', closed = 'all' })[state] local label = kind == 'pr' and 'PRs' or 'Issues' require('fzf-lua').fzf_exec(('gh %s list --limit 100 --state %s'):format(kind, state), { prompt = ('%s (%s)> '):format(label, state), header = ':: to toggle all/open/closed', actions = { ['default'] = function(selected) local num = selected[1]:match('^#?(%d+)') if num then vim.system({ 'gh', kind, 'view', num, '--web' }) end end, ['ctrl-o'] = function() gh_picker(kind, next_state) end, }, }) end return { 'ibhagwan/fzf-lua', dependencies = { 'nvim-tree/nvim-web-devicons' }, config = function(_, opts) require('fzf-lua').setup(opts) map('n', '', function() local fzf = require('fzf-lua') local git_dir = vim.fn.system('git rev-parse --git-dir 2>/dev/null'):gsub('\n', '') if vim.v.shell_error == 0 and git_dir ~= '' then fzf.git_files() else fzf.files() end end) map('n', 'ff', 'FzfLua files') map('n', 'fg', 'FzfLua live_grep') map('n', 'fb', 'FzfLua buffers') map('n', 'fh', 'FzfLua help_tags') map('n', 'fr', 'FzfLua resume') map('n', 'fo', 'FzfLua oldfiles') map('n', 'fc', 'FzfLua commands') map('n', 'fk', 'FzfLua keymaps') map('n', 'f/', 'FzfLua search_history') map('n', 'f:', 'FzfLua command_history') map('n', 'fe', 'FzfLua files cwd=~/.config') map('n', 'gq', 'FzfLua quickfix') map('n', 'gl', 'FzfLua loclist') map('n', 'GB', 'FzfLua git_branches') map('n', 'Gc', 'FzfLua git_commits') map('n', 'Gs', 'FzfLua git_status') map('n', 'Gp', function() gh_picker('pr', 'open') end) map('n', 'Gi', function() gh_picker('issue', 'open') end) end, opts = { 'default-title', winopts = { border = 'single', preview = { layout = 'vertical', vertical = 'down:50%', }, }, fzf_opts = { ['--layout'] = 'reverse', }, }, }