Skip to content

Commit

Permalink
refactor(keybinds): add neorg prefix where mappings are set
Browse files Browse the repository at this point in the history
  • Loading branch information
max397574 committed Jan 6, 2024
1 parent a489e7c commit c72f114
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 39 deletions.
78 changes: 39 additions & 39 deletions lua/neorg/modules/core/keybinds/keybinds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,107 +17,107 @@ module.config.public = {
{
leader .. "tu",
"core.qol.todo_items.todo.task_undone",
opts = { desc = "[neorg] Mark as Undone" },
opts = { desc = "Mark as Undone" },
},

-- Marks the task under the cursor as "pending"
-- ^mark Task as Pending
{
leader .. "tp",
"core.qol.todo_items.todo.task_pending",
opts = { desc = "[neorg] Mark as Pending" },
opts = { desc = "Mark as Pending" },
},

-- Marks the task under the cursor as "done"
-- ^mark Task as Done
{ leader .. "td", "core.qol.todo_items.todo.task_done", opts = { desc = "[neorg] Mark as Done" } },
{ leader .. "td", "core.qol.todo_items.todo.task_done", opts = { desc = "Mark as Done" } },

-- Marks the task under the cursor as "on_hold"
-- ^mark Task as on Hold
{
leader .. "th",
"core.qol.todo_items.todo.task_on_hold",
opts = { desc = "[neorg] Mark as On Hold" },
opts = { desc = "Mark as On Hold" },
},

-- Marks the task under the cursor as "cancelled"
-- ^mark Task as Cancelled
{
leader .. "tc",
"core.qol.todo_items.todo.task_cancelled",
opts = { desc = "[neorg] Mark as Cancelled" },
opts = { desc = "Mark as Cancelled" },
},

-- Marks the task under the cursor as "recurring"
-- ^mark Task as Recurring
{
leader .. "tr",
"core.qol.todo_items.todo.task_recurring",
opts = { desc = "[neorg] Mark as Recurring" },
opts = { desc = "Mark as Recurring" },
},

-- Marks the task under the cursor as "important"
-- ^mark Task as Important
{
leader .. "ti",
"core.qol.todo_items.todo.task_important",
opts = { desc = "[neorg] Mark as Important" },
opts = { desc = "Mark as Important" },
},

-- Marks the task under the cursor as "ambiguous"
-- ^mark Task as ambiguous
{
leader .. "ta",
"core.qol.todo_items.todo.task_ambiguous",
opts = { desc = "[neorg] Mark as Ambigous" },
opts = { desc = "Mark as Ambigous" },
},

-- Switches the task under the cursor between a select few states
{ "<C-Space>", "core.qol.todo_items.todo.task_cycle", opts = { desc = "[neorg] Cycle Task" } },
{ "<C-Space>", "core.qol.todo_items.todo.task_cycle", opts = { desc = "Cycle Task" } },

-- Creates a new .norg file to take notes in
-- ^New Note
{ leader .. "nn", "core.dirman.new.note", opts = { desc = "[neorg] Create New Note" } },
{ leader .. "nn", "core.dirman.new.note", opts = { desc = "Create New Note" } },

-- Hop to the destination of the link under the cursor
{ "<CR>", "core.esupports.hop.hop-link", opts = { desc = "[neorg] Jump to Link" } },
{ "gd", "core.esupports.hop.hop-link", opts = { desc = "[neorg] Jump to Link" } },
{ "gf", "core.esupports.hop.hop-link", opts = { desc = "[neorg] Jump to Link" } },
{ "gF", "core.esupports.hop.hop-link", opts = { desc = "[neorg] Jump to Link" } },
{ "<CR>", "core.esupports.hop.hop-link", opts = { desc = "Jump to Link" } },
{ "gd", "core.esupports.hop.hop-link", opts = { desc = "Jump to Link" } },
{ "gf", "core.esupports.hop.hop-link", opts = { desc = "Jump to Link" } },
{ "gF", "core.esupports.hop.hop-link", opts = { desc = "Jump to Link" } },

-- Same as `<CR>`, except opens the destination in a vertical split
{
"<M-CR>",
"core.esupports.hop.hop-link",
"vsplit",
opts = { desc = "[neorg] Jump to Link (Vertical Split)" },
opts = { desc = "Jump to Link (Vertical Split)" },
},

{ ">.", "core.promo.promote", opts = { desc = "[neorg] Promote Object (Non-Recursively)" } },
{ "<,", "core.promo.demote", opts = { desc = "[neorg] Demote Object (Non-Recursively)" } },
{ ">.", "core.promo.promote", opts = { desc = "Promote Object (Non-Recursively)" } },
{ "<,", "core.promo.demote", opts = { desc = "Demote Object (Non-Recursively)" } },

{ ">>", "core.promo.promote", "nested", opts = { desc = "[neorg] Promote Object (Recursively)" } },
{ "<<", "core.promo.demote", "nested", opts = { desc = "[neorg] Demote Object (Recursively)" } },
{ ">>", "core.promo.promote", "nested", opts = { desc = "Promote Object (Recursively)" } },
{ "<<", "core.promo.demote", "nested", opts = { desc = "Demote Object (Recursively)" } },

{
leader .. "lt",
"core.pivot.toggle-list-type",
opts = { desc = "[neorg] Toggle (Un)ordered List" },
opts = { desc = "Toggle (Un)ordered List" },
},
{
leader .. "li",
"core.pivot.invert-list-type",
opts = { desc = "[neorg] Invert (Un)ordered List" },
opts = { desc = "Invert (Un)ordered List" },
},

{ leader .. "id", "core.tempus.insert-date", opts = { desc = "[neorg] Insert Date" } },
{ leader .. "id", "core.tempus.insert-date", opts = { desc = "Insert Date" } },
},

