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
, lib
, pkgs
, inputs
, ...
}:
@ -9,12 +8,18 @@ with lib;
let
cfg = config.my.programs.nvim;
mkPlugin = name: {
plugin = pkgs.vimPlugins.${name};
type = "lua";
config = lib.readFile (./plugins + "/${name}.lua");
};
mkPlugin = fileName:
let
path = ./plugins + "/${fileName}";
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
{
options.my.programs.nvim.enable = mkEnableOption "nvim";
@ -51,29 +56,7 @@ in
taplo
yamlfmt
];
plugins = builtins.map mkPlugin [
"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; [
plugins = with pkgs.vimPlugins; [
cmp-nvim-lsp
cmp_luasnip
copilot-cmp
@ -84,17 +67,17 @@ in
lspsaga-nvim-original
lualine-lsp-progress
luasnip
nui-nvim # for noice-nvim
nui-nvim
nvim-cmp
nvim-lspconfig
nvim-treesitter.withAllGrammars
nvim-ufo
nvim-web-devicons # for dashboard-nvim
plenary-nvim # for telescope, neogit
nvim-web-devicons
plenary-nvim
popup-nvim
promise-async
vim-lion
]);
] ++ pluginsWithConfig;
};
};
};