feat: add window title for each of the actions
This commit is contained in:
parent
8ac1035d8a
commit
75d1c0d171
3 changed files with 8 additions and 5 deletions
|
|
@ -59,12 +59,14 @@ Action can be run on selected candidates provide functionality
|
|||
|
||||
```lua
|
||||
vim.ivy.run(
|
||||
-- The name given to the results window and displayed to the user
|
||||
"Title",
|
||||
-- Call back function to get all the candidates that will be displayed in
|
||||
-- the results window, The `input` will be passed in, so you can filter
|
||||
-- your results with the value from the prompt
|
||||
function(input) return { "One", "Two", Three } end,
|
||||
-- Action callback that will be called on the completion or peek actions.
|
||||
The currently selected item is passed in as the result.
|
||||
-- The currently selected item is passed in as the result.
|
||||
function(result) vim.cmd("edit " .. result) end
|
||||
)
|
||||
```
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@ local controller = {}
|
|||
controller.items = nil
|
||||
controller.callback = nil
|
||||
|
||||
controller.run = function(items, callback)
|
||||
controller.run = function(name, items, callback)
|
||||
controller.callback = callback
|
||||
controller.items = items
|
||||
|
||||
window.initialize()
|
||||
window.set_items { "-- Loading ---" }
|
||||
vim.api.nvim_buf_set_name(window.get_buffer(), name)
|
||||
|
||||
controller.input ""
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,17 +7,17 @@ local libivy = require "ivy.libivy"
|
|||
vim.ivy = controller
|
||||
|
||||
vim.api.nvim_create_user_command("IvyAg", function()
|
||||
vim.ivy.run(utils.command_finder "ag", utils.vimgrep_action())
|
||||
vim.ivy.run("AG", utils.command_finder "ag", utils.vimgrep_action())
|
||||
end, { bang = true, desc = "Run ag to search for content in files" })
|
||||
|
||||
vim.api.nvim_create_user_command("IvyFd", function()
|
||||
vim.ivy.run(function(term)
|
||||
vim.ivy.run("Files", function(term)
|
||||
return libivy.ivy_files(term, vim.fn.getcwd())
|
||||
end, utils.file_action())
|
||||
end, { bang = true, desc = "Find files in the project" })
|
||||
|
||||
vim.api.nvim_create_user_command("IvyBuffers", function()
|
||||
vim.ivy.run(function(input)
|
||||
vim.ivy.run("Buffers", function(input)
|
||||
local list = {}
|
||||
local buffers = vim.api.nvim_list_bufs()
|
||||
for index = 1, #buffers do
|
||||
|
|
|
|||
Loading…
Reference in a new issue