-
-
Notifications
You must be signed in to change notification settings - Fork 296
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
plugins/by-name: init #2164
Conversation
My opinion was that we'd just do a migration over to the new structure right away. |
Sure, but I'd like the rest of the design decisions discussed & agreed on before investing time into that. |
I think this makes sense, we don't have a large enough scale project to warrant much (if any) nesting. The only thing I could see is maybe doing alphabetical nesting on first character if we were really worried about too large of a directory, for whatever reason.
Completely agree, I think we talked about this previously, but it will make it consistent in finding a plugin and not have to worry about sorting when simple plugins are still using directories instead of a single file. |
202b33d
to
1cc4e48
Compare
Ok, I've included an initial round of migration, just targeting the "utils" category for now. Details
# fish
set category utils
# First, move the loose files
for f in plugins/$category/*.nix
set name (path change-extension '' $f | path basename)
set dest plugins/by-name/$name
mkdir -p $dest
git mv $f $dest/default.nix
end
# next, move the remaining dirs over
git mv plugins/$category/* plugins/by-name/
# Remove the old imports in `default.nix`
vim plugins/default.nix
git add plugins/default.nix
# We also need to move the test files, for consistency:
for f in tests/test-sources/plugins/$category/*.nix
set name (path change-extension '' $f | path basename)
mkdir -p tests/test-sources/plugins/by-name/$name
git mv $f tests/test-sources/plugins/by-name/$name/default.nix
end
git mv tests/test-sources/plugins/$category/* tests/test-sources/plugins/by-name/ |
Yeah, initial impression is that directory layout should be fine. I'm curious what @traxys and @GaetanLepage think. I think utils was our largest directory of plugins and that being flattened into by-name isn't that large. |
3af79f9
to
5df0957
Compare
Another advantage is that it allows to easily split the default.nix file in sub-nix files if need arises, wheras if you had |
I agree with all the design choices |
How far should this PR go with migrating existing plugins to We already have enough migrated to demonstrate it working, and I don't want to spend too long deciding which plugins should/should not be moved over. |
If we're going to be leaving some behind out of by-name, I'd say wherever you feel comfortable stopping. The ones that get left behind we can decide if they should be migrated or not in separate discussions. My original thought was that it was gonna be an all out migration, but I do see the notes about some things not easily migrated, due to the shared code and helpers. So, I think it's fair to just knock out the bulk ones and niche ones can be done later, if it makes sense. |
I think this is a great idea! The internal tooling and helpers have gotten to the point it should be fairly simple to generate a skeleton module. |
This comment was marked as resolved.
This comment was marked as resolved.
f3096eb
to
4b07b9f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be ready for review.
Note that @GaetanLepage has specifically asked to have a say before merging.
Ideally, I'd like approval from all maintainers on this one.
I appreciate it is a large PR, however the vast majority of changes are simple renames with no changes to the files being moved.
The actual changes are mostly in:
- CONTRIBUTING.md (updated docs)
- plugins/default.nix (removing imports)
- modules/plugins.nix (auto-import implementation)
- tests/plugin-by-name.nix (various tests)
Everything within plugins/*
and tests/test-sources/
should exclusively be moving files without actual modification.
I've limited the migration to the low-hanging fruit. Partly for my own sanity, partly to avoid controversy/distraction, partly to keep the bulk part of the review simple.
(Reviewers would have to take more care if I migrated more complex plugins to by-name)
Hopefully the focus of the reviews can be on the design decisions, the extent of the tests (should they go further? additional tests?), any nit-picking with the implementation, and (of course) proof-reading the documentation.
4b07b9f
to
bd87964
Compare
bd87964
to
49cb49f
Compare
I've added very basic empty tests for the few plugins that didn't have any by running: # fish
for name in autoclose commentary easyescape floaterm fugitive gitmessenger intellitab nvim-bqf nvim-colorizer surround treesitter-playground treesitter-refactor vim-matchup
echo "adding test for $name"
set dir tests/test-sources/plugins/by-name/$name
mkdir -p $dir
echo "{
empty = {
plugins.$name.enable = true;
};
}" > $dir/default.nix
git add $dir/default.nix
end With this, I felt comfortable adding a test to |
3288d9e
to
4d3a9e9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I look forward to the convenience of by-name
b3d436b
to
f8d23cf
Compare
Add support for automatically importing any directories under `plugins/by-name`. Includes a validation test, which is run by CI and by the pre-commit hook.
- Move nvim-cmp to plugins/cmp - Move other completion plugins to plugins/by-name
- Added "empty" test for: - autoclose - commentary - easyescape - floaterm - fugitive - gitmessenger - intellitab - nvim-bqf - nvim-colorizer - surround - treesitter-refactor - vim-matchup
f8d23cf
to
54599ad
Compare
@Mergifyio queue |
✅ The pull request has been merged automaticallyThe pull request has been merged automatically at 54599ad |
Add support for automatically importing any directories under
plugins/by-name
.Documentation
plugins/by-name/README.md
(maybe?)Validation
A test is included that does some validation on the by-name directory and plugin-options* enabled within it:
default.nix
default.nix
fileWe could also have a CI workflow running on new PRs only, that validates whether new plugins are added to
by-name
instead of a category.* "Plugin options" are collected by looking for options matching
*.*.enable
Migration
See #2164 (comment)
I'd like an overall consensus on this before working on such migrations. See "Design decisions" below.
Future tooling
I think it'd be useful to have a devshell command that interactively builds a new plugin module based on the template.
You would be prompted for things like "type" (vim, lua, etc) "name", "pkg name" "setup fn", "globals prefix", and it'd automatically produce a minimal module file.
Design decisions
"na"
directory inpkgs/by-name/na/name/package.nix
.plugins/by-name/<name>/default.nix
to keep things simple.pkgs/by-name
, while we have around 200 files total matchingplugins/*/*.nix
.plugins/by-name/examp<TAB>
should be easier without a prefix.default.nix
files.foo/default.nix
orfoo.nix
)type == "directory"
files.by-name
should be imported manually inplugins/default.nix
.