mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 21:30:51 +00:00
Compare commits
34 commits
78203a1bce
...
43e6e673af
Author | SHA1 | Date | |
---|---|---|---|
|
43e6e673af | ||
|
1b82b13dc7 | ||
|
f5850432a8 | ||
|
f672689023 | ||
|
669088244d | ||
|
769e07e7cc | ||
|
0b9f69a20f | ||
|
9dd2a11e4d | ||
|
09e83a6cec | ||
|
c027a87527 | ||
|
abd76db843 | ||
|
85c0839105 | ||
|
6fc691a7c3 | ||
|
14bc100a5e | ||
|
290de58ae9 | ||
|
1ee0a513cc | ||
|
346f536737 | ||
|
ee5a157894 | ||
|
805dd05b39 | ||
|
d3e39d10b0 | ||
|
14061c6db5 | ||
|
5c105b8182 | ||
|
b10c525ffe | ||
|
9b4332ed77 | ||
|
f632fa1a92 | ||
|
0faf4b923b | ||
|
205582135d | ||
|
1988203073 | ||
|
d1d91ff8a5 | ||
|
b552b33077 | ||
|
920e0bad5e | ||
|
f3ce59ed40 | ||
|
50efc3b557 | ||
|
2fc7dc798b |
14 changed files with 505 additions and 105 deletions
|
@ -4,7 +4,7 @@ Release notes for release 0.7
|
|||
|
||||
## Breaking Changes and Migration Guide {#sec-breaking-changes-and-migration-guide-0-7}
|
||||
|
||||
### `vim.configRC` removed
|
||||
### `vim.configRC` removed {#sec-vim-configrc-removed}
|
||||
|
||||
In v0.7 we are removing `vim.configRC` in favor of making `vim.luaConfigRC` the
|
||||
top-level DAG, and thereby making the entire configuration Lua based. This
|
||||
|
@ -26,7 +26,7 @@ making good use of its extensive Lua API. Additionally, Vimscript is slow and
|
|||
brings unnecessary performance overhead while working with different
|
||||
configuration formats.
|
||||
|
||||
### `vim.maps` rewrite
|
||||
### `vim.maps` rewrite {#sec-vim-maps-rewrite}
|
||||
|
||||
Instead of specifying map modes using submodules (eg.: `vim.maps.normal`), a new
|
||||
`mode` option has mode has been introduced. It can be either a string, or a list
|
||||
|
|
34
flake.lock
34
flake.lock
|
@ -843,6 +843,38 @@
|
|||
"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": 1722727896,
|
||||
"narHash": "sha256-h7Dx3zBkUYamQY6lcuQrwAMgBpPqskLnA6WsbefHzMU=",
|
||||
"owner": "horriblename",
|
||||
"repo": "lzn-auto-require",
|
||||
"rev": "c6b47e148a1ff9709e802f68c2c8b558a9a8de9b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "horriblename",
|
||||
"repo": "lzn-auto-require",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-mind-nvim": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
@ -1872,6 +1904,8 @@
|
|||
"plugin-lspkind": "plugin-lspkind",
|
||||
"plugin-lspsaga": "plugin-lspsaga",
|
||||
"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-minimap-vim": "plugin-minimap-vim",
|
||||
"plugin-modes-nvim": "plugin-modes-nvim",
|
||||
|
|
11
flake.nix
11
flake.nix
|
@ -102,6 +102,17 @@
|
|||
};
|
||||
|
||||
## 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
|
||||
plugin-nvim-lspconfig = {
|
||||
url = "github:neovim/nvim-lspconfig";
|
||||
|
|
138
lib/binds.nix
138
lib/binds.nix
|
@ -3,69 +3,87 @@
|
|||
inherit (lib.modules) mkIf mkDefault;
|
||||
inherit (lib.types) nullOr str;
|
||||
inherit (lib.attrsets) isAttrs mapAttrs;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
|
||||
mkLuaBinding = mode: key: action: desc:
|
||||
mkIf (key != null) {
|
||||
${key} = {
|
||||
inherit mode action desc;
|
||||
lua = true;
|
||||
silent = true;
|
||||
};
|
||||
};
|
||||
|
||||
mkExprBinding = mode: key: action: desc:
|
||||
mkIf (key != null) {
|
||||
${key} = {
|
||||
inherit mode action desc;
|
||||
lua = true;
|
||||
silent = true;
|
||||
expr = true;
|
||||
};
|
||||
};
|
||||
|
||||
mkBinding = mode: key: action: desc:
|
||||
mkIf (key != null) {
|
||||
${key} = {
|
||||
inherit mode action desc;
|
||||
silent = true;
|
||||
};
|
||||
};
|
||||
|
||||
mkMappingOption = description: default:
|
||||
mkOption {
|
||||
type = nullOr str;
|
||||
inherit default description;
|
||||
};
|
||||
|
||||
# Utility function that takes two attrsets:
|
||||
# { someKey = "some_value" } and
|
||||
# { someKey = { description = "Some Description"; }; }
|
||||
# and merges them into
|
||||
# { someKey = { value = "some_value"; description = "Some Description"; }; }
|
||||
addDescriptionsToMappings = actualMappings: mappingDefinitions:
|
||||
mapAttrs (name: value: let
|
||||
isNested = isAttrs value;
|
||||
returnedValue =
|
||||
if isNested
|
||||
then addDescriptionsToMappings actualMappings.${name} mappingDefinitions.${name}
|
||||
else {
|
||||
inherit value;
|
||||
inherit (mappingDefinitions.${name}) description;
|
||||
binds = rec {
|
||||
mkLuaBinding = key: action: desc:
|
||||
mkIf (key != null) {
|
||||
"${key}" = {
|
||||
inherit action desc;
|
||||
lua = true;
|
||||
silent = true;
|
||||
};
|
||||
in
|
||||
returnedValue)
|
||||
actualMappings;
|
||||
};
|
||||
|
||||
mkSetBinding = mode: binding: action:
|
||||
mkBinding mode binding.value action binding.description;
|
||||
mkExprBinding = key: action: desc:
|
||||
mkIf (key != null) {
|
||||
"${key}" = {
|
||||
inherit action desc;
|
||||
lua = true;
|
||||
silent = true;
|
||||
expr = true;
|
||||
};
|
||||
};
|
||||
|
||||
mkSetExprBinding = mode: binding: action:
|
||||
mkExprBinding mode binding.value action binding.description;
|
||||
mkBinding = key: action: desc:
|
||||
mkIf (key != null) {
|
||||
"${key}" = {
|
||||
inherit action desc;
|
||||
silent = true;
|
||||
};
|
||||
};
|
||||
|
||||
mkSetLuaBinding = mode: binding: action:
|
||||
mkLuaBinding mode binding.value action binding.description;
|
||||
mkMappingOption = description: default:
|
||||
mkOption {
|
||||
type = nullOr str;
|
||||
inherit default description;
|
||||
};
|
||||
|
||||
pushDownDefault = attr: mapAttrs (_: mkDefault) attr;
|
||||
in {
|
||||
inherit mkLuaBinding mkExprBinding mkBinding mkMappingOption addDescriptionsToMappings mkSetBinding mkSetExprBinding mkSetLuaBinding pushDownDefault;
|
||||
}
|
||||
# Utility function that takes two attrsets:
|
||||
# { someKey = "some_value" } and
|
||||
# { someKey = { description = "Some Description"; }; }
|
||||
# and merges them into
|
||||
# { someKey = { value = "some_value"; description = "Some Description"; }; }
|
||||
addDescriptionsToMappings = actualMappings: mappingDefinitions:
|
||||
mapAttrs (name: value: let
|
||||
isNested = isAttrs value;
|
||||
returnedValue =
|
||||
if isNested
|
||||
then addDescriptionsToMappings actualMappings."${name}" mappingDefinitions."${name}"
|
||||
else {
|
||||
inherit value;
|
||||
inherit (mappingDefinitions."${name}") description;
|
||||
};
|
||||
in
|
||||
returnedValue)
|
||||
actualMappings;
|
||||
|
||||
mkSetBinding = binding: action:
|
||||
mkBinding binding.value action binding.description;
|
||||
|
||||
mkSetExprBinding = binding: action:
|
||||
mkExprBinding binding.value action binding.description;
|
||||
|
||||
mkSetLuaBinding = binding: action:
|
||||
mkLuaBinding binding.value action binding.description;
|
||||
|
||||
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
|
||||
binds
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
typesCustom = import ./custom.nix {inherit lib;};
|
||||
in {
|
||||
inherit (typesDag) dagOf;
|
||||
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType;
|
||||
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType lznPluginType lznPluginTableType;
|
||||
inherit (typesLanguage) diagnostics mkGrammarOption;
|
||||
inherit (typesCustom) anythingConcatLists char;
|
||||
}
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
inherit (lib.options) mkOption;
|
||||
inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair;
|
||||
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;
|
||||
# Get the names of all flake inputs that start with the given prefix.
|
||||
fromInputs = {
|
||||
inputs,
|
||||
|
@ -51,8 +50,156 @@
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
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
|
||||
|
||||
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"}
|
||||
]
|
||||
'';
|
||||
};
|
||||
|
||||
# TODO: enabled, beforeAll, colorscheme, priority, load
|
||||
};
|
||||
};
|
||||
in {
|
||||
inherit extraPluginType fromInputs pluginType;
|
||||
inherit extraPluginType fromInputs pluginType luaInline lznPluginType lznPluginTableType;
|
||||
|
||||
pluginsOpt = {
|
||||
description,
|
||||
|
@ -64,11 +211,6 @@ in {
|
|||
type = pluginsType;
|
||||
};
|
||||
|
||||
luaInline = lib.mkOptionType {
|
||||
name = "luaInline";
|
||||
check = x: lib.nvim.lua.isLuaInline x;
|
||||
};
|
||||
|
||||
/*
|
||||
opts is a attrset of options, example:
|
||||
```
|
||||
|
|
|
@ -69,10 +69,7 @@ inputs: {
|
|||
|
||||
# built (or "normalized") plugins that are modified
|
||||
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
|
||||
builtOptPlugins = map (package: {
|
||||
plugin = package;
|
||||
optional = true;
|
||||
}) (buildConfigPlugins vimOptions.optPlugins);
|
||||
builtOptPlugins = map (package: package // {optional = true;}) (buildConfigPlugins vimOptions.optPlugins);
|
||||
|
||||
# additional Lua and Python3 packages, mapped to their respective functions
|
||||
# to conform to the format mnw expects. end user should
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
wrapper = map (p: ./wrapper + "/${p}") [
|
||||
"build"
|
||||
"rc"
|
||||
"lazy"
|
||||
"warnings"
|
||||
];
|
||||
|
||||
|
|
|
@ -1,17 +1,9 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.types) either str listOf attrsOf nullOr submodule;
|
||||
inherit (lib.types) either str listOf attrsOf nullOr submodule bool;
|
||||
inherit (lib.nvim.config) mkBool;
|
||||
|
||||
mapType = submodule {
|
||||
mode = mkOption {
|
||||
type = either str (listOf str);
|
||||
description = ''
|
||||
The short-name of the mode to set the keymapping for. Passing an empty string is the equivalent of `:map`.
|
||||
|
||||
See `:help map-modes` for a list of modes.
|
||||
'';
|
||||
};
|
||||
mapConfigOptions = {
|
||||
desc = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
|
@ -34,10 +26,69 @@
|
|||
unique = mkBool false "Whether to fail if the map is already defined. Equivalent to adding <unique> to a map.";
|
||||
noremap = mkBool true "Whether to use the 'noremap' variant of the command, ignoring any custom mappings on the defined action. It is highly advised to keep this on, which is the default.";
|
||||
};
|
||||
|
||||
mapType = submodule {
|
||||
options =
|
||||
mapConfigOptions
|
||||
// {
|
||||
mode = mkOption {
|
||||
type = either str (listOf str);
|
||||
description = ''
|
||||
The short-name of the mode to set the keymapping for. Passing an empty string is the equivalent of `:map`.
|
||||
|
||||
See `:help map-modes` for a list of modes.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# legacy stuff
|
||||
mapOption = submodule {
|
||||
options =
|
||||
mapConfigOptions
|
||||
// {
|
||||
action = mkOption {
|
||||
type = str;
|
||||
description = "The action to execute.";
|
||||
};
|
||||
|
||||
lua = mkOption {
|
||||
type = bool;
|
||||
description = ''
|
||||
If true, `action` is considered to be lua code.
|
||||
Thus, it will not be wrapped in `""`.
|
||||
'';
|
||||
default = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
mapOptions = mode:
|
||||
mkOption {
|
||||
description = "Mappings for ${mode} mode";
|
||||
type = attrsOf mapOption;
|
||||
default = {};
|
||||
};
|
||||
in {
|
||||
options.vim = {
|
||||
maps = mkOption {
|
||||
type = attrsOf mapType;
|
||||
type = submodule {
|
||||
freeformType = attrsOf mapType;
|
||||
options = {
|
||||
normal = mapOptions "normal";
|
||||
insert = mapOptions "insert";
|
||||
select = mapOptions "select";
|
||||
visual = mapOptions "visual and select";
|
||||
terminal = mapOptions "terminal";
|
||||
normalVisualOp = mapOptions "normal, visual, select and operator-pending (same as plain 'map')";
|
||||
|
||||
visualOnly = mapOptions "visual only";
|
||||
operator = mapOptions "operator-pending";
|
||||
insertCommand = mapOptions "insert and command-line";
|
||||
lang = mapOptions "insert, command-line and lang-arg";
|
||||
command = mapOptions "command-line";
|
||||
};
|
||||
};
|
||||
default = {};
|
||||
description = "Custom keybindings.";
|
||||
example = ''
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) filter;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.binds) mkBinding;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.binds) mkLznBinding;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.binds) pushDownDefault;
|
||||
|
||||
cfg = config.vim.filetree.nvimTree;
|
||||
|
@ -16,19 +16,28 @@
|
|||
inherit (self.options.vim.filetree.nvimTree) mappings;
|
||||
in {
|
||||
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 {
|
||||
"<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 ''
|
||||
${
|
||||
optionalString cfg.setupOpts.disable_netrw ''
|
||||
|
@ -38,10 +47,9 @@ in {
|
|||
''
|
||||
}
|
||||
|
||||
require'nvim-tree'.setup(${toLuaObject cfg.setupOpts})
|
||||
|
||||
${
|
||||
optionalString cfg.openOnSetup ''
|
||||
require('lz.n').trigger_load("nvim-tree-lua")
|
||||
-- autostart behaviour
|
||||
-- Open on startup has been deprecated
|
||||
-- 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,9 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) map mapAttrs filter;
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.attrsets) mapAttrsToList filterAttrs getAttrs attrValues attrNames;
|
||||
inherit (lib.strings) concatLines concatMapStringsSep;
|
||||
inherit (builtins) map mapAttrs filter removeAttrs attrNames;
|
||||
inherit (lib.attrsets) mapAttrsToList filterAttrs attrsToList;
|
||||
inherit (lib.strings) concatLines concatMapStringsSep optionalString;
|
||||
inherit (lib.trivial) showWarnings;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.nvim.dag) entryAfter mkLuarcSection resolveDag entryAnywhere;
|
||||
|
@ -46,7 +45,35 @@ in {
|
|||
value,
|
||||
}: "vim.keymap.set(${toLuaObject value.mode}, ${toLuaObject name}, ${toLuaObject (getAction value)}, ${toLuaObject (getOpts value)})";
|
||||
|
||||
keymaps = concatLines (map toLuaKeymap (attrsToList (filterNonNull config.maps)));
|
||||
namedModes = {
|
||||
"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"];
|
||||
};
|
||||
|
||||
maps =
|
||||
removeAttrs cfg.maps (attrNames namedModes)
|
||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.normal;}) cfg.maps.normal
|
||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.insert;}) cfg.maps.insert
|
||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.select;}) cfg.maps.select
|
||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.visual;}) cfg.maps.visual
|
||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.terminal;}) cfg.maps.terminal
|
||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.normalVisualOp;}) cfg.maps.normalVisualOp
|
||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.visualOnly;}) cfg.maps.visualOnly
|
||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.operator;}) cfg.maps.operator
|
||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.insertCommand;}) cfg.maps.insertCommand
|
||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.lang;}) cfg.maps.lang
|
||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.command;}) cfg.maps.command;
|
||||
|
||||
keymaps = concatLines (map toLuaKeymap (attrsToList (filterNonNull maps)));
|
||||
in {
|
||||
vim = {
|
||||
luaConfigRC = {
|
||||
|
@ -55,6 +82,8 @@ in {
|
|||
pluginConfigs = entryAfter ["theme"] pluginConfigs;
|
||||
extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs;
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue