flake: autodiscover plugin inputs

This commit is contained in:
raf 2024-04-08 03:28:49 +03:00
parent cf09a3bb8b
commit 859b03dfde
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
8 changed files with 1439 additions and 1524 deletions

2329
flake.lock

File diff suppressed because it is too large Load diff

409
flake.nix
View file

@ -22,7 +22,7 @@
flake = {
lib = {
inherit (import ./lib/stdlib-extended.nix nixpkgs.lib) nvim;
inherit (import ./lib/stdlib-extended.nix nixpkgs.lib inputs) nvim;
inherit (import ./configuration.nix inputs) neovimConfiguration;
};
@ -68,129 +68,6 @@
# TODO: get zig from the zig overlay instead of nixpkgs
zig.url = "github:mitchellh/zig-overlay";
# LSP plugins
nvim-lspconfig = {
# url = "github:neovim/nvim-lspconfig?ref=v0.1.3";
# Use master for nil_ls
url = "github:neovim/nvim-lspconfig";
flake = false;
};
lspsaga = {
url = "github:tami5/lspsaga.nvim";
flake = false;
};
lspkind = {
url = "github:onsails/lspkind-nvim";
flake = false;
};
trouble = {
url = "github:folke/trouble.nvim";
flake = false;
};
nvim-treesitter-context = {
url = "github:nvim-treesitter/nvim-treesitter-context";
flake = false;
};
nvim-lightbulb = {
url = "github:kosayoda/nvim-lightbulb";
flake = false;
};
nvim-code-action-menu = {
url = "github:weilbith/nvim-code-action-menu";
flake = false;
};
lsp-signature = {
url = "github:ray-x/lsp_signature.nvim";
flake = false;
};
lsp-lines = {
url = "sourcehut:~whynothugo/lsp_lines.nvim";
flake = false;
};
none-ls = {
# https://github.com/nvimtools/none-ls.nvim/issues/58
url = "github:nvimtools/none-ls.nvim/bb680d752cec37949faca7a1f509e2fe67ab418a";
flake = false;
};
nvim-docs-view = {
url = "github:amrbashir/nvim-docs-view";
flake = false;
};
# language support
sqls-nvim = {
url = "github:nanotee/sqls.nvim";
flake = false;
};
rust-tools = {
url = "github:simrat39/rust-tools.nvim";
flake = false;
};
flutter-tools = {
url = "github:akinsho/flutter-tools.nvim";
flake = false;
};
neodev-nvim = {
url = "github:folke/neodev.nvim";
flake = false;
};
elixir-ls = {
url = "github:elixir-lsp/elixir-ls";
flake = false;
};
elixir-tools = {
url = "github:elixir-tools/elixir-tools.nvim";
flake = false;
};
glow-nvim = {
url = "github:ellisonleao/glow.nvim";
flake = false;
};
image-nvim = {
url = "github:3rd/image.nvim";
flake = false;
};
# Tidal cycles
tidalcycles = {
url = "github:mitchmindtree/tidalcycles.nix";
inputs.vim-tidal-src.url = "github:tidalcycles/vim-tidal";
};
# Copying/Registers
registers = {
url = "github:tversteeg/registers.nvim";
flake = false;
};
nvim-neoclip = {
url = "github:AckslD/nvim-neoclip.lua";
flake = false;
};
# Telescope
telescope = {
url = "github:nvim-telescope/telescope.nvim";
flake = false;
};
# Langauge server (use master instead of nixpkgs)
rnix-lsp.url = "github:nix-community/rnix-lsp";
nil = {
@ -199,393 +76,521 @@
inputs.flake-utils.follows = "flake-utils";
};
### Plugins
# Tidal cycles
tidalcycles = {
url = "github:mitchmindtree/tidalcycles.nix";
inputs.vim-tidal-src.url = "github:tidalcycles/vim-tidal";
};
# LSP plugins
plugin-nvim-lspconfig = {
# url = "github:neovim/nvim-lspconfig?ref=v0.1.3";
# Use master for nil_ls
url = "github:neovim/nvim-lspconfig";
flake = false;
};
plugin-lspsaga = {
url = "github:tami5/lspsaga.nvim";
flake = false;
};
plugin-lspkind = {
url = "github:onsails/lspkind-nvim";
flake = false;
};
plugin-trouble = {
url = "github:folke/trouble.nvim";
flake = false;
};
plugin-nvim-treesitter-context = {
url = "github:nvim-treesitter/nvim-treesitter-context";
flake = false;
};
plugin-nvim-lightbulb = {
url = "github:kosayoda/nvim-lightbulb";
flake = false;
};
plugin-nvim-code-action-menu = {
url = "github:weilbith/nvim-code-action-menu";
flake = false;
};
plugin-lsp-signature = {
url = "github:ray-x/lsp_signature.nvim";
flake = false;
};
plugin-lsp-lines = {
url = "sourcehut:~whynothugo/lsp_lines.nvim";
flake = false;
};
plugin-none-ls = {
# https://github.com/nvimtools/none-ls.nvim/issues/58
url = "github:nvimtools/none-ls.nvim/bb680d752cec37949faca7a1f509e2fe67ab418a";
flake = false;
};
plugin-nvim-docs-view = {
url = "github:amrbashir/nvim-docs-view";
flake = false;
};
# language support
plugin-sqls-nvim = {
url = "github:nanotee/sqls.nvim";
flake = false;
};
plugin-rust-tools = {
url = "github:simrat39/rust-tools.nvim";
flake = false;
};
plugin-flutter-tools = {
url = "github:akinsho/flutter-tools.nvim";
flake = false;
};
plugin-neodev-nvim = {
url = "github:folke/neodev.nvim";
flake = false;
};
plugin-elixir-ls = {
url = "github:elixir-lsp/elixir-ls";
flake = false;
};
plugin-elixir-tools = {
url = "github:elixir-tools/elixir-tools.nvim";
flake = false;
};
plugin-glow-nvim = {
url = "github:ellisonleao/glow.nvim";
flake = false;
};
plugin-image-nvim = {
url = "github:3rd/image.nvim";
flake = false;
};
# Copying/Registers
plugin-registers = {
url = "github:tversteeg/registers.nvim";
flake = false;
};
plugin-nvim-neoclip = {
url = "github:AckslD/nvim-neoclip.lua";
flake = false;
};
# Telescope
plugin-telescope = {
url = "github:nvim-telescope/telescope.nvim";
flake = false;
};
# Debuggers
nvim-dap = {
plugin-nvim-dap = {
url = "github:mfussenegger/nvim-dap";
flake = false;
};
nvim-dap-ui = {
plugin-nvim-dap-ui = {
url = "github:rcarriga/nvim-dap-ui";
flake = false;
};
# Filetrees
nvim-tree-lua = {
plugin-nvim-tree-lua = {
url = "github:nvim-tree/nvim-tree.lua";
flake = false;
};
# Tablines
nvim-bufferline-lua = {
plugin-nvim-bufferline-lua = {
url = "github:akinsho/nvim-bufferline.lua";
flake = false;
};
# Statuslines
lualine = {
plugin-lualine = {
url = "github:hoob3rt/lualine.nvim";
flake = false;
};
nvim-cmp = {
plugin-nvim-cmp = {
url = "github:hrsh7th/nvim-cmp";
flake = false;
};
cmp-buffer = {
plugin-cmp-buffer = {
url = "github:hrsh7th/cmp-buffer";
flake = false;
};
cmp-nvim-lsp = {
plugin-cmp-nvim-lsp = {
url = "github:hrsh7th/cmp-nvim-lsp";
flake = false;
};
cmp-vsnip = {
plugin-cmp-vsnip = {
url = "github:hrsh7th/cmp-vsnip";
flake = false;
};
cmp-path = {
plugin-cmp-path = {
url = "github:hrsh7th/cmp-path";
flake = false;
};
cmp-treesitter = {
plugin-cmp-treesitter = {
url = "github:ray-x/cmp-treesitter";
flake = false;
};
# snippets
vim-vsnip = {
plugin-vim-vsnip = {
url = "github:hrsh7th/vim-vsnip";
flake = false;
};
# Presence
neocord = {
plugin-neocord = {
url = "github:IogaMaster/neocord";
flake = false; # uses flake-utils, avoid the flake
};
# Autopairs
nvim-autopairs = {
plugin-nvim-autopairs = {
url = "github:windwp/nvim-autopairs";
flake = false;
};
nvim-ts-autotag = {
plugin-nvim-ts-autotag = {
url = "github:windwp/nvim-ts-autotag";
flake = false;
};
# Commenting
kommentary = {
url = "github:b3nj5m1n/kommentary";
flake = false;
};
comment-nvim = {
plugin-comment-nvim = {
url = "github:numToStr/Comment.nvim";
flake = false;
};
todo-comments = {
plugin-todo-comments = {
url = "github:folke/todo-comments.nvim";
flake = false;
};
# Buffer tools
bufdelete-nvim = {
plugin-bufdelete-nvim = {
url = "github:famiu/bufdelete.nvim";
flake = false;
};
# Dashboard Utilities
dashboard-nvim = {
plugin-dashboard-nvim = {
url = "github:glepnir/dashboard-nvim";
flake = false;
};
alpha-nvim = {
plugin-alpha-nvim = {
url = "github:goolord/alpha-nvim";
flake = false;
};
vim-startify = {
plugin-vim-startify = {
url = "github:mhinz/vim-startify";
flake = false;
};
# Themes
tokyonight = {
plugin-tokyonight = {
url = "github:folke/tokyonight.nvim";
flake = false;
};
onedark = {
plugin-onedark = {
url = "github:navarasu/onedark.nvim";
flake = false;
};
catppuccin = {
plugin-catppuccin = {
url = "github:catppuccin/nvim";
flake = false;
};
dracula = {
plugin-dracula = {
url = "github:Mofiqul/dracula.nvim";
flake = false;
};
oxocarbon = {
plugin-oxocarbon = {
url = "github:glyh/oxocarbon.nvim/lualine-support";
flake = false;
};
gruvbox = {
plugin-gruvbox = {
url = "github:ellisonleao/gruvbox.nvim";
flake = false;
};
rose-pine = {
plugin-rose-pine = {
url = "github:rose-pine/neovim";
flake = false;
};
# Rust crates
crates-nvim = {
plugin-crates-nvim = {
url = "github:Saecki/crates.nvim";
flake = false;
};
# Project Management
project-nvim = {
plugin-project-nvim = {
url = "github:ahmedkhalf/project.nvim";
flake = false;
};
# Visuals
nvim-cursorline = {
plugin-nvim-cursorline = {
url = "github:yamatsum/nvim-cursorline";
flake = false;
};
scrollbar-nvim = {
plugin-scrollbar-nvim = {
url = "github:petertriho/nvim-scrollbar";
flake = false;
};
cinnamon-nvim = {
plugin-cinnamon-nvim = {
url = "github:declancm/cinnamon.nvim";
flake = false;
};
cellular-automaton = {
plugin-cellular-automaton = {
url = "github:Eandrju/cellular-automaton.nvim";
flake = false;
};
indent-blankline = {
plugin-indent-blankline = {
url = "github:lukas-reineke/indent-blankline.nvim";
flake = false;
};
nvim-web-devicons = {
plugin-nvim-web-devicons = {
url = "github:nvim-tree/nvim-web-devicons";
flake = false;
};
gitsigns-nvim = {
plugin-gitsigns-nvim = {
url = "github:lewis6991/gitsigns.nvim";
flake = false;
};
fidget-nvim = {
plugin-fidget-nvim = {
url = "github:j-hui/fidget.nvim";
flake = false;
};
highlight-undo = {
plugin-highlight-undo = {
url = "github:tzachar/highlight-undo.nvim";
flake = false;
};
# Minimap
minimap-vim = {
plugin-minimap-vim = {
url = "github:wfxr/minimap.vim";
flake = false;
};
codewindow-nvim = {
plugin-codewindow-nvim = {
url = "github:gorbit99/codewindow.nvim";
flake = false;
};
# Notifications
nvim-notify = {
plugin-nvim-notify = {
url = "github:rcarriga/nvim-notify";
flake = false;
};
# Utilities
ccc = {
plugin-ccc = {
url = "github:uga-rosa/ccc.nvim";
flake = false;
};
diffview-nvim = {
plugin-diffview-nvim = {
url = "github:sindrets/diffview.nvim";
flake = false;
};
icon-picker-nvim = {
plugin-icon-picker-nvim = {
url = "github:ziontee113/icon-picker.nvim";
flake = false;
};
which-key = {
plugin-which-key = {
url = "github:folke/which-key.nvim";
flake = false;
};
cheatsheet-nvim = {
plugin-cheatsheet-nvim = {
url = "github:sudormrfbin/cheatsheet.nvim";
flake = false;
};
gesture-nvim = {
plugin-gesture-nvim = {
url = "github:notomo/gesture.nvim";
flake = false;
};
hop-nvim = {
plugin-hop-nvim = {
url = "github:phaazon/hop.nvim";
flake = false;
};
leap-nvim = {
plugin-leap-nvim = {
url = "github:ggandor/leap.nvim";
flake = false;
};
smartcolumn = {
plugin-smartcolumn = {
url = "github:m4xshen/smartcolumn.nvim";
flake = false;
};
nvim-surround = {
plugin-nvim-surround = {
url = "github:kylechui/nvim-surround";
flake = false;
};
# Note-taking
obsidian-nvim = {
plugin-obsidian-nvim = {
url = "github:epwalsh/obsidian.nvim";
flake = false;
};
orgmode-nvim = {
plugin-orgmode-nvim = {
url = "github:nvim-orgmode/orgmode";
flake = false;
};
mind-nvim = {
plugin-mind-nvim = {
url = "github:phaazon/mind.nvim";
flake = false;
};
# Spellchecking
vim-dirtytalk = {
plugin-vim-dirtytalk = {
url = "github:psliwka/vim-dirtytalk";
flake = false;
};
# Terminal
toggleterm-nvim = {
plugin-toggleterm-nvim = {
url = "github:akinsho/toggleterm.nvim";
flake = false;
};
# UI
nvim-navbuddy = {
plugin-nvim-navbuddy = {
url = "github:SmiteshP/nvim-navbuddy";
flake = false;
};
nvim-navic = {
plugin-nvim-navic = {
url = "github:SmiteshP/nvim-navic";
flake = false;
};
noice-nvim = {
plugin-noice-nvim = {
url = "github:folke/noice.nvim";
flake = false;
};
modes-nvim = {
plugin-modes-nvim = {
url = "github:mvllow/modes.nvim";
flake = false;
};
nvim-colorizer-lua = {
plugin-nvim-colorizer-lua = {
url = "github:NvChad/nvim-colorizer.lua";
flake = false;
};
vim-illuminate = {
plugin-vim-illuminate = {
url = "github:RRethy/vim-illuminate";
flake = false;
};
# Assistant
copilot-lua = {
plugin-copilot-lua = {
url = "github:zbirenbaum/copilot.lua";
flake = false;
};
copilot-cmp = {
plugin-copilot-cmp = {
url = "github:zbirenbaum/copilot-cmp";
flake = false;
};
# Session management
nvim-session-manager = {
plugin-nvim-session-manager = {
url = "github:Shatur/neovim-session-manager";
flake = false;
};
# Dependencies
plenary-nvim = {
plugin-plenary-nvim = {
# (required by crates-nvim)
url = "github:nvim-lua/plenary.nvim";
flake = false;
};
dressing-nvim = {
plugin-dressing-nvim = {
# (required by icon-picker-nvim)
url = "github:stevearc/dressing.nvim";
flake = false;
};
vim-markdown = {
plugin-vim-markdown = {
# (required by obsidian-nvim)
url = "github:preservim/vim-markdown";
flake = false;
};
tabular = {
plugin-tabular = {
# (required by vim-markdown)
url = "github:godlygeek/tabular";
flake = false;
};
nui-nvim = {
plugin-nui-nvim = {
# (required by noice.nvim)
url = "github:MunifTanjim/nui.nvim";
flake = false;
};
vim-repeat = {
plugin-vim-repeat = {
# (required by leap.nvim)
url = "github:tpope/vim-repeat";
flake = false;
};
nvim-nio = {
plugin-nvim-nio = {
# (required nvim-dap-ui)
url = "github:nvim-neotest/nvim-nio";
flake = false;

View file

@ -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;};

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;
};
};

View file

@ -11,7 +11,7 @@ inputs: {
inherit (pkgs.neovimUtils) makeNeovimConfig;
inherit (lib.attrsets) recursiveUpdate;
extendedLib = import ../lib/stdlib-extended.nix lib;
extendedLib = import ../lib/stdlib-extended.nix lib inputs;
nvimModules = import ./modules.nix {
inherit check pkgs;