|
1 | 1 | local lazy = require("flutter-tools.lazy") |
2 | 2 | local pickers = lazy.require("telescope.pickers") ---@module "telescope.pickers" |
| 3 | +local snack_picker = lazy.require("snacks.picker") ---@module "snakcs.picker" |
3 | 4 | local finders = lazy.require("telescope.finders") ---@module "telescope.finders" |
4 | 5 | local sorters = lazy.require("telescope.sorters") ---@module "telescope.sorters" |
5 | 6 | local actions = lazy.require("telescope.actions") ---@module "telescope.actions" |
@@ -97,9 +98,8 @@ function M.get_config(items, user_opts, opts) |
97 | 98 | })) |
98 | 99 | end |
99 | 100 |
|
100 | | -function M.commands(opts) |
| 101 | +local function generate_commands_list() |
101 | 102 | local cmds = {} |
102 | | - |
103 | 103 | if commands.is_running() then |
104 | 104 | cmds = { |
105 | 105 | { |
@@ -264,8 +264,31 @@ function M.commands(opts) |
264 | 264 | }, |
265 | 265 | }) |
266 | 266 | end |
| 267 | + return cmds |
| 268 | +end |
267 | 269 |
|
268 | | - pickers.new(M.get_config(cmds, opts, { title = "Flutter tools commands" })):find() |
| 270 | +function M.commands(opts) |
| 271 | + pickers |
| 272 | + .new(M.get_config(generate_commands_list(), opts, { title = "Flutter tools commands" })) |
| 273 | + :find() |
| 274 | +end |
| 275 | + |
| 276 | +function M.commands_snack() |
| 277 | + local cmds = generate_commands_list() |
| 278 | + for index, item in ipairs(cmds) do |
| 279 | + item.text = index .. ". " .. item.label |
| 280 | + end |
| 281 | + snack_picker.pick({ |
| 282 | + title = "Flutter Tools", |
| 283 | + format = "text", |
| 284 | + autoselect = true, |
| 285 | + finder = function() return cmds end, |
| 286 | + confirm = function(picker, item) |
| 287 | + picker:close() |
| 288 | + if item and item.command then item.command() end |
| 289 | + end, |
| 290 | + layout = "select", |
| 291 | + }) |
269 | 292 | end |
270 | 293 |
|
271 | 294 | local function execute_fvm_use(bufnr) |
|
0 commit comments