"Error: no such mapping" appearing with obsidian shortcuts
santiyounger opened this issue · 9 comments
Hey,
thank you so much for making this, if it wasn't for this I don't think vim would be this great in Obsidian. Really appreciate your hard work.
I started to realize that after using obsidian shortcuts this plug in seems to return Error: no such mapping.
at the bottom of the screen
When do I get this error
I get this error with most obsidian shortcuts, such as: "navigate back" "open random note" "open today's note" the error appear when using the shortcuts, as well as when using these commands from the command palette.
it doesn't cause any conflicts, but it's distracting, specially since I record tutorials and I don't want that message popping up all the time and confusing people.
I'm happy with workarounds if necessary, perhaps I can think of something in obsidian.css to hide that message somehow perhaps.
Not sure if this is a bug, since it's actually detecting that it's not a vim shortcut, but in practicality it'd be nice to remove the error somehow.
Specs:
Obsidian v 0.9.11
Obsidian vimrc 0.1.0
Manjaro Linux x86_64 with Awesome Window Manager
Thanks!
I spent quite a while trying to recreate this with no success. I expect to be able to, since my configuration is quite similar to yours! (just i3wm instead of Awesome :) )
Can you maybe...
- Verify this behavior stops when you disable the Vimrc plugin and starts again when you enable it,
- Turn off other non-default plugins in case there's a conflict with something I don't have?
And most importantly, knowing what's in your vimrc might make the difference.
Here's another insight: I suspect this error is coming from the CodeMirror Vim module (vim.js line 4776 in the unmap
function). It seems to be shown when unmap
is called for a nonexistent mapping. Does this make sense with something in your configuration?
hey @esm7 thanks for taking a look at this I appreciate it
you were right
This is what I have in my .obsidian.vimrc
nmap H ^
nmap L $
nmap j gj
nmap k gk
unmap <C-c>
if I get rid of unmap <C-c>
the error message doesn't display anymore.
I should have included that info, I didn't realize that's what it was.
I understand it's a conflict with code mirror I use unmap <C-c>
so that I can use copy ctrl+c
while in vim mode, are you aware of any possible way to keep the unmap of ctrl+c
in the .obsidian.vimrc without displaying the error?
If not, dont worry, I really appreciate the help, and the great plugin!
I'm having the same issue. It appears that this plugin is running the .vimrc
file every time we switch between notes, which in my own workflow is quite often. I'm able to get around this by manually running the command every time I start Obsidian, but it would be nice to have this functionality in .vimrc
without the annoying error message. One possibility would be to change how the plugin interacts with the API so it only runs at startup. There may also be a way to suppress the error messages.
I can have the plugin load less often (it's made this way because it was the easy way around and I saw no side-effects to it), and I can probably also catch the exception, but I wonder if we can tackle the root cause. One thing I'm trying to figure out, is what do you gain from having the unmap
at your vimrc? To my understanding, CodeMirror outputs the error because the keymap (in the example above <C-c>
) is not mapped to anything, so unmapping it has no effect except an error message.
Wouldn't you rather map <C-c>
to y
or yy
?
Ignore the last comment for now please, I think I understand the issue and will work on a fix.
Should be fixed in version 0.1.1, please update and let me know.
thank you so much @esm7 it works perfect for me on 0.1.1 Appreciate your hard work, your plugin is the best thing that could happen to an addicted vim user! Back when I started in Obsidian I only gave it a chance due to the fact that it supports vim mode, but it had annoyances that thanks to you, now things work great!