Add object keys
This commit is contained in:
parent
8b29e84959
commit
ac6b048849
@ -1,11 +1,11 @@
|
|||||||
local options_current = {
|
local options_current = {
|
||||||
auto_reload = false,
|
|
||||||
brace_last_indent = false,
|
brace_last_indent = false,
|
||||||
brace_last_wrap = true,
|
brace_last_wrap = true,
|
||||||
brace_pad = false,
|
brace_pad = false,
|
||||||
comma_last = {['{'] = true},
|
comma_last = {['{'] = true},
|
||||||
comma_prefix = false,
|
comma_prefix = false,
|
||||||
comma_prefix_indent = false,
|
comma_prefix_indent = false,
|
||||||
|
object_char = 'a',
|
||||||
by_filetype = {
|
by_filetype = {
|
||||||
go = {comma_last = true},
|
go = {comma_last = true},
|
||||||
},
|
},
|
||||||
@ -34,10 +34,6 @@ local function query_with_pairing(value, pairing)
|
|||||||
return value
|
return value
|
||||||
end
|
end
|
||||||
|
|
||||||
local function setup(options)
|
|
||||||
merge_table(options_current, options)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function query(name, pairing)
|
local function query(name, pairing)
|
||||||
local options_current_by_filetype = options_current.by_filetype[vim.bo.filetype]
|
local options_current_by_filetype = options_current.by_filetype[vim.bo.filetype]
|
||||||
if options_current_by_filetype then
|
if options_current_by_filetype then
|
||||||
@ -50,6 +46,26 @@ local function query(name, pairing)
|
|||||||
return query_with_pairing(options_current[name], pairing)
|
return query_with_pairing(options_current[name], pairing)
|
||||||
end
|
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 {
|
return {
|
||||||
setup = setup,
|
setup = setup,
|
||||||
query = query,
|
query = query,
|
||||||
|
@ -11,13 +11,11 @@ if not vim.g.argonaut_loaded then
|
|||||||
require('argonaut').inspect()
|
require('argonaut').inspect()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function argonaut_object_inner()
|
local function argonaut_inner_object()
|
||||||
argonaut_reload()
|
|
||||||
require('argonaut').object(true)
|
require('argonaut').object(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function argonaut_object_outer()
|
local function argonaut_outer_object()
|
||||||
argonaut_reload()
|
|
||||||
require('argonaut').object(false)
|
require('argonaut').object(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -29,12 +27,12 @@ if not vim.g.argonaut_loaded then
|
|||||||
require('argonaut').reflow(true)
|
require('argonaut').reflow(true)
|
||||||
end
|
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('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
|
vim.g.argonaut_loaded = true
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user