File has undergone refactor to reduce overall expected responsibility which was temporary for kickstarting the extension. The presser/init.lua script will now, and only now, be responsible for handling and setting up configuration of presser itself (extensibility to be concluded in future). Now, the script defines presser@setup() which is to be called by a user in their Neovim config script. This function currently defines one user command which allows for executing the builtins@find_replace. Most functions which were defined in table@presser have been migrated to a new location presser/actions, defined in table@actions. The function definition presser@find_replace has been migrated to presser.builtins (in builtins@find_replace). Consult other commits related to migrations for more info about specific refactors.
35 lines
728 B
Lua
35 lines
728 B
Lua
local builtins = require'presser.builtins'
|
|
|
|
local a = vim.api
|
|
|
|
local presser = {} -- list of functions to be exported
|
|
|
|
presser.setup = function ( opts )
|
|
local opts = opts or {}
|
|
-- @Dev: TODO - construct setup function for configs
|
|
--
|
|
|
|
--map("n", "<Leader>h", "<cmd>lua require'presser'.find_replace()<CR>") -- global replace with last buffer item
|
|
|
|
a.nvim_create_user_command(
|
|
'Presser',
|
|
function ( o )
|
|
local args = {}
|
|
for arg in string.gmatch( o.args, "%S+" ) do
|
|
table.insert( args, arg )
|
|
end
|
|
builtins[args[1]]()
|
|
end,
|
|
{
|
|
nargs = 1,
|
|
complete = function (ArgLead, CmdLine, CursorPos)
|
|
return { 'find_replace' }
|
|
end,
|
|
}
|
|
)
|
|
|
|
|
|
end
|
|
|
|
return presser
|