1

WIP on argument selection

This commit is contained in:
Alex Yatskov 2024-05-04 11:35:22 -07:00
parent 2b2d831837
commit 710c9fad4e
3 changed files with 58 additions and 0 deletions

View File

@ -8,7 +8,23 @@ local function reflow()
end end
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 { return {
reflow = reflow, reflow = reflow,
setup = config.setup, setup = config.setup,
object_a = object_a,
object_i = object_i,
} }

View File

@ -396,6 +396,14 @@ function ParamList:parse()
end end
end end
function ParamList:get_active_param()
for _, param in ipairs(self.parsed) do
if param.offset then
return param
end
end
end
-- --
-- Builder -- Builder
-- --
@ -624,6 +632,28 @@ function WrapContext:toggle()
end end
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 { return {
WrapContext = WrapContext, WrapContext = WrapContext,
} }

View File

@ -11,8 +11,20 @@ if not vim.g.argonaut then
require('argonaut').reflow() require('argonaut').reflow()
end 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('ArgonautReload', argonaut_reload, {})
vim.api.nvim_create_user_command('ArgonautReflow', argonaut_reflow, {}) 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 vim.g.argonaut = true
end end