Updated config
This commit is contained in:
31
.config/nvim/lua/usercmds.lua
Normal file
31
.config/nvim/lua/usercmds.lua
Normal file
@ -0,0 +1,31 @@
|
||||
-- ToggleWord
|
||||
vim.api.nvim_create_user_command("ToggleWord", function()
|
||||
local inverse = {
|
||||
["true"] = "false",
|
||||
["True"] = "False",
|
||||
["TRUE"] = "FALSE",
|
||||
["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, {})
|
Reference in New Issue
Block a user