Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins/by-name: init #2164

Merged
merged 17 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 9 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,22 @@ This is done by making most of the options of the type `types.nullOr ....`, and
Most of nixvim is dedicated to wrapping neovim plugins such that we can configure them in Nix.
To add a new plugin you need to do the following.

1. Add a file in the correct sub-directory of [plugins](plugins). This depends on your exact plugin.

The vast majority of plugins fall into one of those two categories:
1. Add a file in the correct sub-directory of [`plugins`](plugins).
- Most plugins should be added to [`plugins/by-name/<name>`](plugins/by-name).
Plugins in `by-name` are automatically imported 🚀
- Occasionally, you may wish to add a plugin to a directory outside of `by-name`, such as [`plugins/colorschemes`](plugins/colorschemes).
If so, you will also need to add your plugin to [`plugins/default.nix`](plugins/default.nix) to ensure it gets imported.
Note: the imports list is sorted and grouped. In vim, you can usually use `V` (visual-line mode) with the `:sort` command to achieve the desired result.

2. The vast majority of plugins fall into one of those two categories:
- _vim plugins_: They are configured through **global variables** (`g:plugin_foo_option` in vimscript and `vim.g.plugin_foo_option` in lua).\
For those, you should use the `lib.nixvim.vim-plugin.mkVimPlugin`.\
-> See [this plugin](plugins/utils/direnv.nix) for an example.
- _neovim plugins_: They are configured through a `setup` function (`require('plugin').setup({opts})`).\
For those, you should use the `lib.nixvim.neovim-plugin.mkNeovimPlugin`.\
-> See the [template](plugins/TEMPLATE.nix).

2. Add the necessary parameters for the `mkNeovimPlugin`/`mkVimPlugin`:
3. Add the necessary parameters for the `mkNeovimPlugin`/`mkVimPlugin`:
- `name`: The name of the plugin. The resulting nixvim module will have `plugins.<name>` as a path.\
For a plugin named `foo-bar.nvim`, set this to `foo-bar` (subject to exceptions).
- `originalName`: The "real" name of the plugin (i.e. `foo-bar.nvim`). This is used mostly in documentation.
Expand All @@ -55,10 +60,6 @@ The vast majority of plugins fall into one of those two categories:
See below for more information
- `settingsExample`: An example of what could the `settings` attrs look like.

3. Add to plugins/default.nix
- As a final step, please add your plugin to `plugins/default.nix` to ensure it gets imported.
- Note: the imports list is sorted and grouped. In vim, you can usually use `V` (visual-line mode) with the `:sort` command to achieve the desired result.

[nixpkgs-maintainers]: https://github.com/NixOS/nixpkgs/blob/master/maintainers/maintainer-list.nix

#### Declaring plugin options
Expand Down
10 changes: 10 additions & 0 deletions flake-modules/dev/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@
args = [ ".#checks.${system}.maintainers" ];
pass_filenames = false;
};
plugins-by-name = {
enable = true;
name = "plugins-by-name";
description = "Check `plugins/by-name` when it's modified.";
files = "^(?:tests/test-sources/)?plugins/by-name/";
package = pkgs.nix;
entry = "nix build --no-link --print-build-logs";
args = [ ".#checks.${system}.plugins-by-name" ];
pass_filenames = false;
};
};
};
};
Expand Down
2 changes: 2 additions & 0 deletions flake-modules/tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@

maintainers = import ../tests/maintainers.nix { inherit pkgs; };

plugins-by-name = pkgs.callPackage ../tests/plugins-by-name.nix { inherit evaluatedNixvim; };

generated = pkgs.callPackage ../tests/generated.nix { };

