Skip to content
neo451 edited this page Oct 19, 2025 · 6 revisions

Create new mapping

vim.api.nvim_create_autocmd("User", {
   pattern = "ObsidianNoteEnter",
   callback = function(ev)
      vim.keymap.set("n", "<leader>ch", "<cmd>Obsidian toggle_checkbox<cr>", {
         buffer = ev.buf,
         desc = "Toggle checkbox",
      })
   end,
})

Or with the callback module:

require("obsidian").setup({
   callbacks = {
      enter_note = function(note)
         vim.keymap.set("n", "<leader>ch", "<cmd>Obsidian toggle_checkbox<cr>", {
            buffer = note.bufnr,
            desc = "Toggle checkbox",
         })
      end,
   },
})

Remove default mapping

vim.api.nvim_create_autocmd("User", {
   pattern = "ObsidianNoteEnter",
   callback = function(ev)
      vim.keymap.del("n", "<CR>", { buffer = ev.buf })
   end,
})

Or with the callback module like above.

Action functions

The plugin provides the following remappable functions:

  • smart_action
    • If cursor is on a link, follow the link
    • If cursor is on a tag, show all notes with that tag in a picker
    • If cursor is on a checkbox, toggle the checkbox
    • If cursor is on a heading, cycle the fold of that heading
  • nav_link ["next"|"prev"]
    • Will navigate cursor to next valid link in the buffer
  • set_checkbox [state]
    • If cursor is on a checkbox, set the state to the parameter given
    • If cursor is on a checkbox and no parameter was given, set the state to the next input
    • Note: Either given state or next input will have to be a valid choice in Obsidian.ui.checkboxes (if you didn't specify any you can check the README configuration for the default list of them)

Example with remapping nav_link:

require("obsidian").setup({
   callbacks = {
      enter_note = function(note)
         vim.keymap.set("n", "<Tab>", function()
            require("obsidian.api").nav_link("next")
         end, {
            buffer = note.bufnr,
            desc = "Go to next link",
         })
         vim.keymap.set("n", "<S-Tab>", function()
            require("obsidian.api").nav_link("prev")
         end, {
            buffer = note.bufnr,
            desc = "Go to previous link",
         })
      end,
   },
})
Clone this wiki locally