mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 21:30:51 +00:00
feat: add venn.nvim
for drawing venn diagrams
This commit is contained in:
parent
04f174e8a8
commit
afa4206a81
5 changed files with 75 additions and 3 deletions
23
flake.lock
23
flake.lock
|
@ -211,11 +211,11 @@
|
||||||
"dashboard-nvim": {
|
"dashboard-nvim": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1675318414,
|
"lastModified": 1675464953,
|
||||||
"narHash": "sha256-cwD9Oh7VuF6rECQp1YwEu0ghuYzO8txwnxtWU8ewAgI=",
|
"narHash": "sha256-mYSSZnM2Z9uLc4ADiA/prv4JyLPaBEhwN/owwvsmkZY=",
|
||||||
"owner": "glepnir",
|
"owner": "glepnir",
|
||||||
"repo": "dashboard-nvim",
|
"repo": "dashboard-nvim",
|
||||||
"rev": "f4eedba90f0a55111351fd45444db5a82081727f",
|
"rev": "d8e5ee3651ce85a34cb1645ecf1ba1d0ce54a1c8",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -874,6 +874,7 @@
|
||||||
"todo-comments": "todo-comments",
|
"todo-comments": "todo-comments",
|
||||||
"tokyonight": "tokyonight",
|
"tokyonight": "tokyonight",
|
||||||
"trouble": "trouble",
|
"trouble": "trouble",
|
||||||
|
"venn-nvim": "venn-nvim",
|
||||||
"vim-vsnip": "vim-vsnip",
|
"vim-vsnip": "vim-vsnip",
|
||||||
"which-key": "which-key"
|
"which-key": "which-key"
|
||||||
}
|
}
|
||||||
|
@ -1103,6 +1104,22 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"venn-nvim": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1669127905,
|
||||||
|
"narHash": "sha256-Ks5qUaI0MrhVC2AhVsReVwC/2WArXqIQ36CcCSCyzAk=",
|
||||||
|
"owner": "jbyuki",
|
||||||
|
"repo": "venn.nvim",
|
||||||
|
"rev": "c114563960b8fb1197695d42798d1f3e7190b798",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "jbyuki",
|
||||||
|
"repo": "venn.nvim",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"vim-tidal-src": {
|
"vim-tidal-src": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
|
|
@ -133,6 +133,7 @@
|
||||||
};
|
};
|
||||||
vim.utility = {
|
vim.utility = {
|
||||||
colorizer.enable = true;
|
colorizer.enable = true;
|
||||||
|
venn-nvim.enable = false; # FIXME: throws an error when the command is ran manually
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -492,5 +493,10 @@
|
||||||
url = "github:uga-rosa/ccc.nvim";
|
url = "github:uga-rosa/ccc.nvim";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
venn-nvim = {
|
||||||
|
url = "github:jbyuki/venn.nvim";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ with lib; let
|
||||||
"cinnamon-nvim"
|
"cinnamon-nvim"
|
||||||
"cheatsheet-nvim"
|
"cheatsheet-nvim"
|
||||||
"colorizer"
|
"colorizer"
|
||||||
|
"venn-nvim"
|
||||||
];
|
];
|
||||||
|
|
||||||
pluginsType = with types; listOf (nullOr (either (enum availablePlugins) package));
|
pluginsType = with types; listOf (nullOr (either (enum availablePlugins) package));
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
_: {
|
_: {
|
||||||
imports = [
|
imports = [
|
||||||
./colorizer.nix
|
./colorizer.nix
|
||||||
|
./venn.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
47
modules/utility/venn.nix
Normal file
47
modules/utility/venn.nix
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib;
|
||||||
|
with builtins; let
|
||||||
|
cfg = config.vim.utility.venn-nvim;
|
||||||
|
in {
|
||||||
|
options.vim.utility.venn-nvim = {
|
||||||
|
enable = mkEnableOption "draw ASCII diagrams in Neovim";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf (cfg.enable) {
|
||||||
|
vim.startPlugins = [
|
||||||
|
"venn-nvim"
|
||||||
|
];
|
||||||
|
|
||||||
|
# TODO: https://github.com/jbyuki/venn.nvim#using-toggle-command
|
||||||
|
# add keybindings for drawing diagrams4
|
||||||
|
vim.luaConfigRC.venn-nvim = nvim.dag.entryAnywhere ''
|
||||||
|
local venn = require('venn')
|
||||||
|
-- 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
|
||||||
|
vim.cmd[[setlocal ve=all]]
|
||||||
|
-- draw a line on HJKL keystokes
|
||||||
|
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})
|
||||||
|
-- draw a box by pressing "f" with visual selection
|
||||||
|
vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox<CR>", {noremap = true})
|
||||||
|
else
|
||||||
|
vim.cmd[[setlocal ve=]]
|
||||||
|
vim.cmd[[mapclear <buffer>]]
|
||||||
|
vim.b.venn_enabled = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- toggle keymappings for venn using <leader>v
|
||||||
|
vim.api.nvim_set_keymap('n', '<leader>v', ":lua Toggle_venn()<CR>", { noremap = true})
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue