WIP on argument selection
This commit is contained in:
parent
2b2d831837
commit
710c9fad4e
@ -8,7 +8,23 @@ local function reflow()
|
||||
end
|
||||
end
|
||||
|
||||
local function object_a()
|
||||
local wrap_context = types.WrapContext.new(config.get())
|
||||
if wrap_context:parse() then
|
||||
wrap_context:object_a()
|
||||
end
|
||||
end
|
||||
|
||||
local function object_i()
|
||||
local wrap_context = types.WrapContext.new(config.get())
|
||||
if wrap_context:parse() then
|
||||
wrap_context:object_i()
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
reflow = reflow,
|
||||
setup = config.setup,
|
||||
object_a = object_a,
|
||||
object_i = object_i,
|
||||
}
|
||||
|
@ -396,6 +396,14 @@ function ParamList:parse()
|
||||
end
|
||||
end
|
||||
|
||||
function ParamList:get_active_param()
|
||||
for _, param in ipairs(self.parsed) do
|
||||
if param.offset then
|
||||
return param
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- Builder
|
||||
--
|
||||
@ -624,6 +632,28 @@ function WrapContext:toggle()
|
||||
end
|
||||
end
|
||||
|
||||
function WrapContext:object_i()
|
||||
local param = self.params:get_active_param()
|
||||
if param then
|
||||
param.start:set_current()
|
||||
vim.cmd.normal('v')
|
||||
param.stop:set_current()
|
||||
end
|
||||
end
|
||||
|
||||
function WrapContext:object_a()
|
||||
local param = self.params:get_active_param()
|
||||
if param then
|
||||
param.start:set_current()
|
||||
vim.cmd.normal('v')
|
||||
if param.terminator then
|
||||
param.terminator:set_current()
|
||||
else
|
||||
param.stop:set_current()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
WrapContext = WrapContext,
|
||||
}
|
||||
|
@ -11,8 +11,20 @@ if not vim.g.argonaut then
|
||||
require('argonaut').reflow()
|
||||
end
|
||||
|
||||
local function argonaut_object_a()
|
||||
argonaut_reload()
|
||||
require('argonaut').object_a()
|
||||
end
|
||||
|
||||
local function argonaut_object_i()
|
||||
argonaut_reload()
|
||||
require('argonaut').object_i()
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command('ArgonautReload', argonaut_reload, {})
|
||||
vim.api.nvim_create_user_command('ArgonautReflow', argonaut_reflow, {})
|
||||
vim.api.nvim_create_user_command('ArgonautObjectA', argonaut_object_a, {})
|
||||
vim.api.nvim_create_user_command('ArgonautObjectI', argonaut_object_i, {})
|
||||
|
||||
vim.g.argonaut = true
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user