plugins/todo-comments: migrate to mkNeovimPlugin#2030
plugins/todo-comments: migrate to mkNeovimPlugin#2030mergify[bot] merged 1 commit intonix-community:mainfrom
Conversation
8ecf733 to
3fb4211
Compare
| (mkIf (cfg.keymaps.todoTrouble != null) { trouble.enable = true; }) | ||
| (mkIf (cfg.keymaps.todoTelescope != null) { telescope.enable = true; }) | ||
| ]; | ||
| mkCompositeOption "Keymap settings for the `:${funcName}` function." { |
There was a problem hiding this comment.
Is it possible to do this is a way that complies with #603?
There was a problem hiding this comment.
If you're unfamiliar, the idea is that plugin keymaps should make use of mkMapOptionSubmodule instead of implementing their own keymap submodule types.
There was a problem hiding this comment.
If mkMapOptionSubmodule is too limiting, because it doesn't support additional options (cwd, keywords) I'm open to making it more powerful by adding an extraOptions argument or similar.
There was a problem hiding this comment.
As discussed in #2030 (comment) this can done in be another PR
826f39a to
e550f80
Compare
plugins/utils/todo-comments.nix
Outdated
| keymaps = flatten ( | ||
| mapAttrsToList ( | ||
| optionName: funcName: | ||
| let | ||
| keymap = cfg.keymaps.${optionName}; | ||
|
|
||
| cwd = optionalString (keymap.cwd != null) " cwd=${keymap.cwd}"; | ||
| keywords = optionalString (keymap.keywords != null) " keywords=${keymap.keywords}"; | ||
| in | ||
| optional (keymap != null) { | ||
| mode = "n"; | ||
| inherit (keymap) key options; | ||
| action = ":${funcName}${cwd}${keywords}<CR>"; | ||
| } | ||
| ) commands | ||
| ); |
There was a problem hiding this comment.
I see this is unchanged from the previous implementation, other than being indented further.
However, I think this would be simpler mapping over cfg.keymaps instead of mapping over commands?
Ideally, I'd like to avoid using optional+flatten, perhaps we could do something like:
keymaps = lib.pipe cfg.keymaps [
(filterAttrs (n: v: v != null))
(mapAttrsToList (name: keymap: {
inherit (keymap) key option;
mode = "n";
action =
let
cmd = commands.${name};
cwd = optionalString (keymap.cwd != null) " cwd=${keymap.cwd}";
keywords = optionalString (keymap.keywords != null) " keywords=${keymap.keywords}";
in
"<cmd>${cmd}${cwd}${keywords}<cr>";
}))
];Looking at the commands attrset, we could probably replace it with a upperFirstChar style helper.
However, many of the details would be slightly different if we can go down the #603 route.
There was a problem hiding this comment.
I see this is unchanged from the previous implementation, other than being indented further.
Yeah, sorry I didn't touch this bit. I wasn't sure what to do with it, yet.
I think the suggested solution is a lot cleaner. But, I need to get more familiar with that keymap issue that was mentioned here and above.
There was a problem hiding this comment.
We can always tackle it in another PR, but the other suggestions above could be better.
There was a problem hiding this comment.
If I can tackle that separately it would give me a bit to figure it out and maybe get the extraOptions support for mkMapOptionSubmodule
970e1df to
f602326
Compare
MattSturgeon
left a comment
There was a problem hiding this comment.
Think these are the final comments 🚀
| keymapsActions = { | ||
| todoQuickFix = "TodoQuickFix"; | ||
| todoLocList = "TodoLocList"; | ||
| todoTrouble = "TodoTrouble"; | ||
| todoTelescope = "TodoTelescope"; | ||
| }; |
There was a problem hiding this comment.
Up to you, we could drop this, since we have lib.nixvim.upperFirstChar:
Lines 81 to 104 in 78fc4be
There was a problem hiding this comment.
Well, I guess it's used in the option declaration as well as the keymap transformation. So maybe best to keep it?
| mode = "n"; | ||
| action = | ||
| let | ||
| cmd = keymapsActions.${name}; |
There was a problem hiding this comment.
If you decide to drop the keymapsActions attrs:
| cmd = keymapsActions.${name}; | |
| cmd = lib.nixvim.upperFirstChar name; |
plugins/utils/todo-comments.nix
Outdated
| keywords = | ||
| defaultNullOpts.mkAttrsOf | ||
| (types.submodule { | ||
| options = { |
There was a problem hiding this comment.
Note: this will be affected by #1618, however that doesn't affect how you should implement it here. It's just another reason for us to investigate the issue.
eb58f12 to
a8437a8
Compare
There was a problem hiding this comment.
Can't see any remaining issues. Thanks for another quality PR! 🎉
Using mkMapOptionSubmodule as per #603 can be postponed to another PR, and may be best done after #2035 is merged anyway.
Up to you if you're happy merging now if if you'd like to ping other maintainers for a second opinion.
No need to wait for the tests to pass though, since mergify will do that for us.
|
@Mergifyio queue |
🛑 The pull request has been removed from the queue
|
|
@Mergifyio refresh |
|
@Mergifyio queue |
✅ Pull request refreshed |
✅ The pull request has been merged automaticallyDetailsThe pull request has been merged automatically at 379ae77 |
No description provided.