feat(nvim): hydra improvements

This commit is contained in:
Price Hiller 2022-09-17 17:32:38 -05:00
parent 6f7d4c5b09
commit e543f82554

View File

@ -51,7 +51,7 @@ hydra({
end,
},
mode = { "n", "x" },
body = "<leader>G",
body = "<leader>hg",
heads = {
{
"J",
@ -117,16 +117,15 @@ hydra({
})
-- Hydra for diagrams
local hint = [[
hydra({
name = "Draw Diagram",
hint = [[
Arrow^^^^^^ Select region with <C-v>
^ ^ _K_ ^ ^ _f_: surround it with box
_H_ ^ ^ _L_
^ ^ _J_ ^ ^ _<Esc>_
]]
hydra({
name = "Draw Diagram",
hint = hint,
]] ,
config = {
color = "pink",
invoke_on_body = true,
@ -140,7 +139,7 @@ hydra({
end,
},
mode = "n",
body = "<leader>D",
body = "<leader>hd",
heads = {
{ "H", "<C-v>h:VBox<CR>" },
{ "J", "<C-v>j:VBox<CR>" },
@ -150,3 +149,125 @@ hydra({
{ "<Esc>", nil, { exit = true } },
},
})
hydra({
name = "Options",
hint = [[
^ ^ Options
^
_v_ %{ve} virtual edit
_i_ %{list} invisible characters
_s_ %{spell} spell
_w_ %{wrap} wrap
_c_ %{cul} cursor line
_n_ %{nu} number
_r_ %{rnu} relative number
^
^^^^ _<Esc>_
]] ,
config = {
color = "amaranth",
invoke_on_body = true,
hint = {
border = "rounded",
position = "middle",
},
},
mode = { "n", "x" },
body = "<leader>ho",
heads = {
{
"n",
function()
if vim.o.number == true then
vim.o.number = false
else
vim.o.number = true
end
end,
{ desc = "number" },
},
{
"r",
function()
if vim.o.relativenumber == true then
vim.o.relativenumber = false
else
vim.o.number = true
vim.o.relativenumber = true
end
end,
{ desc = "relativenumber" },
},
{
"v",
function()
if vim.o.virtualedit == "all" then
vim.o.virtualedit = "block"
else
vim.o.virtualedit = "all"
end
end,
{ desc = "virtualedit" },
},
{
"i",
function()
if vim.o.list == true then
vim.o.list = false
else
vim.o.list = true
end
end,
{ desc = "show invisible" },
},
{
"s",
function()
if vim.o.spell == true then
vim.o.spell = false
else
vim.o.spell = true
end
end,
{ desc = "spell" },
},
{
"w",
function()
if vim.o.wrap ~= true then
vim.o.wrap = true
-- Dealing with word wrap:
-- If cursor is inside very long line in the file than wraps
-- around several rows on the screen, then 'j' key moves you to
-- the next line in the file, but not to the next row on the
-- screen under your previous position as in other editors. These
-- bindings fixes this.
vim.keymap.set("n", "k", function()
return vim.v.count > 0 and "k" or "gk"
end, { expr = true, desc = "k or gk" })
vim.keymap.set("n", "j", function()
return vim.v.count > 0 and "j" or "gj"
end, { expr = true, desc = "j or gj" })
else
vim.o.wrap = false
vim.keymap.del("n", "k")
vim.keymap.del("n", "j")
end
end,
{ desc = "wrap" },
},
{
"c",
function()
if vim.o.cursorline == true then
vim.o.cursorline = false
else
vim.o.cursorline = true
end
end,
{ desc = "cursor line" },
},
{ "<Esc>", nil, { exit = true } },
},
})