i = {
{ "<C-t>", "core.promo.promote", opts = { desc = "[neorg] Promote Object (Recursively)" } },
{ "<C-d>", "core.promo.demote", opts = { desc = "[neorg] Demote Object (Recursively)" } },
{ "<M-CR>", "core.itero.next-iteration", "<CR>", opts = { desc = "[neorg] Continue Object" } },
{ "<M-d>", "core.tempus.insert-date-insert-mode", opts = { desc = "[neorg] Insert Date" } },
{ "<C-t>", "core.promo.promote", opts = { desc = "Promote Object (Recursively)" } },
{ "<C-d>", "core.promo.demote", opts = { desc = "Demote Object (Recursively)" } },
{ "<M-CR>", "core.itero.next-iteration", "<CR>", opts = { desc = "Continue Object" } },
{ "<M-d>", "core.tempus.insert-date-insert-mode", opts = { desc = "Insert Date" } },
},

-- TODO: Readd these
Expand All @@ -137,14 +137,14 @@ module.config.public = {
{
"j",
"core.integrations.treesitter.next.heading",
opts = { desc = "[neorg] Move to Next Heading" },
opts = { desc = "Move to Next Heading" },
},

-- Move to the previous heading in the document
{
"k",
"core.integrations.treesitter.previous.heading",
opts = { desc = "[neorg] Move to Previous Heading" },
opts = { desc = "Move to Previous Heading" },
},
},
}, {
Expand All @@ -156,13 +156,13 @@ module.config.public = {
keybinds.map_event_to_mode("traverse-link", {
n = {
-- Move to the next link in the document
{ "j", "core.integrations.treesitter.next.link", opts = { desc = "[neorg] Move to Next Link" } },
{ "j", "core.integrations.treesitter.next.link", opts = { desc = "Move to Next Link" } },

-- Move to the previous link in the document
{
"k",
"core.integrations.treesitter.previous.link",
opts = { desc = "[neorg] Move to Previous Link" },
opts = { desc = "Move to Previous Link" },
},
},
}, {
Expand All @@ -173,13 +173,13 @@ module.config.public = {
-- Map the below keys on presenter mode
keybinds.map_event_to_mode("presenter", {
n = {
{ "<CR>", "core.presenter.next_page", opts = { desc = "[neorg] Next Page" } },
{ "l", "core.presenter.next_page", opts = { desc = "[neorg] Next Page" } },
{ "h", "core.presenter.previous_page", opts = { desc = "[neorg] Previous Page" } },
{ "<CR>", "core.presenter.next_page", opts = { desc = "Next Page" } },
{ "l", "core.presenter.next_page", opts = { desc = "Next Page" } },
{ "h", "core.presenter.previous_page", opts = { desc = "Previous Page" } },

-- Keys for closing the current display
{ "q", "core.presenter.close", opts = { desc = "[neorg] Close Presentation" } },
{ "<Esc>", "core.presenter.close", opts = { desc = "[neorg] Close Presentation" } },
{ "q", "core.presenter.close", opts = { desc = "Close Presentation" } },
{ "<Esc>", "core.presenter.close", opts = { desc = "Close Presentation" } },
},
}, {
silent = true,
Expand All @@ -190,18 +190,18 @@ module.config.public = {
-- Apply the below keys to all modes
keybinds.map_to_mode("all", {
n = {
{ leader .. "mn", "<cmd>Neorg mode norg<CR>", opts = { desc = "[neorg] Enter Norg Mode" } },
{ leader .. "mn", "<cmd>Neorg mode norg<CR>", opts = { desc = "Enter Norg Mode" } },
{
leader .. "mh",
"<cmd>Neorg mode traverse-heading<CR>",
opts = { desc = "[neorg] Enter Heading Traversal Mode" },
opts = { desc = "Enter Heading Traversal Mode" },
},
{
leader .. "ml",
"<cmd>Neorg mode traverse-link<CR>",
opts = { desc = "[neorg] Enter Link Traversal Mode" },
opts = { desc = "Enter Link Traversal Mode" },
},
{ "gO", "<cmd>Neorg toc split<CR>", opts = { desc = "[neorg] Open a Table of Contents" } },
{ "gO", "<cmd>Neorg toc split<CR>", opts = { desc = "Open a Table of Contents" } },
},
}, {
silent = true,
Expand Down
4 changes: 4 additions & 0 deletions lua/neorg/modules/core/keybinds/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ module.public = {
local opts = data.opts or {}
opts.buffer = buf

if opts.desc and not vim.startswith(opts.desc, "[neorg]") then
opts.desc = "[neorg] " .. opts.desc
end

vim.keymap.set(mode, key, data.command, opts)
end
end)
Expand Down

0 comments on commit c72f114

Please sign in to comment.