feat(picker): picker support
This commit is contained in:
parent
ea9883895f
commit
a33e66680b
11 changed files with 829 additions and 2 deletions
|
|
@ -698,6 +698,48 @@ local function navigate_problem(delta, language)
|
|||
setup_problem(state.contest_id, new_problem.id, language)
|
||||
end
|
||||
|
||||
local function handle_pick_action()
|
||||
if not config.picker then
|
||||
logger.log(
|
||||
'No picker configured. Set picker = "telescope" or picker = "fzf-lua" in config',
|
||||
vim.log.levels.ERROR
|
||||
)
|
||||
return
|
||||
end
|
||||
|
||||
if config.picker == 'telescope' then
|
||||
local ok, telescope = pcall(require, 'telescope')
|
||||
if not ok then
|
||||
logger.log(
|
||||
'Telescope not available. Install telescope.nvim or change picker config',
|
||||
vim.log.levels.ERROR
|
||||
)
|
||||
return
|
||||
end
|
||||
local ok_cp, telescope_cp = pcall(require, 'cp.pickers.telescope')
|
||||
if not ok_cp then
|
||||
logger.log('Failed to load telescope integration', vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
telescope_cp.platform_picker()
|
||||
elseif config.picker == 'fzf-lua' then
|
||||
local ok, _ = pcall(require, 'fzf-lua')
|
||||
if not ok then
|
||||
logger.log(
|
||||
'fzf-lua not available. Install fzf-lua or change picker config',
|
||||
vim.log.levels.ERROR
|
||||
)
|
||||
return
|
||||
end
|
||||
local ok_cp, fzf_cp = pcall(require, 'cp.pickers.fzf_lua')
|
||||
if not ok_cp then
|
||||
logger.log('Failed to load fzf-lua integration', vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
fzf_cp.platform_picker()
|
||||
end
|
||||
end
|
||||
|
||||
local function restore_from_current_file()
|
||||
local current_file = vim.fn.expand('%:p')
|
||||
if current_file == '' then
|
||||
|
|
@ -837,6 +879,8 @@ function M.handle_command(opts)
|
|||
navigate_problem(1, cmd.language)
|
||||
elseif cmd.action == 'prev' then
|
||||
navigate_problem(-1, cmd.language)
|
||||
elseif cmd.action == 'pick' then
|
||||
handle_pick_action()
|
||||
end
|
||||
return
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue