presser.nvim/presser/init.lua
TheOnePath adf5b94d78 Refactored main init.lua file
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.
2023-01-13 17:18:56 +00:00

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