package-options = pkgs.callPackage ../tests/package-options.nix { inherit evaluatedNixvim; };
Expand Down
15 changes: 13 additions & 2 deletions modules/plugins.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
{ ... }:
{ lib, ... }:
let
inherit (builtins) readDir;
inherit (lib.attrsets) foldlAttrs;
inherit (lib.lists) optional;
by-name = ../plugins/by-name;
in
{
imports = [ ../plugins/default.nix ];
imports =
[ ../plugins ]
++ foldlAttrs (
prev: name: type:
prev ++ optional (type == "directory") (by-name + "/${name}")
) [ ] (readDir by-name);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ helpers.neovim-plugin.mkNeovimPlugin {
hydras = import ./hydras-option.nix { inherit lib helpers; };
};

settingsOptions = import ./hydra-config-opts.nix { inherit lib helpers; };
settingsOptions = import ./settings-options.nix { inherit lib helpers; };

settingsExample = {
exit = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let
for more information.
'';

config = import ./hydra-config-opts.nix { inherit lib helpers; };
config = import ./settings-options.nix { inherit lib helpers; };

heads =
let
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
181 changes: 1 addition & 180 deletions plugins/default.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
{
imports = [
./ai/chatgpt.nix
./ai/copilot-chat.nix

./bufferlines/barbar.nix
./bufferlines/barbecue.nix
./bufferlines/bufferline.nix
./bufferlines/navic.nix
./cmp

./colorschemes/ayu.nix
./colorschemes/base16
Expand All @@ -30,37 +24,6 @@
./colorschemes/tokyonight.nix
./colorschemes/vscode.nix

./completion/codeium-vim.nix
./completion/codeium-nvim.nix
./completion/copilot-lua.nix
./completion/copilot-vim.nix
./completion/coq.nix
./completion/coq-thirdparty.nix
./completion/lspkind.nix
./completion/cmp

./dap

./filetrees/chadtree.nix
./filetrees/neo-tree.nix
./filetrees/nvim-tree.nix
./filetrees/yazi.nix

./git/committia.nix
./git/diffview.nix
./git/fugitive.nix
./git/git-conflict.nix
./git/git-worktree.nix
./git/gitblame.nix
./git/gitgutter.nix
./git/gitignore.nix
./git/gitlinker.nix
./git/gitmessenger.nix
./git/gitsigns
./git/lazygit.nix
./git/neogit
./git/octo.nix

./languages/clangd-extensions.nix
./languages/cmake-tools.nix
./languages/debugprint.nix
Expand Down Expand Up @@ -90,32 +53,13 @@
./languages/sniprun.nix
./languages/tagbar.nix
./languages/texpresso.nix
./languages/treesitter/hmts.nix
./languages/treesitter/rainbow-delimiters.nix
./languages/treesitter/treesitter-context.nix
./languages/treesitter/treesitter-refactor.nix
./languages/treesitter/treesitter-textobjects.nix
./languages/treesitter/treesitter.nix
./languages/treesitter/ts-autotag.nix
./languages/treesitter/ts-context-commentstring.nix
./languages/typescript-tools.nix
./languages/typst/typst-vim.nix
./languages/vim-slime.nix
./languages/vimtex.nix
./languages/zig.nix

./lsp
./lsp/conform-nvim.nix
./lsp/fidget.nix
./lsp/inc-rename.nix
./lsp/lspsaga.nix
./lsp/lsp-format.nix
./lsp/lsp-lines.nix
./lsp/lsp-status.nix
./lsp/nvim-lightbulb.nix
./lsp/schemastore.nix
./lsp/trouble.nix
./lsp/wtf.nix

./neotest

Expand All @@ -125,129 +69,6 @@
./pluginmanagers/lazy.nix
./pluginmanagers/lz-n.nix

./snippets/friendly-snippets.nix
./snippets/luasnip
./snippets/nvim-snippets.nix

./statuslines/airline.nix
./statuslines/lightline.nix
./statuslines/lualine.nix

./telescope

./ui/edgy.nix
./ui/headlines.nix
./ui/image.nix
./ui/neoscroll.nix
./ui/noice.nix
./ui/numbertoggle.nix
./ui/specs.nix
./ui/statuscol.nix
./ui/transparent.nix
./ui/twilight.nix
./ui/virt-column.nix
./ui/zen-mode.nix

./utils/alpha.nix
./utils/arrow.nix
./utils/auto-save.nix
./utils/auto-session.nix
./utils/autoclose.nix
./utils/autosource.nix
./utils/bacon.nix
./utils/baleia.nix
./utils/better-escape.nix
./utils/bufdelete.nix
./utils/ccc.nix
./utils/clipboard-image.nix
./utils/cloak.nix
./utils/codesnap.nix
./utils/comment.nix
./utils/comment-box.nix
./utils/commentary.nix
./utils/competitest.nix
./utils/conjure.nix
./utils/coverage.nix
./utils/cursorline.nix
./utils/dashboard.nix
./utils/direnv.nix
./utils/dressing.nix
./utils/easyescape.nix
./utils/emmet.nix
./utils/endwise.nix
./utils/firenvim.nix
./utils/flash.nix
./utils/floaterm.nix
./utils/fzf-lua.nix
./utils/goyo.nix
./utils/guess-indent.nix
./utils/hardtime.nix
./utils/harpoon.nix
./utils/hop.nix
./utils/hydra
./utils/illuminate.nix
./utils/improved-search.nix
./utils/indent-blankline.nix
./utils/indent-o-matic.nix
./utils/instant.nix
./utils/intellitab.nix
./utils/lastplace.nix
./utils/leap.nix
./utils/magma-nvim.nix
./utils/mark-radar.nix
./utils/marks.nix
./utils/mini.nix
./utils/mkdnflow.nix
./utils/molten.nix
./utils/multicursors.nix
./utils/navbuddy.nix
./utils/neoclip.nix
./utils/neocord.nix
./utils/neogen.nix
./utils/neorg.nix
./utils/netman.nix
./utils/nix-develop.nix
./utils/notify.nix
./utils/nvim-autopairs.nix
./utils/nvim-bqf.nix
./utils/nvim-colorizer.nix
./utils/nvim-osc52.nix
./utils/nvim-ufo.nix
./utils/obsidian
./utils/oil.nix
./utils/ollama.nix
./utils/persistence.nix
./utils/presence-nvim.nix
./utils/project-nvim.nix
./utils/quickmath.nix
./utils/refactoring.nix
./utils/repeat.nix
./utils/rest.nix
./utils/sandwich.nix
./utils/scope.nix
./utils/sleuth.nix
./utils/smart-splits.nix
./utils/spectre.nix
./utils/spider.nix
./utils/startify
./utils/startup.nix
./utils/surround.nix
./utils/tmux-navigator.nix
./utils/todo-comments.nix
./utils/toggleterm.nix
./utils/trim.nix
./utils/undotree.nix
./utils/vim-bbye.nix
./utils/vim-css-color.nix
./utils/vim-matchup.nix
./utils/wakatime.nix
./utils/web-devicons.nix
./utils/which-key.nix
./utils/wilder.nix
./utils/yanky.nix
./utils/zellij.nix
./utils/zk.nix

./deprecation.nix
];
}
Loading