mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 02:11:33 +00:00
flake: autodiscover plugin inputs
This commit is contained in:
parent
cf09a3bb8b
commit
859b03dfde
8 changed files with 1439 additions and 1524 deletions
|
@ -1,5 +1,9 @@
|
|||
{lib}: {
|
||||
types = import ./types {inherit lib;};
|
||||
{
|
||||
inputs,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
types = import ./types {inherit inputs lib;};
|
||||
|
||||
config = import ./config.nix {inherit lib;};
|
||||
binds = import ./binds.nix {inherit lib;};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Cconvenience function that returns the given Nixpkgs standard library
|
||||
# extended with our functions using `lib.extend`.
|
||||
nixpkgsLib: let
|
||||
nixpkgsLib: inputs: let
|
||||
mkNvimLib = import ./.;
|
||||
in
|
||||
# WARNING: New functions should not be added here, but to files
|
||||
|
@ -8,7 +8,10 @@ in
|
|||
# function does not fit to any of the existing categories, create
|
||||
# a new file and import it in `./default.nix.`
|
||||
nixpkgsLib.extend (self: super: {
|
||||
nvim = mkNvimLib {lib = self;};
|
||||
nvim = mkNvimLib {
|
||||
inherit inputs;
|
||||
lib = self;
|
||||
};
|
||||
|
||||
# For forward compatibility.
|
||||
literalExpression = super.literalExpression or super.literalExample;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# From home-manager: https://github.com/nix-community/home-manager/blob/master/modules/lib/types-dag.nix
|
||||
# Used for ordering config text.
|
||||
# Used for ordering configuration text.
|
||||
{lib}: let
|
||||
inherit
|
||||
(lib)
|
||||
|
@ -59,8 +59,8 @@ in rec {
|
|||
name = "dagOf";
|
||||
description = "DAG of ${elemType.description}";
|
||||
inherit (attrEquivalent) check merge emptyValue;
|
||||
inherit (elemType) getSubModules;
|
||||
getSubOptions = prefix: elemType.getSubOptions (prefix ++ ["<name>"]);
|
||||
getSubModules = elemType.getSubModules;
|
||||
substSubModules = m: dagOf (elemType.substSubModules m);
|
||||
functor = (defaultFunctor name) // {wrapped = elemType;};
|
||||
nestedTypes.elemType = elemType;
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
{lib}: let
|
||||
{
|
||||
inputs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
typesDag = import ./dag.nix {inherit lib;};
|
||||
typesPlugin = import ./plugins.nix {inherit lib;};
|
||||
typesPlugin = import ./plugins.nix {inherit inputs lib;};
|
||||
typesLanguage = import ./languages.nix {inherit lib;};
|
||||
in {
|
||||
inherit (typesDag) dagOf;
|
||||
|
|
|
@ -1,137 +1,51 @@
|
|||
{lib}:
|
||||
with lib; let
|
||||
# Plugin must be same as input name from flake.nix
|
||||
availablePlugins = [
|
||||
# TODO: sort by category
|
||||
"nvim-treesitter-context"
|
||||
"gitsigns-nvim"
|
||||
"plenary-nvim"
|
||||
"nvim-lspconfig"
|
||||
"nvim-treesitter"
|
||||
"lspsaga"
|
||||
"lspkind"
|
||||
"nvim-lightbulb"
|
||||
"lsp-signature"
|
||||
"nvim-tree-lua"
|
||||
"nvim-bufferline-lua"
|
||||
"lualine"
|
||||
"nvim-autopairs"
|
||||
"nvim-ts-autotag"
|
||||
"nvim-web-devicons"
|
||||
"tokyonight"
|
||||
"bufdelete-nvim"
|
||||
"nvim-cmp"
|
||||
"cmp-nvim-lsp"
|
||||
"cmp-buffer"
|
||||
"cmp-vsnip"
|
||||
"cmp-path"
|
||||
"cmp-treesitter"
|
||||
"crates-nvim"
|
||||
"vim-vsnip"
|
||||
"nvim-code-action-menu"
|
||||
"trouble"
|
||||
"none-ls"
|
||||
"which-key"
|
||||
"indent-blankline"
|
||||
"nvim-cursorline"
|
||||
"sqls-nvim"
|
||||
"glow-nvim"
|
||||
"telescope"
|
||||
"rust-tools"
|
||||
"onedark"
|
||||
"catppuccin"
|
||||
"dracula"
|
||||
"oxocarbon"
|
||||
"gruvbox"
|
||||
"rose-pine"
|
||||
"minimap-vim"
|
||||
"dashboard-nvim"
|
||||
"alpha-nvim"
|
||||
"scrollbar-nvim"
|
||||
"codewindow-nvim"
|
||||
"nvim-notify"
|
||||
"cinnamon-nvim"
|
||||
"cheatsheet-nvim"
|
||||
"ccc"
|
||||
"cellular-automaton"
|
||||
"neocord"
|
||||
"icon-picker-nvim"
|
||||
"dressing-nvim"
|
||||
"orgmode-nvim"
|
||||
"obsidian-nvim"
|
||||
"vim-markdown"
|
||||
"tabular"
|
||||
"toggleterm-nvim"
|
||||
"noice-nvim"
|
||||
"nui-nvim"
|
||||
"copilot-lua"
|
||||
"tabnine-nvim"
|
||||
"nvim-session-manager"
|
||||
"gesture-nvim"
|
||||
"comment-nvim"
|
||||
"kommentary"
|
||||
"mind-nvim"
|
||||
"fidget-nvim"
|
||||
"diffview-nvim"
|
||||
"todo-comments"
|
||||
"flutter-tools"
|
||||
"flutter-tools-patched"
|
||||
"hop-nvim"
|
||||
"leap-nvim"
|
||||
"modes-nvim"
|
||||
"vim-repeat"
|
||||
"smartcolumn"
|
||||
"project-nvim"
|
||||
"neodev-nvim"
|
||||
"elixir-ls"
|
||||
"elixir-tools"
|
||||
"nvim-colorizer-lua"
|
||||
"vim-illuminate"
|
||||
"nvim-surround"
|
||||
"nvim-dap"
|
||||
"nvim-dap-ui"
|
||||
"nvim-navic"
|
||||
"nvim-navbuddy"
|
||||
"copilot-cmp"
|
||||
"lsp-lines"
|
||||
"vim-dirtytalk"
|
||||
"highlight-undo"
|
||||
"nvim-docs-view"
|
||||
"image-nvim"
|
||||
"nvim-nio"
|
||||
];
|
||||
{
|
||||
inputs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair;
|
||||
inherit (lib.strings) hasPrefix removePrefix isString;
|
||||
inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr;
|
||||
|
||||
# Get the names of all flake inputs that start with the given prefix.
|
||||
fromInputs = inputs: prefix:
|
||||
mapAttrs' (n: v: nameValuePair (removePrefix prefix n) {src = v;}) (filterAttrs (n: _: hasPrefix prefix n) inputs);
|
||||
|
||||
pluginsFromInputs = attrNames (fromInputs inputs "plugin-");
|
||||
|
||||
# Get the names of all flake inputs that start with the given prefix.
|
||||
|
||||
# You can either use the name of the plugin or a package.
|
||||
pluginType = with types;
|
||||
nullOr (
|
||||
either
|
||||
package
|
||||
(enum availablePlugins)
|
||||
);
|
||||
pluginType = nullOr (
|
||||
either
|
||||
package
|
||||
(enum (pluginsFromInputs ++ ["nvim-treesitter" "flutter-tools-patched" "vim-repeat"]))
|
||||
);
|
||||
|
||||
pluginsType = types.listOf pluginType;
|
||||
pluginsType = listOf pluginType;
|
||||
|
||||
extraPluginType = with types;
|
||||
submodule {
|
||||
options = {
|
||||
package = mkOption {
|
||||
type = pluginType;
|
||||
description = "Plugin Package.";
|
||||
};
|
||||
extraPluginType = submodule {
|
||||
options = {
|
||||
package = mkOption {
|
||||
type = pluginType;
|
||||
description = "Plugin Package.";
|
||||
};
|
||||
|
||||
after = mkOption {
|
||||
type = listOf str;
|
||||
default = [];
|
||||
description = "Setup this plugin after the following ones.";
|
||||
};
|
||||
after = mkOption {
|
||||
type = listOf str;
|
||||
default = [];
|
||||
description = "Setup this plugin after the following ones.";
|
||||
};
|
||||
|
||||
setup = mkOption {
|
||||
type = lines;
|
||||
default = "";
|
||||
description = "Lua code to run during setup.";
|
||||
example = "require('aerial').setup {}";
|
||||
};
|
||||
setup = mkOption {
|
||||
type = lines;
|
||||
default = "";
|
||||
description = "Lua code to run during setup.";
|
||||
example = "require('aerial').setup {}";
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
inherit extraPluginType;
|
||||
|
||||
|
@ -156,23 +70,25 @@ in {
|
|||
lib.mergeOneOption val defs;
|
||||
};
|
||||
|
||||
# opts is a attrset of options, example:
|
||||
# ```
|
||||
# mkPluginSetupOption "telescope" {
|
||||
# file_ignore_patterns = mkOption {
|
||||
# description = "...";
|
||||
# type = types.listOf types.str;
|
||||
# default = [];
|
||||
# };
|
||||
# layout_config.horizontal = mkOption {...};
|
||||
# }
|
||||
# ```
|
||||
/*
|
||||
opts is a attrset of options, example:
|
||||
```
|
||||
mkPluginSetupOption "telescope" {
|
||||
file_ignore_patterns = mkOption {
|
||||
description = "...";
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
};
|
||||
layout_config.horizontal = mkOption {...};
|
||||
}
|
||||
```
|
||||
*/
|
||||
mkPluginSetupOption = pluginName: opts:
|
||||
mkOption {
|
||||
description = "Option table to pass into the setup function of " + pluginName;
|
||||
default = {};
|
||||
type = types.submodule {
|
||||
freeformType = with types; attrsOf anything;
|
||||
type = submodule {
|
||||
freeformType = attrsOf anything;
|
||||
options = opts;
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue