refactor(nvim): discover plugins automatically

nixos
Moritz Böhme 2023-03-11 17:00:32 +01:00
parent fc4caeb1ec
commit b87d7b387a
Signed by: moritz
GPG Key ID: 970C6E89EB0547A9
1 changed files with 17 additions and 34 deletions

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
path = ./plugins + "/${fileName}";
pluginName = lib.removeSuffix ".lua" fileName;
in
{
plugin = pkgs.vimPlugins.${pluginName};
type = "lua"; type = "lua";
config = lib.readFile (./plugins + "/${name}.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;
}; };
}; };
}; };