diff --git a/README.md b/README.md index 11ec7df..fae7b8b 100644 --- a/README.md +++ b/README.md @@ -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 ) ``` diff --git a/lua/ivy/controller.lua b/lua/ivy/controller.lua index 8412dce..b1dd66f 100644 --- a/lua/ivy/controller.lua +++ b/lua/ivy/controller.lua @@ -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 diff --git a/plugin/ivy.lua b/plugin/ivy.lua index b2bd595..92f22f6 100644 --- a/plugin/ivy.lua +++ b/plugin/ivy.lua @@ -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