diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2024-05-15 01:41:11 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2024-05-15 01:41:11 +0200 |
commit | 3d5db16dcf5b8647bb568bde6cd9d2cd2dedcd2b (patch) | |
tree | a265852683d0b7d122c9c04cc32b83cebd893354 /fnl/plugins | |
parent | 8760754a8229465308c97d992897ed5fc23df667 (diff) |
Add venn plugin
Diffstat (limited to 'fnl/plugins')
-rw-r--r-- | fnl/plugins/venn.fnl | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/fnl/plugins/venn.fnl b/fnl/plugins/venn.fnl new file mode 100644 index 0000000..037fcbc --- /dev/null +++ b/fnl/plugins/venn.fnl @@ -0,0 +1,33 @@ +;; Draw ASCII diagrams in Neovim + +(lambda enable [win] + (tset (. vim.w win) :venn_enabled true) + (set vim.wo.virtualedit :all) + (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}) + (vim.api.nvim_buf_set_keymap 0 :v :f ":VBox<cr>" {:noremap true})) + +(lambda disable [win] + (set vim.wo.virtualedit "") + (vim.api.nvim_buf_del_keymap 0 :n :J) + (vim.api.nvim_buf_del_keymap 0 :n :K) + (vim.api.nvim_buf_del_keymap 0 :n :L) + (vim.api.nvim_buf_del_keymap 0 :n :H) + (vim.api.nvim_buf_del_keymap 0 :v :f) + (tset (. vim.w win) :venn_enabled nil)) + +(lambda toggle [] + (let [win (vim.api.nvim_get_current_win)] + (let [enabled (vim.inspect (. (. vim.w win) :venn_enabled))] + (if (= enabled :nil) + (enable win) + (disable win))))) + +(fn config [] + (vim.keymap.set :n :<leader>v (fn [] + (toggle)) + {:noremap true :desc "Toggle Venn Diagram"})) + +{1 :jbyuki/venn.nvim : config} |