feat: relocate whichkey and add cheatsheet.nvim

This commit is contained in:
NotAShelf 2023-02-04 01:46:34 +03:00
parent 44692d64d5
commit 94be9167d2
No known key found for this signature in database
GPG key ID: 5B5C8895F28445F1
10 changed files with 144 additions and 87 deletions

View file

@ -0,0 +1,22 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.binds.cheatsheet;
in {
options.vim.binds.cheatsheet = {
enable = mkEnableOption "Searchable cheatsheet for nvim using telescope";
};
config = mkIf (cfg.enable) {
vim.startPlugins = ["cheatsheet-nvim"];
vim.luaConfigRC.cheaetsheet-nvim = nvim.dag.entryAnywhere ''
require('cheatsheet').setup({})
'';
};
}

11
modules/binds/default.nix Normal file
View file

@ -0,0 +1,11 @@
{
config,
lib,
pkgs,
...
}: {
imports = [
./which-key.nix
./cheatsheet.nix
];
}

View file

@ -0,0 +1,20 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.binds.whichKey;
in {
options.vim.binds.whichKey = {
enable = mkEnableOption "which-key menu";
};
config = mkIf (cfg.enable) {
vim.startPlugins = ["which-key"];
vim.luaConfigRC.whichkey = nvim.dag.entryAnywhere ''local wk = require("which-key").setup {}'';
};
}

View file

@ -1,6 +0,0 @@
{
config,
lib,
pkgs,
...
}: {imports = [./which-key.nix];}

View file

@ -1,24 +0,0 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.keys;
in {
options.vim.keys = {
enable = mkEnableOption "key binding plugins";
whichKey = {
enable = mkEnableOption "which-key menu";
};
};
config = mkIf (cfg.enable && cfg.whichKey.enable) {
vim.startPlugins = ["which-key"];
vim.luaConfigRC.whichkey = nvim.dag.entryAnywhere ''local wk = require("which-key").setup {}'';
};
}

View file

@ -16,62 +16,64 @@ in {
isDag = dag: isDag = dag:
builtins.isAttrs dag && all nvim.dag.isEntry (builtins.attrValues dag); builtins.isAttrs dag && all nvim.dag.isEntry (builtins.attrValues dag);
# Takes an attribute set containing entries built by entryAnywhere, /*
# entryAfter, and entryBefore to a topologically sorted list of Takes an attribute set containing entries built by entryAnywhere,
# entries. entryAfter, and entryBefore to a topologically sorted list of
# entries.
# Internally this function uses the `toposort` function in
# `<nixpkgs/lib/lists.nix>` and its value is accordingly. Internally this function uses the `toposort` function in
# `<nixpkgs/lib/lists.nix>` and its value is accordingly.
# Specifically, the result on success is
# Specifically, the result on success is
# { result = [ { name = ?; data = ?; } … ] }
# { result = [ { name = ?; data = ?; } ] }
# For example
# For example
# nix-repl> topoSort {
# a = entryAnywhere "1"; nix-repl> topoSort {
# b = entryAfter [ "a" "c" ] "2"; a = entryAnywhere "1";
# c = entryBefore [ "d" ] "3"; b = entryAfter [ "a" "c" ] "2";
# d = entryBefore [ "e" ] "4"; c = entryBefore [ "d" ] "3";
# e = entryAnywhere "5"; d = entryBefore [ "e" ] "4";
# } == { e = entryAnywhere "5";
# result = [ } == {
# { data = "1"; name = "a"; } result = [
# { data = "3"; name = "c"; } { data = "1"; name = "a"; }
# { data = "2"; name = "b"; } { data = "3"; name = "c"; }
# { data = "4"; name = "d"; } { data = "2"; name = "b"; }
# { data = "5"; name = "e"; } { data = "4"; name = "d"; }
# ]; { data = "5"; name = "e"; }
# } ];
# true }
# true
# And the result on error is
# And the result on error is
# {
# cycle = [ { after = ?; name = ?; data = ? } … ]; {
# loops = [ { after = ?; name = ?; data = ? } … ]; cycle = [ { after = ?; name = ?; data = ? } ];
# } loops = [ { after = ?; name = ?; data = ? } ];
# }
# For example
# For example
# nix-repl> topoSort {
# a = entryAnywhere "1"; nix-repl> topoSort {
# b = entryAfter [ "a" "c" ] "2"; a = entryAnywhere "1";
# c = entryAfter [ "d" ] "3"; b = entryAfter [ "a" "c" ] "2";
# d = entryAfter [ "b" ] "4"; c = entryAfter [ "d" ] "3";
# e = entryAnywhere "5"; d = entryAfter [ "b" ] "4";
# } == { e = entryAnywhere "5";
# cycle = [ } == {
# { after = [ "a" "c" ]; data = "2"; name = "b"; } cycle = [
# { after = [ "d" ]; data = "3"; name = "c"; } { after = [ "a" "c" ]; data = "2"; name = "b"; }
# { after = [ "b" ]; data = "4"; name = "d"; } { after = [ "d" ]; data = "3"; name = "c"; }
# ]; { after = [ "b" ]; data = "4"; name = "d"; }
# loops = [ ];
# { after = [ "a" "c" ]; data = "2"; name = "b"; } loops = [
# ]; { after = [ "a" "c" ]; data = "2"; name = "b"; }
# } ];
# true }
true
*/
topoSort = dag: let topoSort = dag: let
dagBefore = dag: name: dagBefore = dag: name:
builtins.attrNames builtins.attrNames

View file

@ -47,6 +47,8 @@ with lib; let
"codewindow-nvim" "codewindow-nvim"
"nvim-notify" "nvim-notify"
"cinnamon-nvim" "cinnamon-nvim"
"cheatsheet-nvim"
"colorizer"
]; ];
pluginsType = with types; listOf (nullOr (either (enum availablePlugins) package)); pluginsType = with types; listOf (nullOr (either (enum availablePlugins) package));

View file

@ -17,13 +17,14 @@
./tidal ./tidal
./autopairs ./autopairs
./snippets ./snippets
./keys ./binds
./markdown ./markdown
./telescope ./telescope
./git ./git
./minimap ./minimap
./dashboard ./dashboard
./notifications ./notifications
./utility
]; ];
pkgsModule = {config, ...}: { pkgsModule = {config, ...}: {

View file

@ -0,0 +1,24 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.utility.colorizer;
in {
options.vim.utility.colorizer = {
enable = mkEnableOption "ccc color picker for neovim";
};
config = mkIf (cfg.enable) {
vim.startPlugins = [
"colorizer"
];
vim.configRC.ccc =
nvim.dag.entryAnywhere ''
'';
};
}

View file

@ -0,0 +1,5 @@
_: {
imports = [
./colorizer.nix
];
}