User Keybinds
Pages 45
Setting Up
For the programmer
- Writing my own module
- Hotswapping modules
- Difference between module.public and module.config.public
- Metamodules
Inbuilt modules:
core.autocommands
core.export
core.export.markdown
core.gtd.base
core.integrations.treesitter
core.keybinds
core.mode
core.neorgcmd
core.norg.completion
core.norg.concealer
core.norg.dirman
core.norg.esupports.hop
core.norg.esupports.indent
core.norg.esupports.metagen
core.norg.journal
core.norg.manoeuvre
core.norg.news
core.norg.qol.toc
core.norg.qol.todo_items
core.presenter
core.syntax
core.tangle
Clone this wiki locally
The Keybinds Module
Module for managing keybindings with Neorg mode support.
Overview
Disabling Default Keybinds
By default when you load the core.keybinds
module all keybinds will be enabled.
If you want to change this, be sure to set default_keybinds
to false
:
["core.keybinds"] = {
config = {
default_keybinds = false,
}
}
Setting Up a Keybind Hook
Want to change some keybinds? You can set up a function that will allow you to tweak every keybind bit by bit.
["core.keybinds"] = {
config = {
hook = function(keybinds)
-- Unmaps any Neorg key from the `norg` mode
keybinds.unmap("norg", "n", "gtd")
-- Binds the `gtd` key in `norg` mode to execute `:echo 'Hello'`
keybinds.map("norg", "n", "gtd", "<cmd>echo 'Hello!'<CR>")
-- Remap unbinds the current key then rebinds it to have a different action
-- associated with it.
-- The following is the equivalent of the `unmap` and `map` calls you saw above:
keybinds.remap("norg", "n", "gtd", "<cmd>echo 'Hello!'<CR>")
-- Sometimes you may simply want to rebind the Neorg action something is bound to
-- versus remapping the entire keybind. This remap is essentially the same as if you
-- did `keybinds.remap("norg", "n", "<C-Space>, "<cmd>Neorg keybind norg core.norg.qol.todo_items.todo.task_done<CR>")
keybinds.remap_event("norg", "n", "<C-Space>", "core.norg.qol.todo_items.todo.task_done")
-- Want to move one keybind into the other? `remap_key` moves the data of the
-- first keybind to the second keybind, then unbinds the first keybind.
keybinds.remap_key("norg", "n", "<C-Space>", "<Leader>t")
end,
}
}
Usage
How to Apply
- This module is already present in the
core.defaults
metamodule. You can load the module with:In your Neorg setup.["core.defaults"] = {},
- To manually load the module, place this code in your Neorg setup:
Consult the configuration section to see how you can configure
["core.keybinds"] = { config = { -- Note that this table is optional and doesn't need to be provided -- Configuration here } }
core.keybinds
to your liking.
Configuration
default_keybinds
: Use the default keybinds provided in https://github.com/nvim-neorg/neorg/blob/main/lua/neorg/modules/core/keybinds/keybinds.lua
Default value: true
neorg_leader
: Prefix for some Neorg keybinds
Default value: "<LocalLeader>"
hook
: Function to be invoked that allows the user to change their keybinds
Default value: nil
keybind_preset
: The keybind preset to use
Default value: "neorg"
keybind_presets
: An array of functions, each one corresponding to a separate preset
Default Value:
Developer Usage
Public API
This segment will detail all of the functions core.keybinds
exposes. All of these functions reside in the public
table.
request_keys
bind_all
register_keybind
sync
register_keybinds
Examples
Create keybinds in your module
-- The process of defining a keybind is only a tiny bit more involved than defining e.g. an autocommand. Let's see what differs in creating a keybind rather than creating an autocommand:
Attach some keys to the create keybind
-- To invoke a keybind, we can then use :Neorg keybind norg test.module.my_keybind.
Extra Info
Version
This module supports at least version 0.0.9. The current Neorg version is 0.0.11.
Imports
Requires
-
core.neorgcmd
- This module deals with handling everything related to the:Neorg
command. -
core.mode
- Modes are a way of isolating different parts of Neorg based on the current mode. -
core.autocommands
- Handles the creation and management of Neovim's autocommands.
Required by
-
core.gtd.ui
- Nicely displays GTD related information. -
core.integrations.treesitter
- A module designed to integrate TreeSitter into Neorg. -
core.norg.dirman
- This module is be responsible for managing directories full of .norg files. -
core.norg.journal
- Easily create files for a journal. -
core.norg.manoeuvre
- A Neorg module for moving around different elements up and down. -
core.norg.esupports.hop
- "Hop" between Neorg links, following them with a single keypress. -
core.norg.esupports.metagen
- A Neorg module for generating document metadata automatically. -
core.norg.qol.toc
- Generates a Table of Content from the Neorg file. -
core.norg.qol.todo_items
- Module for implementing todo lists.