mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-07 12:45:57 +01:00
Merge c97476bd3e
into 589b86d378
This commit is contained in:
commit
e20034c86a
8 changed files with 162 additions and 9 deletions
17
flake.lock
17
flake.lock
|
@ -843,6 +843,22 @@
|
|||
"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-mind-nvim": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
@ -1856,6 +1872,7 @@
|
|||
"plugin-lspkind": "plugin-lspkind",
|
||||
"plugin-lspsaga": "plugin-lspsaga",
|
||||
"plugin-lualine": "plugin-lualine",
|
||||
"plugin-lz-n": "plugin-lz-n",
|
||||
"plugin-mind-nvim": "plugin-mind-nvim",
|
||||
"plugin-minimap-vim": "plugin-minimap-vim",
|
||||
"plugin-modes-nvim": "plugin-modes-nvim",
|
||||
|
|
|
@ -102,6 +102,12 @@
|
|||
};
|
||||
|
||||
## Plugins
|
||||
# Lazy loading
|
||||
plugin-lz-n = {
|
||||
url = "github:nvim-neorocks/lz.n";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
# LSP plugins
|
||||
plugin-nvim-lspconfig = {
|
||||
url = "github:neovim/nvim-lspconfig";
|
||||
|
|
|
@ -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;
|
||||
# Get the names of all flake inputs that start with the given prefix.
|
||||
fromInputs = {
|
||||
inputs,
|
||||
|
@ -51,8 +50,82 @@
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
luaInline = lib.mkOptionType {
|
||||
name = "luaInline";
|
||||
check = x: lib.nvim.lua.isLuaInline x;
|
||||
};
|
||||
|
||||
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;
|
||||
# }
|
||||
|
||||
package = mkOption {
|
||||
type = pluginType;
|
||||
};
|
||||
|
||||
before = mkOption {
|
||||
type = nullOr luaInline;
|
||||
description = "Code to run before plugin is loaded";
|
||||
default = null;
|
||||
};
|
||||
|
||||
after = mkOption {
|
||||
type = nullOr luaInline;
|
||||
description = "Code to run after plugin is loaded";
|
||||
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 (either str (listOf str)); # TODO: support lz.n.KeysSpec
|
||||
};
|
||||
|
||||
# TODO: enabled, beforeAll, colorscheme, priority, load
|
||||
};
|
||||
};
|
||||
in {
|
||||
inherit extraPluginType fromInputs pluginType;
|
||||
inherit extraPluginType fromInputs pluginType luaInline lznPluginType lznPluginTableType;
|
||||
|
||||
pluginsOpt = {
|
||||
description,
|
||||
|
@ -64,11 +137,6 @@ in {
|
|||
type = pluginsType;
|
||||
};
|
||||
|
||||
luaInline = lib.mkOptionType {
|
||||
name = "luaInline";
|
||||
check = x: lib.nvim.lua.isLuaInline x;
|
||||
};
|
||||
|
||||
/*
|
||||
opts is a attrset of options, example:
|
||||
```
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
wrapper = map (p: ./wrapper + "/${p}") [
|
||||
"build"
|
||||
"rc"
|
||||
"lazy"
|
||||
"warnings"
|
||||
];
|
||||
|
||||
|
|
26
modules/wrapper/lazy/config.nix
Normal file
26
modules/wrapper/lazy/config.nix
Normal file
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.attrsets) mapAttrsToList;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
cfg = config.vim.lazy;
|
||||
|
||||
toLuaLznSpec = name: plugin:
|
||||
(removeAttrs plugin ["package"])
|
||||
// {"@1" = name;};
|
||||
lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins;
|
||||
in {
|
||||
config.vim = mkIf cfg.enable {
|
||||
startPlugins = ["lz-n"];
|
||||
|
||||
optPlugins = mapAttrsToList (_: plugin: plugin.package) cfg.plugins;
|
||||
|
||||
luaConfigRC.lzn-load = entryAnywhere ''
|
||||
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"];
|
||||
};
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue