A toolbox for neovim to put your custom neovim functions, all invokable from vim.ui.select!
return {
'DanWlker/toolbox.nvim',
keys = {
{
'<leader>st',
function()
require('toolbox').show_picker()
end,
desc = '[S]earch [T]oolbox',
mode = { 'n', 'v' },
},
},
-- Remove this if you don't need to always see telescope's ui when triggering toolbox
-- keys = {} will cause toolbox to lazy load, therefore if it loads before telescope you
-- will see the default vim.ui.select.
--
-- If you want to use your custom vim.ui.select overrides, remember to add it into dependencies
-- to ensure it loads first
--
-- Note: This is safe to remove, it is just to ensure plugins load in the correct order
dependencies = { 'nvim-telescope/telescope.nvim' },
opts = {
commands = {
{
name = 'Close current tab',
execute = 'tabclose',
},
{
name = 'Format Json',
execute = "%!jq '.'",
},
{
name = 'Print Vim table',
execute = function(v)
print(vim.inspect(v))
end,
},
{
name = 'Copy relative path to clipboard',
execute = function()
local path = vim.fn.expand '%'
vim.fn.setreg('+', path)
end,
},
{
name = 'Copy absolute path to clipboard',
execute = function()
local path = vim.fn.expand '%:p'
vim.fn.setreg('+', path)
end,
},
{
name = 'Copy Vim table to clipboard',
execute = function(v)
vim.fn.setreg('+', vim.inspect(v))
end,
},
{
name = 'Reload plugin',
execute = function(name)
package.loaded[name] = nil
require(name).setup()
end,
},
},
},
config = true,
}
{
commands = {
--Note this is the identifier for the command as well
--@type string
name = ""
--if it is a function and it requires no params, it will be immediately invoked
--if it requires params, it will be shown in the command line
--if it is a string, it will be invoked via vim.cmd, similar to `:`
--@type string|function
execute = "" | function() end
--if set for string commands, it will populate the `:` command
--@type bool
require_input = false,
}
}
- Make it work in visual mode (Done)