1

Add object keys

This commit is contained in:
Alex Yatskov 2025-01-19 17:26:30 -08:00
parent 8b29e84959
commit ac6b048849
2 changed files with 28 additions and 14 deletions

View File

@ -1,11 +1,11 @@
local options_current = {
auto_reload = false,
brace_last_indent = false,
brace_last_wrap = true,
brace_pad = false,
comma_last = {['{'] = true},
comma_prefix = false,
comma_prefix_indent = false,
object_char = 'a',
by_filetype = {
go = {comma_last = true},
},
@ -34,10 +34,6 @@ local function query_with_pairing(value, pairing)
return value
end
local function setup(options)
merge_table(options_current, options)
end
local function query(name, pairing)
local options_current_by_filetype = options_current.by_filetype[vim.bo.filetype]
if options_current_by_filetype then
@ -50,6 +46,26 @@ local function query(name, pairing)
return query_with_pairing(options_current[name], pairing)
end
local function setup(options)
merge_table(options_current, options)
local object_char = query('object_char')
for _, mode in ipairs({'x', 'o'}) do
vim.api.nvim_set_keymap(
mode,
'i' .. object_char,
':<C-u>ArgonautInnerObject<cr>',
{noremap = true, silent = true}
)
vim.api.nvim_set_keymap(
mode,
'a' .. object_char,
':<C-u>ArgonautOuterObject<cr>',
{noremap = true, silent = true}
)
end
end
return {
setup = setup,
query = query,

View File

@ -11,13 +11,11 @@ if not vim.g.argonaut_loaded then
require('argonaut').inspect()
end
local function argonaut_object_inner()
argonaut_reload()
local function argonaut_inner_object()
require('argonaut').object(true)
end
local function argonaut_object_outer()
argonaut_reload()
local function argonaut_outer_object()
require('argonaut').object(false)
end
@ -29,12 +27,12 @@ if not vim.g.argonaut_loaded then
require('argonaut').reflow(true)
end
vim.api.nvim_create_user_command('ArgonautInspect', argonaut_inspect, {})
vim.api.nvim_create_user_command('ArgonautObjectInner', argonaut_object_inner, {})
vim.api.nvim_create_user_command('ArgonautObjectOuter', argonaut_object_outer, {})
vim.api.nvim_create_user_command('ArgonautReflow', argonaut_reflow, {})
vim.api.nvim_create_user_command('ArgonautReload', argonaut_reload, {})
vim.api.nvim_create_user_command('ArgonautToggle', argonaut_toggle, {})
vim.api.nvim_create_user_command('ArgonautInnerObject', argonaut_inner_object, {})
vim.api.nvim_create_user_command('ArgonautOuterObject', argonaut_outer_object, {})
vim.api.nvim_create_user_command('ArgonautReflow', argonaut_reflow, {})
vim.api.nvim_create_user_command('ArgonautInspect', argonaut_inspect, {})
vim.api.nvim_create_user_command('ArgonautReload', argonaut_reload, {})
vim.g.argonaut_loaded = true
end