mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-23 05:40:44 +00:00
Compare commits
42 commits
f905acaf05
...
51035c5468
Author | SHA1 | Date | |
---|---|---|---|
|
51035c5468 | ||
|
477f2fb8c7 | ||
|
7bace58ab4 | ||
|
ca86aaa3af | ||
|
c991b2adea | ||
|
6d42de8aba | ||
|
39ebfbcd98 | ||
|
0daad3e51a | ||
|
7075872810 | ||
|
4e13acfac3 | ||
|
3a88caeda6 | ||
|
4c230a0460 | ||
|
cfaa2e3e77 | ||
|
217079b546 | ||
|
6fe0103209 | ||
|
6d2d9cd60e | ||
|
b1cc8bb27b | ||
|
90dd876c53 | ||
|
146fcf25e6 | ||
|
5eadc2937d | ||
|
f683cd36e0 | ||
|
bd6c228e5c | ||
|
d660aae9be | ||
|
4014ab0a01 | ||
|
659c4b5ca2 | ||
|
23c6f319cd | ||
|
57828912bb | ||
|
56a3d45ac7 | ||
|
5745fd8103 | ||
|
5a045d2ea0 | ||
|
7648cb8c7e | ||
|
6e3292f2c4 | ||
|
7abd0f8626 | ||
|
3800a1c016 | ||
|
6cd3363942 | ||
|
6d7d5ee190 | ||
|
b6c1a7145e | ||
|
b2eae85e79 | ||
|
feccaf477a | ||
|
aa040ab538 | ||
|
71727e5378 | ||
|
34b462a744 |
14 changed files with 448 additions and 73 deletions
34
flake.lock
34
flake.lock
|
@ -843,6 +843,38 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"plugin-lz-n": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1719989949,
|
||||||
|
"narHash": "sha256-oHwmlLgdJJDz5+gs1KLAa2MHQAadM/JYmHGfep9yl28=",
|
||||||
|
"owner": "nvim-neorocks",
|
||||||
|
"repo": "lz.n",
|
||||||
|
"rev": "4c790ba2c3789f580aa019712bbe3112f85e73a0",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nvim-neorocks",
|
||||||
|
"repo": "lz.n",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"plugin-lzn-auto-require": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1723928740,
|
||||||
|
"narHash": "sha256-CMWy+btqUaXUWSO4jZYDfBcNiYMFyRb8jtIdi072WP8=",
|
||||||
|
"owner": "horriblename",
|
||||||
|
"repo": "lzn-auto-require",
|
||||||
|
"rev": "1b9f6527e32bf196ce239f7a8b9a54d342605511",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "horriblename",
|
||||||
|
"repo": "lzn-auto-require",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"plugin-mind-nvim": {
|
"plugin-mind-nvim": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
@ -1872,6 +1904,8 @@
|
||||||
"plugin-lspkind": "plugin-lspkind",
|
"plugin-lspkind": "plugin-lspkind",
|
||||||
"plugin-lspsaga": "plugin-lspsaga",
|
"plugin-lspsaga": "plugin-lspsaga",
|
||||||
"plugin-lualine": "plugin-lualine",
|
"plugin-lualine": "plugin-lualine",
|
||||||
|
"plugin-lz-n": "plugin-lz-n",
|
||||||
|
"plugin-lzn-auto-require": "plugin-lzn-auto-require",
|
||||||
"plugin-mind-nvim": "plugin-mind-nvim",
|
"plugin-mind-nvim": "plugin-mind-nvim",
|
||||||
"plugin-minimap-vim": "plugin-minimap-vim",
|
"plugin-minimap-vim": "plugin-minimap-vim",
|
||||||
"plugin-modes-nvim": "plugin-modes-nvim",
|
"plugin-modes-nvim": "plugin-modes-nvim",
|
||||||
|
|
11
flake.nix
11
flake.nix
|
@ -102,6 +102,17 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
## Plugins
|
## Plugins
|
||||||
|
# Lazy loading
|
||||||
|
plugin-lz-n = {
|
||||||
|
url = "github:nvim-neorocks/lz.n";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
plugin-lzn-auto-require = {
|
||||||
|
url = "github:horriblename/lzn-auto-require";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
|
||||||
# LSP plugins
|
# LSP plugins
|
||||||
plugin-nvim-lspconfig = {
|
plugin-nvim-lspconfig = {
|
||||||
url = "github:neovim/nvim-lspconfig";
|
url = "github:neovim/nvim-lspconfig";
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
inherit (lib.modules) mkIf mkDefault;
|
inherit (lib.modules) mkIf mkDefault;
|
||||||
inherit (lib.types) nullOr str;
|
inherit (lib.types) nullOr str;
|
||||||
inherit (lib.attrsets) isAttrs mapAttrs;
|
inherit (lib.attrsets) isAttrs mapAttrs;
|
||||||
|
inherit (lib.generators) mkLuaInline;
|
||||||
|
|
||||||
binds = rec {
|
binds = rec {
|
||||||
mkLuaBinding = key: action: desc:
|
mkLuaBinding = key: action: desc:
|
||||||
|
@ -67,6 +68,22 @@
|
||||||
mkLuaBinding binding.value action binding.description;
|
mkLuaBinding binding.value action binding.description;
|
||||||
|
|
||||||
pushDownDefault = attr: mapAttrs (_: mkDefault) attr;
|
pushDownDefault = attr: mapAttrs (_: mkDefault) attr;
|
||||||
|
|
||||||
|
mkLznBinding = mode: lhs: rhs: desc: {
|
||||||
|
inherit mode lhs rhs desc;
|
||||||
|
};
|
||||||
|
|
||||||
|
mkSetLznBinding = binding: action: {
|
||||||
|
lhs = binding.value;
|
||||||
|
rhs = action;
|
||||||
|
desc = binding.description;
|
||||||
|
};
|
||||||
|
|
||||||
|
mkSetLuaLznBinding = binding: action: {
|
||||||
|
lhs = binding.value;
|
||||||
|
rhs = mkLuaInline "function() ${action} end";
|
||||||
|
desc = binding.description;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
binds
|
binds
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
typesCustom = import ./custom.nix {inherit lib;};
|
typesCustom = import ./custom.nix {inherit lib;};
|
||||||
in {
|
in {
|
||||||
inherit (typesDag) dagOf;
|
inherit (typesDag) dagOf;
|
||||||
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType;
|
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType lznPluginType lznPluginTableType;
|
||||||
inherit (typesLanguage) diagnostics mkGrammarOption;
|
inherit (typesLanguage) diagnostics mkGrammarOption;
|
||||||
inherit (typesCustom) anythingConcatLists char;
|
inherit (typesCustom) anythingConcatLists char;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,7 @@
|
||||||
inherit (lib.options) mkOption;
|
inherit (lib.options) mkOption;
|
||||||
inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair;
|
inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair;
|
||||||
inherit (lib.strings) hasPrefix removePrefix;
|
inherit (lib.strings) hasPrefix removePrefix;
|
||||||
inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr;
|
inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr oneOf bool int;
|
||||||
|
|
||||||
# Get the names of all flake inputs that start with the given prefix.
|
# Get the names of all flake inputs that start with the given prefix.
|
||||||
fromInputs = {
|
fromInputs = {
|
||||||
inputs,
|
inputs,
|
||||||
|
@ -51,8 +50,188 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
luaInline = lib.mkOptionType {
|
||||||
|
name = "luaInline";
|
||||||
|
check = x: lib.nvim.lua.isLuaInline x;
|
||||||
|
};
|
||||||
|
|
||||||
|
lznKeysSpec = submodule {
|
||||||
|
options = {
|
||||||
|
desc = mkOption {
|
||||||
|
description = "Description of the key map";
|
||||||
|
type = nullOr str;
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
noremap = mkOption {
|
||||||
|
description = "TBD";
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
expr = mkOption {
|
||||||
|
description = "TBD";
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
nowait = mkOption {
|
||||||
|
description = "TBD";
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
ft = mkOption {
|
||||||
|
description = "TBD";
|
||||||
|
type = nullOr (listOf str);
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
lhs = mkOption {
|
||||||
|
type = str;
|
||||||
|
description = "Key to bind to";
|
||||||
|
};
|
||||||
|
|
||||||
|
rhs = mkOption {
|
||||||
|
type = nullOr (either str luaInline);
|
||||||
|
default = null;
|
||||||
|
# FIXME: use a separate flag to indicate lua instead of luaInline
|
||||||
|
description = "Action to trigger. luaInline code will be wrapped in a function.";
|
||||||
|
};
|
||||||
|
|
||||||
|
mode = mkOption {
|
||||||
|
description = "Modes to bind in";
|
||||||
|
type = listOf str;
|
||||||
|
default = ["n" "x" "s" "o"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
lznPluginTableType = attrsOf lznPluginType;
|
||||||
|
lznPluginType = submodule {
|
||||||
|
options = {
|
||||||
|
## Should probably infer from the actual plugin somehow
|
||||||
|
## In general this is the name passed to packadd, so the dir name of the plugin
|
||||||
|
# name = mkOption {
|
||||||
|
# type= str;
|
||||||
|
# }
|
||||||
|
|
||||||
|
# Non-lz.n options
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
type = pluginType;
|
||||||
|
description = "Plugin package";
|
||||||
|
};
|
||||||
|
|
||||||
|
setupModule = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
description = "Lua module to run setup function on.";
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
setupOpts = mkOption {
|
||||||
|
type = submodule {freeformType = attrsOf anything;};
|
||||||
|
description = "Options to pass to the setup function";
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
# lz.n options
|
||||||
|
|
||||||
|
enabled = mkOption {
|
||||||
|
type = nullOr (either bool str);
|
||||||
|
description = "When false, or if the lua function returns false, this plugin will not be included in the spec";
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
beforeAll = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
description = "Lua code to run before any plugins are loaded. This will be wrapped in a function.";
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
before = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
description = "Lua code to run before plugin is loaded. This will be wrapped in a function.";
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
after = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
description = "Lua code to run after plugin is loaded. This will be wrapped in a function.";
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
event = mkOption {
|
||||||
|
description = "Lazy-load on event";
|
||||||
|
default = null;
|
||||||
|
type = let
|
||||||
|
event = submodule {
|
||||||
|
options = {
|
||||||
|
event = mkOption {
|
||||||
|
type = nullOr (either str (listOf str));
|
||||||
|
description = "Exact event name";
|
||||||
|
example = "BufEnter";
|
||||||
|
};
|
||||||
|
pattern = mkOption {
|
||||||
|
type = nullOr (either str (listOf str));
|
||||||
|
description = "Event pattern";
|
||||||
|
example = "BufEnter *.lua";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
nullOr (oneOf [str (listOf str) event]);
|
||||||
|
};
|
||||||
|
|
||||||
|
cmd = mkOption {
|
||||||
|
description = "Lazy-load on command";
|
||||||
|
default = null;
|
||||||
|
type = nullOr (either str (listOf str));
|
||||||
|
};
|
||||||
|
|
||||||
|
ft = mkOption {
|
||||||
|
description = "Lazy-load on filetype";
|
||||||
|
default = null;
|
||||||
|
type = nullOr (either str (listOf str));
|
||||||
|
};
|
||||||
|
|
||||||
|
keys = mkOption {
|
||||||
|
description = "Lazy-load on key mapping";
|
||||||
|
default = null;
|
||||||
|
type = nullOr (oneOf [str (listOf lznKeysSpec) (listOf str)]);
|
||||||
|
example = ''
|
||||||
|
keys = [
|
||||||
|
{lhs = "<leader>s"; rhs = ":NvimTreeToggle<cr>"; desc = "Toggle NvimTree"}
|
||||||
|
]
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
colorscheme = mkOption {
|
||||||
|
description = "Lazy-load on colorscheme.";
|
||||||
|
type = nullOr (either str (listOf str));
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
priority = mkOption {
|
||||||
|
type = nullOr int;
|
||||||
|
description = "Only useful for stat plugins (not lazy-loaded) to force loading certain plugins first.";
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
load = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
Lua code to override the `vim.g.lz_n.load()` function for a single plugin.
|
||||||
|
|
||||||
|
This will be wrapped in a function
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
inherit extraPluginType fromInputs pluginType;
|
inherit extraPluginType fromInputs pluginType luaInline lznPluginType lznPluginTableType;
|
||||||
|
|
||||||
pluginsOpt = {
|
pluginsOpt = {
|
||||||
description,
|
description,
|
||||||
|
@ -64,11 +243,6 @@ in {
|
||||||
type = pluginsType;
|
type = pluginsType;
|
||||||
};
|
};
|
||||||
|
|
||||||
luaInline = lib.mkOptionType {
|
|
||||||
name = "luaInline";
|
|
||||||
check = x: lib.nvim.lua.isLuaInline x;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
opts is a attrset of options, example:
|
opts is a attrset of options, example:
|
||||||
```
|
```
|
||||||
|
|
|
@ -69,10 +69,7 @@ inputs: {
|
||||||
|
|
||||||
# built (or "normalized") plugins that are modified
|
# built (or "normalized") plugins that are modified
|
||||||
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
|
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
|
||||||
builtOptPlugins = map (package: {
|
builtOptPlugins = map (package: package // {optional = true;}) (buildConfigPlugins vimOptions.optPlugins);
|
||||||
plugin = package;
|
|
||||||
optional = true;
|
|
||||||
}) (buildConfigPlugins vimOptions.optPlugins);
|
|
||||||
|
|
||||||
# additional Lua and Python3 packages, mapped to their respective functions
|
# additional Lua and Python3 packages, mapped to their respective functions
|
||||||
# to conform to the format mnw expects. end user should
|
# to conform to the format mnw expects. end user should
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
wrapper = map (p: ./wrapper + "/${p}") [
|
wrapper = map (p: ./wrapper + "/${p}") [
|
||||||
"build"
|
"build"
|
||||||
"rc"
|
"rc"
|
||||||
|
"lazy"
|
||||||
"warnings"
|
"warnings"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -4,55 +4,74 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (builtins) mapAttrs;
|
inherit (lib.trivial) pipe;
|
||||||
|
inherit (lib.attrsets) mapAttrsToList;
|
||||||
|
inherit (lib.lists) flatten;
|
||||||
|
|
||||||
processLegacyMap = modes: legacyMap: [(legacyMap // {mode = modes;})];
|
legacyMapModes = {
|
||||||
|
normal = ["n"];
|
||||||
|
insert = ["i"];
|
||||||
|
select = ["s"];
|
||||||
|
visual = ["v"];
|
||||||
|
terminal = ["t"];
|
||||||
|
normalVisualOp = ["n" "v" "o"];
|
||||||
|
visualOnly = ["n" "x"];
|
||||||
|
operator = ["o"];
|
||||||
|
insertCommand = ["i" "c"];
|
||||||
|
lang = ["l"];
|
||||||
|
command = ["c"];
|
||||||
|
};
|
||||||
|
|
||||||
cfg = config.vim;
|
cfg = config.vim;
|
||||||
in {
|
in {
|
||||||
config = {
|
config = {
|
||||||
vim.keymaps = mkMerge [
|
vim.keymaps = mkMerge [
|
||||||
(mkIf cfg.disableArrows {
|
(
|
||||||
"<up>" = [
|
mkIf cfg.disableArrows [
|
||||||
{
|
{
|
||||||
|
key = "<up>";
|
||||||
mode = ["n" "i"];
|
mode = ["n" "i"];
|
||||||
action = "<nop>";
|
action = "<nop>";
|
||||||
noremap = false;
|
noremap = false;
|
||||||
}
|
}
|
||||||
];
|
|
||||||
"<down>" = [
|
|
||||||
{
|
{
|
||||||
|
key = "<down>";
|
||||||
mode = ["n" "i"];
|
mode = ["n" "i"];
|
||||||
action = "<nop>";
|
action = "<nop>";
|
||||||
noremap = false;
|
noremap = false;
|
||||||
}
|
}
|
||||||
];
|
|
||||||
"<left>" = [
|
|
||||||
{
|
{
|
||||||
|
key = "<left>";
|
||||||
mode = ["n" "i"];
|
mode = ["n" "i"];
|
||||||
action = "<nop>";
|
action = "<nop>";
|
||||||
noremap = false;
|
noremap = false;
|
||||||
}
|
}
|
||||||
];
|
|
||||||
"<right>" = [
|
|
||||||
{
|
{
|
||||||
|
key = "<right>";
|
||||||
mode = ["n" "i"];
|
mode = ["n" "i"];
|
||||||
action = "<nop>";
|
action = "<nop>";
|
||||||
noremap = false;
|
noremap = false;
|
||||||
}
|
}
|
||||||
];
|
]
|
||||||
})
|
)
|
||||||
(mapAttrs (_key: processLegacyMap ["n"]) cfg.maps.normal)
|
(
|
||||||
(mapAttrs (_key: processLegacyMap ["i"]) cfg.maps.insert)
|
pipe cfg.maps
|
||||||
(mapAttrs (_key: processLegacyMap ["s"]) cfg.maps.select)
|
[
|
||||||
(mapAttrs (_key: processLegacyMap ["v"]) cfg.maps.visual)
|
(mapAttrsToList (
|
||||||
(mapAttrs (_key: processLegacyMap ["t"]) cfg.maps.terminal)
|
oldMode: keybinds:
|
||||||
(mapAttrs (_key: processLegacyMap ["n" "v" "o"]) cfg.maps.normalVisualOp)
|
mapAttrsToList (
|
||||||
(mapAttrs (_key: processLegacyMap ["n" "x"]) cfg.maps.visualOnly)
|
key: bind:
|
||||||
(mapAttrs (_key: processLegacyMap ["o"]) cfg.maps.operator)
|
bind
|
||||||
(mapAttrs (_key: processLegacyMap ["i" "c"]) cfg.maps.insertCommand)
|
// {
|
||||||
(mapAttrs (_key: processLegacyMap ["l"]) cfg.maps.lang)
|
inherit key;
|
||||||
(mapAttrs (_key: processLegacyMap ["c"]) cfg.maps.command)
|
mode = legacyMapModes.${oldMode};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
keybinds
|
||||||
|
))
|
||||||
|
flatten
|
||||||
|
]
|
||||||
|
)
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,12 @@
|
||||||
options =
|
options =
|
||||||
mapConfigOptions
|
mapConfigOptions
|
||||||
// {
|
// {
|
||||||
|
key = mkOption {
|
||||||
|
type = str;
|
||||||
|
description = ''
|
||||||
|
Key that triggers this keybind.
|
||||||
|
'';
|
||||||
|
};
|
||||||
mode = mkOption {
|
mode = mkOption {
|
||||||
type = either str (listOf str);
|
type = either str (listOf str);
|
||||||
description = ''
|
description = ''
|
||||||
|
@ -44,31 +50,36 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
# legacy stuff
|
# legacy stuff
|
||||||
mapOption = submodule {
|
legacyMapOption = submodule {
|
||||||
options = mapConfigOptions;
|
options = mapConfigOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
mapOptions = mode:
|
mapOptions = mode:
|
||||||
mkOption {
|
mkOption {
|
||||||
description = "Mappings for ${mode} mode";
|
description = "Mappings for ${mode} mode";
|
||||||
type = attrsOf mapOption;
|
type = attrsOf legacyMapOption;
|
||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
options.vim = {
|
options.vim = {
|
||||||
keymaps = mkOption {
|
keymaps = mkOption {
|
||||||
type = submodule {
|
type = listOf mapType;
|
||||||
freeformType = attrsOf (listOf mapType);
|
|
||||||
};
|
|
||||||
description = "Custom keybindings.";
|
description = "Custom keybindings.";
|
||||||
example = ''
|
example = ''
|
||||||
maps = {
|
vim.keymaps = [
|
||||||
"<leader>m" = {
|
{
|
||||||
|
key = "<leader>m";
|
||||||
mode = "n";
|
mode = "n";
|
||||||
silent = true;
|
silent = true;
|
||||||
action = "<cmd>make<CR>";
|
action = ":make<CR>";
|
||||||
}; # Same as nnoremap <leader>m <silent> <cmd>make<CR>
|
}
|
||||||
};
|
{
|
||||||
|
key = "<leader>l";
|
||||||
|
mode = ["n" "x"];
|
||||||
|
silent = true;
|
||||||
|
action = "<cmd>cnext<CR>";
|
||||||
|
}
|
||||||
|
];
|
||||||
'';
|
'';
|
||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
|
inherit (builtins) filter;
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.strings) optionalString;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.nvim.binds) mkBinding;
|
inherit (lib.nvim.binds) mkLznBinding;
|
||||||
inherit (lib.nvim.dag) entryAnywhere;
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
|
||||||
inherit (lib.nvim.binds) pushDownDefault;
|
inherit (lib.nvim.binds) pushDownDefault;
|
||||||
|
|
||||||
cfg = config.vim.filetree.nvimTree;
|
cfg = config.vim.filetree.nvimTree;
|
||||||
|
@ -16,19 +16,28 @@
|
||||||
inherit (self.options.vim.filetree.nvimTree) mappings;
|
inherit (self.options.vim.filetree.nvimTree) mappings;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = ["nvim-tree-lua"];
|
|
||||||
|
|
||||||
vim.maps.normal = mkMerge [
|
|
||||||
(mkBinding cfg.mappings.toggle ":NvimTreeToggle<cr>" mappings.toggle.description)
|
|
||||||
(mkBinding cfg.mappings.refresh ":NvimTreeRefresh<cr>" mappings.refresh.description)
|
|
||||||
(mkBinding cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
|
|
||||||
(mkBinding cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
|
|
||||||
];
|
|
||||||
|
|
||||||
vim.binds.whichKey.register = pushDownDefault {
|
vim.binds.whichKey.register = pushDownDefault {
|
||||||
"<leader>t" = "+NvimTree";
|
"<leader>t" = "+NvimTree";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vim.lazy = {
|
||||||
|
plugins = {
|
||||||
|
nvim-tree-lua = {
|
||||||
|
package = "nvim-tree-lua";
|
||||||
|
setupModule = "nvim-tree";
|
||||||
|
inherit (cfg) setupOpts;
|
||||||
|
cmd = ["NvimTreeClipboard" "NvimTreeClose" "NvimTreeCollapse" "NvimTreeCollapseKeepBuffers" "NvimTreeFindFile" "NvimTreeFindFileToggle" "NvimTreeFocus" "NvimTreeHiTest" "NvimTreeOpen" "NvimTreeRefresh" "NvimTreeResize" "NvimTreeToggle"];
|
||||||
|
|
||||||
|
keys = filter ({lhs, ...}: lhs != null) [
|
||||||
|
(mkLznBinding ["n"] cfg.mappings.toggle ":NvimTreeToggle<cr>" mappings.toggle.description)
|
||||||
|
(mkLznBinding ["n"] cfg.mappings.refresh ":NvimTreeRefresh<cr>" mappings.refresh.description)
|
||||||
|
(mkLznBinding ["n"] cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
|
||||||
|
(mkLznBinding ["n"] cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
vim.pluginRC.nvimtreelua = entryAnywhere ''
|
vim.pluginRC.nvimtreelua = entryAnywhere ''
|
||||||
${
|
${
|
||||||
optionalString cfg.setupOpts.disable_netrw ''
|
optionalString cfg.setupOpts.disable_netrw ''
|
||||||
|
@ -38,10 +47,9 @@ in {
|
||||||
''
|
''
|
||||||
}
|
}
|
||||||
|
|
||||||
require'nvim-tree'.setup(${toLuaObject cfg.setupOpts})
|
|
||||||
|
|
||||||
${
|
${
|
||||||
optionalString cfg.openOnSetup ''
|
optionalString cfg.openOnSetup ''
|
||||||
|
require('lz.n').trigger_load("nvim-tree-lua")
|
||||||
-- autostart behaviour
|
-- autostart behaviour
|
||||||
-- Open on startup has been deprecated
|
-- Open on startup has been deprecated
|
||||||
-- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup
|
-- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup
|
||||||
|
|
74
modules/wrapper/lazy/config.nix
Normal file
74
modules/wrapper/lazy/config.nix
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (builtins) toJSON typeOf head length;
|
||||||
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit (lib.attrsets) mapAttrsToList;
|
||||||
|
inherit (lib.generators) mkLuaInline;
|
||||||
|
inherit (lib.strings) optionalString;
|
||||||
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
|
inherit (lib.nvim.dag) entryBefore;
|
||||||
|
cfg = config.vim.lazy;
|
||||||
|
|
||||||
|
toLuzLznKeySpec = {
|
||||||
|
desc,
|
||||||
|
noremap,
|
||||||
|
expr,
|
||||||
|
nowait,
|
||||||
|
ft,
|
||||||
|
lhs,
|
||||||
|
rhs,
|
||||||
|
mode,
|
||||||
|
}: {
|
||||||
|
"@1" = lhs;
|
||||||
|
"@2" = rhs;
|
||||||
|
inherit desc noremap expr nowait ft mode;
|
||||||
|
};
|
||||||
|
|
||||||
|
toLuaLznSpec = name: spec:
|
||||||
|
(removeAttrs spec ["package" "setupModule" "setupOpts" "keys"])
|
||||||
|
// {
|
||||||
|
"@1" = name;
|
||||||
|
before =
|
||||||
|
if spec.before != null
|
||||||
|
then
|
||||||
|
mkLuaInline ''
|
||||||
|
function()
|
||||||
|
${spec.before}
|
||||||
|
end
|
||||||
|
''
|
||||||
|
else null;
|
||||||
|
|
||||||
|
after =
|
||||||
|
if spec.setupModule == null && spec.after == null
|
||||||
|
then null
|
||||||
|
else
|
||||||
|
mkLuaInline ''
|
||||||
|
function()
|
||||||
|
${
|
||||||
|
optionalString (spec.setupModule != null)
|
||||||
|
"require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})"
|
||||||
|
}
|
||||||
|
${optionalString (spec.after != null) spec.after}
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
|
||||||
|
keys =
|
||||||
|
if typeOf spec.keys == "list" && length spec.keys > 0 && typeOf (head spec.keys) == "set"
|
||||||
|
then map toLuzLznKeySpec spec.keys
|
||||||
|
else spec.keys;
|
||||||
|
};
|
||||||
|
lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins;
|
||||||
|
in {
|
||||||
|
config.vim = mkIf cfg.enable {
|
||||||
|
startPlugins = ["lz-n" "lzn-auto-require"];
|
||||||
|
|
||||||
|
optPlugins = mapAttrsToList (_: plugin: plugin.package) cfg.plugins;
|
||||||
|
|
||||||
|
luaConfigRC.lzn-load = entryBefore ["pluginConfigs"] ''
|
||||||
|
require('lz.n').load(${toLuaObject lznSpecs})
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
6
modules/wrapper/lazy/default.nix
Normal file
6
modules/wrapper/lazy/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
_: {
|
||||||
|
imports = [
|
||||||
|
./lazy.nix
|
||||||
|
./config.nix
|
||||||
|
];
|
||||||
|
}
|
29
modules/wrapper/lazy/lazy.nix
Normal file
29
modules/wrapper/lazy/lazy.nix
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
{lib, ...}: let
|
||||||
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
|
inherit (lib.types) enum;
|
||||||
|
inherit (lib.nvim.types) lznPluginTableType;
|
||||||
|
in {
|
||||||
|
options.vim.lazy = {
|
||||||
|
enable = mkEnableOption "plugin lazy-loading" // {default = true;};
|
||||||
|
loader = mkOption {
|
||||||
|
description = "Lazy loader to use";
|
||||||
|
type = enum ["lz.n"];
|
||||||
|
default = "lz.n";
|
||||||
|
};
|
||||||
|
|
||||||
|
plugins = mkOption {
|
||||||
|
default = {};
|
||||||
|
type = lznPluginTableType;
|
||||||
|
description = "list of plugins to lazy load";
|
||||||
|
example = ''
|
||||||
|
{
|
||||||
|
toggleterm-nvim = {
|
||||||
|
package = "toggleterm-nvim";
|
||||||
|
after = lib.generators.mkLuaInline "function() require('toggleterm').setup{} end";
|
||||||
|
cmd = ["ToggleTerm"];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -3,10 +3,10 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) map mapAttrs filter removeAttrs attrNames;
|
inherit (builtins) map mapAttrs filter;
|
||||||
inherit (lib.attrsets) mapAttrsToList filterAttrs attrsToList;
|
inherit (lib.attrsets) mapAttrsToList filterAttrs;
|
||||||
inherit (lib.strings) concatLines concatMapStringsSep optionalString;
|
inherit (lib.strings) concatLines concatMapStringsSep optionalString;
|
||||||
inherit (lib.trivial) showWarnings pipe;
|
inherit (lib.trivial) showWarnings;
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (lib.nvim.dag) entryAfter mkLuarcSection resolveDag entryAnywhere;
|
inherit (lib.nvim.dag) entryAfter mkLuarcSection resolveDag entryAnywhere;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
|
@ -40,17 +40,9 @@ in {
|
||||||
inherit (keymap) desc silent nowait script expr unique noremap;
|
inherit (keymap) desc silent nowait script expr unique noremap;
|
||||||
};
|
};
|
||||||
|
|
||||||
toLuaKeymap = key: bind: "vim.keymap.set(${toLuaObject bind.mode}, ${toLuaObject key}, ${toLuaObject (getAction bind)}, ${toLuaObject (getOpts bind)})";
|
toLuaKeymap = bind: "vim.keymap.set(${toLuaObject bind.mode}, ${toLuaObject bind.key}, ${toLuaObject (getAction bind)}, ${toLuaObject (getOpts bind)})";
|
||||||
|
|
||||||
maps =
|
maps = concatLines (map toLuaKeymap cfg.keymaps);
|
||||||
pipe
|
|
||||||
# attrsOf (listOf mapOption)
|
|
||||||
cfg.keymaps
|
|
||||||
[
|
|
||||||
(mapAttrsToList (key: binds:
|
|
||||||
concatLines (map (toLuaKeymap key) binds)))
|
|
||||||
concatLines
|
|
||||||
];
|
|
||||||
|
|
||||||
keymaps = maps;
|
keymaps = maps;
|
||||||
in {
|
in {
|
||||||
|
@ -61,6 +53,8 @@ in {
|
||||||
pluginConfigs = entryAfter ["theme"] pluginConfigs;
|
pluginConfigs = entryAfter ["theme"] pluginConfigs;
|
||||||
extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs;
|
extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs;
|
||||||
mappings = entryAfter ["extraPluginConfigs"] keymaps;
|
mappings = entryAfter ["extraPluginConfigs"] keymaps;
|
||||||
|
# FIXME: put this somewhere less stupid
|
||||||
|
footer = entryAfter ["mappings"] (optionalString config.vim.lazy.enable "require('lzn-auto-require.loader').register_loader()");
|
||||||
};
|
};
|
||||||
|
|
||||||
builtLuaConfigRC = let
|
builtLuaConfigRC = let
|
||||||
|
|
Loading…
Reference in a new issue