refactor(nvim): discover plugins automatically

This commit is contained in:
Moritz Böhme 2023-03-11 17:00:32 +01:00
parent fc4caeb1ec
commit b87d7b387a
Signed by: moritz
GPG key ID: 970C6E89EB0547A9

View file

@ -1,7 +1,6 @@
{ config { config
, lib , lib
, pkgs , pkgs
, inputs
, ... , ...
}: }:
@ -9,12 +8,18 @@ with lib;
let let
cfg = config.my.programs.nvim; cfg = config.my.programs.nvim;
mkPlugin = name: { mkPlugin = fileName:
plugin = pkgs.vimPlugins.${name}; let
type = "lua"; path = ./plugins + "/${fileName}";
config = lib.readFile (./plugins + "/${name}.lua"); pluginName = lib.removeSuffix ".lua" fileName;
}; in
{
plugin = pkgs.vimPlugins.${pluginName};
type = "lua";
config = lib.readFile path;
};
pluginFileNames = builtins.attrNames (builtins.readDir ./plugins);
pluginsWithConfig = builtins.map mkPlugin pluginFileNames;
in in
{ {
options.my.programs.nvim.enable = mkEnableOption "nvim"; options.my.programs.nvim.enable = mkEnableOption "nvim";
@ -51,29 +56,7 @@ in
taplo taplo
yamlfmt yamlfmt
]; ];
plugins = builtins.map mkPlugin [ plugins = with pkgs.vimPlugins; [
"catppuccin-nvim"
"comment-nvim"
"copilot-lua"
"dashboard-nvim"
"formatter-nvim"
"gitsigns-nvim"
"lualine-nvim"
"noice-nvim"
"nvim-autopairs"
"nvim-lastplace"
"nvim-surround"
"nvim-tree-lua"
"nvim-treesitter-textsubjects"
"nvim-ts-context-commentstring"
"orgmode"
"smartcolumn-nvim"
"telescope-fzf-native-nvim"
"telescope-nvim"
"telescope-zoxide"
"which-key-nvim"
"todo-comments-nvim"
] ++ (with pkgs.vimPlugins; [
cmp-nvim-lsp cmp-nvim-lsp
cmp_luasnip cmp_luasnip
copilot-cmp copilot-cmp
@ -84,17 +67,17 @@ in
lspsaga-nvim-original lspsaga-nvim-original
lualine-lsp-progress lualine-lsp-progress
luasnip luasnip
nui-nvim # for noice-nvim nui-nvim
nvim-cmp nvim-cmp
nvim-lspconfig nvim-lspconfig
nvim-treesitter.withAllGrammars nvim-treesitter.withAllGrammars
nvim-ufo nvim-ufo
nvim-web-devicons # for dashboard-nvim nvim-web-devicons
plenary-nvim # for telescope, neogit plenary-nvim
popup-nvim popup-nvim
promise-async promise-async
vim-lion vim-lion
]); ] ++ pluginsWithConfig;
}; };
}; };
}; };