Skip to content

Allow disabling nvf mappings#1450

Open
alfarelcynthesis wants to merge 5 commits intoNotAShelf:mainfrom
alfarelcynthesis:no-default-mappings-option
Open

Allow disabling nvf mappings#1450
alfarelcynthesis wants to merge 5 commits intoNotAShelf:mainfrom
alfarelcynthesis:no-default-mappings-option

Conversation

@alfarelcynthesis
Copy link
Contributor

@alfarelcynthesis alfarelcynthesis commented Mar 15, 2026

This approach to the problem sources mkMappingOption from config, since it should reference an option for whether to use the provided default or null.

This change would be completely transparent to any current users, but requires enforcing that new plugin contributions use config.vim.lib.mkMappingOption instead of the lib.nvim.binds version.
If people are using the original mkMappingOption in outside projects, it will continue working as before, which is probably the desired behaviour.

  • First commit contains the actual implementation.
    • Probably best to focus review time here initially, it's fairly simple.
  • Second is mostly script-generated, replaces references to the original mkMappingOption with ones to the config-aware one.
  • Third is fixes to less-automatable issues related to nullable keymaps.
  • Fourth is conversions to mkMappingOption for options that should have used it but used to use mkOption.

Related discussion: #1043

Feedback Wanted

  • Should the lib options go elsewhere? be named something else?
  • Should the config-aware mkMappingOption be named separately to reduce confusion?
  • Should useNvfKeymaps be named something else?
  • Should this be mentioned in the setup/other docs?
  • Should the option also be used to remove which-key group defaults (Duplicate Keybindings when setting personal keymaps in which-key #718)?
    • Probably not, based on the comment on the issue.

Remaining work

  • Direct testing. Packages build, but I should spend some more time inspecting them in an actual setup.
  • Make surround-nvim vendored keymaps option default depend on the global setting?
  • LS keybinds, does rust still require them to be not null?
  • Should the copilot-lua mkLuaKeymap use lib.binds.mkLuaBinding?
    • Updated it to allow nulls, should be fine to leave as is, but might be a good opportunity to update it?
  • Check that .#nix and .#maximal build with useNvfKeymaps disabled.

Sanity Checking

  • I have updated the changelog as per my changes
  • I have tested, and self-reviewed my code
    • I haven't tested every plugin, but the changes should be completely transparent, and I've tested both packages with and without the option enabled, as well as my config.
      This is probably worth testing a bit more thoroughly, if it gets accepted.
  • My changes fit guidelines found in hacking nvf
  • Style and consistency
    • I ran Alejandra to format my code (nix fmt)
    • My code conforms to the editorconfig configuration of the project
    • My changes are consistent with the rest of the codebase
      • debatable, worth talking about (function as config option)
  • If new changes are particularly complex:
    • My code includes comments in particularly complex areas
    • I have added a section in the manual
    • (For breaking changes) I have included a migration guide
      • isn't breaking
  • Package(s) built:
    • .#nix (default package)
    • .#maximal
    • .#docs-html (manual, must build)
    • .#docs-linkcheck (optional, please build if adding links)
      • unrelated errors
  • Tested on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin

Add a 👍 reaction to pull requests you find important.

@alfarelcynthesis alfarelcynthesis force-pushed the no-default-mappings-option branch 2 times, most recently from 7f2ed04 to 7823de1 Compare March 15, 2026 00:57
github-actions bot pushed a commit that referenced this pull request Mar 15, 2026
@github-actions
Copy link

github-actions bot commented Mar 15, 2026

🚀 Live preview deployed from 1d3730f

View it here:

Debug Information

Triggered by: alfarelcynthesis

HEAD at: no-default-mappings-option

Reruns: 2396

github-actions bot pushed a commit that referenced this pull request Mar 15, 2026
github-actions bot pushed a commit that referenced this pull request Mar 15, 2026
@alfarelcynthesis alfarelcynthesis force-pushed the no-default-mappings-option branch 5 times, most recently from 781252c to 3a40efb Compare March 15, 2026 02:20
github-actions bot pushed a commit that referenced this pull request Mar 15, 2026
@alfarelcynthesis alfarelcynthesis force-pushed the no-default-mappings-option branch from 3a40efb to 0f14749 Compare March 15, 2026 02:34
github-actions bot pushed a commit that referenced this pull request Mar 15, 2026
@alfarelcynthesis alfarelcynthesis marked this pull request as ready for review March 15, 2026 02:48
github-actions bot pushed a commit that referenced this pull request Mar 15, 2026
horriblename
horriblename previously approved these changes Mar 15, 2026
Copy link
Collaborator

@horriblename horriblename left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I wouldn't have thought of that

LGTM but I'd like an approval from @NotAShelf or @Soliprem

github-actions bot pushed a commit that referenced this pull request Mar 15, 2026
@snoweuph
Copy link
Collaborator

Thanks! I wouldn't have thought of that

LGTM but I'd like an approval from @NotAShelf or @Soliprem

isn't raf on for vacation according to matrix?

@NotAShelf
Copy link
Owner

I'm on """vacation""", meaning I am away from my main system involuntarily

@snoweuph
Copy link
Collaborator

I'm on """vacation""", meaning I am away from my main system involuntarily

LMFAO, :3

@alfarelcynthesis
Copy link
Contributor Author

I added the changelog entry, seems like this won't need too many other changes :)

github-actions bot pushed a commit that referenced this pull request Mar 15, 2026
@alfarelcynthesis alfarelcynthesis force-pushed the no-default-mappings-option branch from cbddc5c to 0ba2482 Compare March 17, 2026 19:00
github-actions bot pushed a commit that referenced this pull request Mar 17, 2026
@alfarelcynthesis alfarelcynthesis force-pushed the no-default-mappings-option branch from 0ba2482 to c5c9ef8 Compare March 17, 2026 19:11
@alfarelcynthesis
Copy link
Contributor Author

alfarelcynthesis commented Mar 17, 2026

Rebased on latest main + #1457.

(I'm rebasing to make sure to catch small incompatibilities as they get into the repo, given this touches a lot of files.)

(Also means anyone testing this branch by using it gets up-to-date options elsewhere.)

github-actions bot pushed a commit that referenced this pull request Mar 17, 2026
@alfarelcynthesis alfarelcynthesis force-pushed the no-default-mappings-option branch from c5c9ef8 to 40f40a4 Compare March 17, 2026 20:11
github-actions bot pushed a commit that referenced this pull request Mar 17, 2026
@alfarelcynthesis alfarelcynthesis force-pushed the no-default-mappings-option branch from 40f40a4 to a62ed88 Compare March 20, 2026 18:53
github-actions bot pushed a commit that referenced this pull request Mar 20, 2026
@alfarelcynthesis alfarelcynthesis force-pushed the no-default-mappings-option branch 2 times, most recently from d48066a to 997c941 Compare March 22, 2026 13:56
github-actions bot pushed a commit that referenced this pull request Mar 22, 2026
@alfarelcynthesis alfarelcynthesis force-pushed the no-default-mappings-option branch from 997c941 to 78a4db0 Compare March 23, 2026 15:56
github-actions bot pushed a commit that referenced this pull request Mar 23, 2026
@alfarelcynthesis alfarelcynthesis force-pushed the no-default-mappings-option branch from 78a4db0 to 5f51010 Compare March 24, 2026 14:16
github-actions bot pushed a commit that referenced this pull request Mar 24, 2026
Copy link
Collaborator

@Soliprem Soliprem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on a skim nothing jumps to the eye that I'd change, and I like the change itslef. LGTM, but I'll need to review this better with a fresh mind

mkMappingOption wants to read a setting set in config without passing it
every time, so it should be defined in config.
Generated using:

- `sd -F "inherit (lib.nvim.binds) mkMappingOption;" "inherit (config.vim.lib) mkMappingOption;" $(find . -type f)`
- `sd -F "{lib, ...}: let" "{config, lib, ...}: let" $(find . -type f)`

Tweaked manually (placement in inherit list, fixing todo-comments and toggleterm).

Ran `nix run nixpkgs#deadnix -- -e` to clean up.
Next commit includes unrelated dead code.
Mostly involves filtering keybinds that are null in cases where the
keybind is the attrname, and optionalString for manual lua keybind
registration.
@alfarelcynthesis alfarelcynthesis force-pushed the no-default-mappings-option branch from 5f51010 to 5ba3b72 Compare March 25, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants