dotfiles/lua/plugins/venn.lua

23 lines
1 KiB
Lua
Raw Normal View History

2024-01-03 01:24:21 +01:00
-- venn.nvim: enable or disable keymappings
function _G.Toggle_venn()
local venn_enabled = vim.inspect(vim.b.venn_enabled)
if venn_enabled == "nil" then
vim.b.venn_enabled = true
2024-03-20 12:49:43 +01:00
vim.cmd [[setlocal ve=all]]
2024-01-03 01:24:21 +01:00
-- draw a line on HJKL keystokes
2024-03-20 12:49:43 +01:00
vim.api.nvim_buf_set_keymap(0, "n", "J", "<C-v>j:VBox<CR>", { noremap = true })
vim.api.nvim_buf_set_keymap(0, "n", "K", "<C-v>k:VBox<CR>", { noremap = true })
vim.api.nvim_buf_set_keymap(0, "n", "L", "<C-v>l:VBox<CR>", { noremap = true })
vim.api.nvim_buf_set_keymap(0, "n", "H", "<C-v>h:VBox<CR>", { noremap = true })
2024-01-03 01:24:21 +01:00
-- draw a box by pressing "f" with visual selection
2024-03-20 12:49:43 +01:00
vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox<CR>", { noremap = true })
2024-01-03 01:24:21 +01:00
else
2024-03-20 12:49:43 +01:00
vim.cmd [[setlocal ve=]]
vim.cmd [[mapclear <buffer>]]
2024-01-03 01:24:21 +01:00
vim.b.venn_enabled = nil
end
end
2024-03-20 12:49:43 +01:00
2024-01-03 01:24:21 +01:00
-- toggle keymappings for venn using <leader>v
2024-03-20 12:49:43 +01:00
vim.api.nvim_set_keymap('n', '<leader>v', ":lua Toggle_venn()<CR>", { noremap = true })