-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from kid-icarus/telescope
feat: add telescope picker
- Loading branch information
Showing
4 changed files
with
74 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
local pickers = require 'telescope.pickers' | ||
local finders = require 'telescope.finders' | ||
local actions = require 'telescope.actions' | ||
local action_state = require 'telescope.actions.state' | ||
local conf = require('telescope.config').values | ||
local api_client = require 'jira.api_client' | ||
|
||
local M = {} | ||
|
||
local transitions = function(opts) | ||
opts = opts or {} | ||
local results = api_client.get_transitions() | ||
pickers | ||
.new(opts, { | ||
prompt_title = 'Transitions', | ||
finder = finders.new_table { | ||
results = results, | ||
entry_maker = function(entry) | ||
return { | ||
value = entry, | ||
display = entry.name, | ||
ordinal = entry.name, | ||
} | ||
end, | ||
}, | ||
attach_mappings = function(prompt_bufnr, map) | ||
actions.select_default:replace(function() | ||
actions.close(prompt_bufnr) | ||
local selection = action_state.get_selected_entry() | ||
api_client.transition_issue(selection.value.id) | ||
end) | ||
return true | ||
end, | ||
sorter = conf.generic_sorter(opts), | ||
}) | ||
:find() | ||
end | ||
|
||
M.transitions = transitions | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
local transitions = require('jira.pickers').transitions | ||
|
||
return require('telescope').register_extension { | ||
exports = { | ||
transitions = transitions, | ||
}, | ||
} |