Map ObsidianExtractNote in neovim

43 Views Asked by At

I'm trying to map <leader>ox to call ObsidianExtractNote from obsidian.nvim plugin

vim.keymap.set('x', '<leader>ox', '<cmd>ObsidianExtractNote<cr>')

When I just call :ObsidianExtractNote in command mode it prompts to name a new note and works just fine.

But pressing <leader>ox fails with an error:

attempt to index local 'new_id'

I also tried to map this command with a constant name to avoid the prompt:

vim.keymap.set('x', '<leader>ox', '<cmd>ObsidianExtractNote note_name<cr>')

But this time the new error occurred:

Invalid 'start_col': out of range
1

There are 1 best solutions below

0
Anton On

Finally found a solution.

I thought that <cmd> and : are equals but they are not. <cmd> doesn't change mode instead of :.

After changing mapping to vim.keymap.set('x', '<leader>ox', ':ObsidianExtractNote<cr>') all errors are gone.