Skyler Grey | 3d1b450 | 2022-10-31 00:11:11 +0000 | [diff] [blame] | 1 | -- venn.nvim: enable or disable keymappings |
| 2 | function _G.Toggle_venn() |
| 3 | local venn_enabled = vim.inspect(vim.b.venn_enabled) |
| 4 | if venn_enabled == "nil" then |
| 5 | vim.b.venn_enabled = true |
| 6 | vim.cmd[[setlocal ve=all]] |
| 7 | -- draw a line on HJKL keystokes |
| 8 | vim.cmd("call HardTimeOff()") |
| 9 | vim.api.nvim_buf_set_keymap(0, "n", "J", "<C-v>j:VBox<CR>", {noremap = true}) |
| 10 | vim.api.nvim_buf_set_keymap(0, "n", "K", "<C-v>k:VBox<CR>", {noremap = true}) |
| 11 | vim.api.nvim_buf_set_keymap(0, "n", "L", "<C-v>l:VBox<CR>", {noremap = true}) |
| 12 | vim.api.nvim_buf_set_keymap(0, "n", "H", "<C-v>h:VBox<CR>", {noremap = true}) |
| 13 | -- draw a box by pressing "f" with visual selection |
| 14 | vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox<CR>", {noremap = true}) |
| 15 | print("Enabled draw-mode") |
| 16 | else |
| 17 | vim.cmd("call HardTimeOn()") |
| 18 | vim.cmd[[setlocal ve=]] |
| 19 | vim.cmd[[mapclear <buffer>]] |
| 20 | vim.b.venn_enabled = nil |
| 21 | print("Disabled draw-mode") |
| 22 | end |
| 23 | end |
| 24 | -- toggle keymappings for venn using <leader>v |
| 25 | vim.api.nvim_set_keymap('n', '<leader>d', ":lua Toggle_venn()<CR>", { noremap = true}) |
| 26 | vim.api.nvim_set_keymap('n', '<leader>v', ":lua Toggle_venn()<CR>", { noremap = true}) |
| 27 | |