35 lines
635 B
Lua
35 lines
635 B
Lua
-- ToggleWord
|
|
vim.api.nvim_create_user_command("ToggleWord", function()
|
|
local inverse = {
|
|
["horizontal"] = "vertical",
|
|
["on"] = "off",
|
|
["true"] = "false",
|
|
["True"] = "False",
|
|
["TRUE"] = "FALSE",
|
|
["yes"] = "no",
|
|
["Yes"] = "No",
|
|
["YES"] = "NO",
|
|
["1"] = "0",
|
|
["<"] = ">",
|
|
["("] = ")",
|
|
["["] = "]",
|
|
["{"] = "}",
|
|
['"'] = "'",
|
|
['""'] = "''",
|
|
["+"] = "-",
|
|
["==="] = "!==",
|
|
["=="] = "!=",
|
|
}
|
|
|
|
vim.tbl_add_reverse_lookup(inverse)
|
|
vim.cmd("normal! yiw")
|
|
local yanked = vim.fn.getreg('"')
|
|
local flipped = inverse[yanked]
|
|
|
|
if flipped == nil then
|
|
return
|
|
end
|
|
|
|
vim.cmd("normal! ciw" .. flipped)
|
|
end, {})
|