mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 09:49:48 +01:00
feat: relocate whichkey and add cheatsheet.nvim
This commit is contained in:
parent
44692d64d5
commit
94be9167d2
10 changed files with 144 additions and 87 deletions
22
modules/binds/cheatsheet.nix
Normal file
22
modules/binds/cheatsheet.nix
Normal 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
11
modules/binds/default.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
./which-key.nix
|
||||
./cheatsheet.nix
|
||||
];
|
||||
}
|
20
modules/binds/which-key.nix
Normal file
20
modules/binds/which-key.nix
Normal 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 {}'';
|
||||
};
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: {imports = [./which-key.nix];}
|
|
@ -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 {}'';
|
||||
};
|
||||
}
|
|
@ -16,62 +16,64 @@ in {
|
|||
isDag = 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
|
||||
# entries.
|
||||
#
|
||||
# Internally this function uses the `toposort` function in
|
||||
# `<nixpkgs/lib/lists.nix>` and its value is accordingly.
|
||||
#
|
||||
# Specifically, the result on success is
|
||||
#
|
||||
# { result = [ { name = ?; data = ?; } … ] }
|
||||
#
|
||||
# For example
|
||||
#
|
||||
# nix-repl> topoSort {
|
||||
# a = entryAnywhere "1";
|
||||
# b = entryAfter [ "a" "c" ] "2";
|
||||
# c = entryBefore [ "d" ] "3";
|
||||
# d = entryBefore [ "e" ] "4";
|
||||
# e = entryAnywhere "5";
|
||||
# } == {
|
||||
# result = [
|
||||
# { data = "1"; name = "a"; }
|
||||
# { data = "3"; name = "c"; }
|
||||
# { data = "2"; name = "b"; }
|
||||
# { data = "4"; name = "d"; }
|
||||
# { data = "5"; name = "e"; }
|
||||
# ];
|
||||
# }
|
||||
# true
|
||||
#
|
||||
# And the result on error is
|
||||
#
|
||||
# {
|
||||
# cycle = [ { after = ?; name = ?; data = ? } … ];
|
||||
# loops = [ { after = ?; name = ?; data = ? } … ];
|
||||
# }
|
||||
#
|
||||
# For example
|
||||
#
|
||||
# nix-repl> topoSort {
|
||||
# a = entryAnywhere "1";
|
||||
# b = entryAfter [ "a" "c" ] "2";
|
||||
# c = entryAfter [ "d" ] "3";
|
||||
# d = entryAfter [ "b" ] "4";
|
||||
# e = entryAnywhere "5";
|
||||
# } == {
|
||||
# cycle = [
|
||||
# { after = [ "a" "c" ]; data = "2"; name = "b"; }
|
||||
# { after = [ "d" ]; data = "3"; name = "c"; }
|
||||
# { after = [ "b" ]; data = "4"; name = "d"; }
|
||||
# ];
|
||||
# loops = [
|
||||
# { after = [ "a" "c" ]; data = "2"; name = "b"; }
|
||||
# ];
|
||||
# }
|
||||
# true
|
||||
/*
|
||||
Takes an attribute set containing entries built by entryAnywhere,
|
||||
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.
|
||||
|
||||
Specifically, the result on success is
|
||||
|
||||
{ result = [ { name = ?; data = ?; } … ] }
|
||||
|
||||
For example
|
||||
|
||||
nix-repl> topoSort {
|
||||
a = entryAnywhere "1";
|
||||
b = entryAfter [ "a" "c" ] "2";
|
||||
c = entryBefore [ "d" ] "3";
|
||||
d = entryBefore [ "e" ] "4";
|
||||
e = entryAnywhere "5";
|
||||
} == {
|
||||
result = [
|
||||
{ data = "1"; name = "a"; }
|
||||
{ data = "3"; name = "c"; }
|
||||
{ data = "2"; name = "b"; }
|
||||
{ data = "4"; name = "d"; }
|
||||
{ data = "5"; name = "e"; }
|
||||
];
|
||||
}
|
||||
true
|
||||
|
||||
And the result on error is
|
||||
|
||||
{
|
||||
cycle = [ { after = ?; name = ?; data = ? } … ];
|
||||
loops = [ { after = ?; name = ?; data = ? } … ];
|
||||
}
|
||||
|
||||
For example
|
||||
|
||||
nix-repl> topoSort {
|
||||
a = entryAnywhere "1";
|
||||
b = entryAfter [ "a" "c" ] "2";
|
||||
c = entryAfter [ "d" ] "3";
|
||||
d = entryAfter [ "b" ] "4";
|
||||
e = entryAnywhere "5";
|
||||
} == {
|
||||
cycle = [
|
||||
{ after = [ "a" "c" ]; data = "2"; name = "b"; }
|
||||
{ after = [ "d" ]; data = "3"; name = "c"; }
|
||||
{ after = [ "b" ]; data = "4"; name = "d"; }
|
||||
];
|
||||
loops = [
|
||||
{ after = [ "a" "c" ]; data = "2"; name = "b"; }
|
||||
];
|
||||
}
|
||||
true
|
||||
*/
|
||||
topoSort = dag: let
|
||||
dagBefore = dag: name:
|
||||
builtins.attrNames
|
||||
|
|
|
@ -47,6 +47,8 @@ with lib; let
|
|||
"codewindow-nvim"
|
||||
"nvim-notify"
|
||||
"cinnamon-nvim"
|
||||
"cheatsheet-nvim"
|
||||
"colorizer"
|
||||
];
|
||||
|
||||
pluginsType = with types; listOf (nullOr (either (enum availablePlugins) package));
|
||||
|
|
|
@ -17,13 +17,14 @@
|
|||
./tidal
|
||||
./autopairs
|
||||
./snippets
|
||||
./keys
|
||||
./binds
|
||||
./markdown
|
||||
./telescope
|
||||
./git
|
||||
./minimap
|
||||
./dashboard
|
||||
./notifications
|
||||
./utility
|
||||
];
|
||||
|
||||
pkgsModule = {config, ...}: {
|
||||
|
|
24
modules/utility/colorizer.nix
Normal file
24
modules/utility/colorizer.nix
Normal 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 ''
|
||||
'';
|
||||
};
|
||||
}
|
5
modules/utility/default.nix
Normal file
5
modules/utility/default.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
_: {
|
||||
imports = [
|
||||
./colorizer.nix
|
||||
];
|
||||
}
|
Loading…
Reference in a new issue