-
-
Notifications
You must be signed in to change notification settings - Fork 220
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
feat!: massive keybinds refactor #1509
Conversation
I think modes would be quite similar to what this plugin does https://github.com/shmerl/session-keys Of course the optimal solution would be namespaced mappings but we don't know when will get those (if ever 😢 ) |
Mode support is much more sophisticated now and should fix a lot of issues found during day to day usage. This is because modes can now have parents which they inherit behaviours like keybinds from. |
Note: general keybinds that operate outside of norg files will not trigger because neorg lazy loads itself. This should be mitigated by moving the core startup code to |
just a thought I had |
another thing is custom keybinds you can just use normal keybinds because of the different modes |
I earlier alluded to reimplementing the keybind hook for interoperability, but instead settled on (in my opinion) a much better system. Keybind hooks are very limiting and unnecessary DSLs for our keybind system. Users will have to set their keymaps in a buffer-local fashion either:
This will, by default, override that key for all Neorg modes. To remap a key in a specific mode only, one can simply query the current mode using This approach is much more inline with the vim philosophy and much easier to adapt to any configuration style. |
the mode thing doesn't work though |
If a mode change happens dynamically then yes there may be a problem, you're right. A user autocommand generated by the core.mode module sounds like a good approach. (PS: there is already a way to listen to these events through |
Actually, I'm highly considering nuking mode support. Shouldn't we integrate with e.g. hydra instead? |
hydra does much more than just different modes and seems overkill imo and not worth to add as a dependency also hydra is not too well maintained it seems as long as it's just optional I'm fine with this |
I never wanted to add it as a direct dependency. But integration with existing tools is much wiser than trying to reinvent the wheel in my eyes. It simplifies the existing code so much that I'd say it's worth pursuing. |
…local mappings instead
86c977b
to
f297ccd
Compare
Just documentation left now! (and the docgen) |
I don't believe I'm missing anything here. Should be ready to merge into main soon as a first test wave. If any of you are not pinned to the latest stable release then I encourage you to do so asap :p |
Modernizing Keybinds
This pull request is a long-awaited refactor of the internal keybind system used by Neorg. In this refactor I seek to:
including a "vim" preset which makes full use of the vim keys for all operationsthis will require a different pull request to consider all of the vim-available keys)<Plug>
mappings<Plug>
may seem like a weird choice, but it is the defacto way of mapping keys. This way, various modules can map their behaviours to a<Plug>
object without worrying about who binds it and where. Plug mappings also allow us to check for keybind conflicts reliably. When you map your own keybind to a Neorg mapping, Neorg will no longer forcefully create its own keybind, completely eliminating conflicts.All in all, this system will be much more ergonomic and will only require a vim.keymap.set from the user's end, everything else will just work!
TODOs
Reimplement keybind hook (required for mode interoperability)default_keybinds
option