-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ObsidianLink and ObsidianLinkNew misbehave when called from a keybind #372
Comments
Hey @kohotli, have you tried this: local map = vim.keymap.set
map("v", "<leader>Ole", function()
- vim.cmd("ObsidianLink")
+ vim.cmd("'<,'>ObsidianLink")
end)
map("v", "<leader>Oln", function()
- vim.cmd("ObsidianLinkNew")
+ vim.cmd("'<,'>ObsidianLinkNew")
end) |
Just tried it, I now get a different error when I highlight something for the first time:
And then it behaves the same as previously indicated in this issue (i.e. it makes a link of the previously highlighted text, not what's currently highlighted) |
@kohotli, I stumbled upon something similar and have some notes here: The marks that The whole visual selection, keymap, user command situation is a bit messy IMO. A workaround from my obsidian configuration (with lazy): return {
"epwalsh/obsidian.nvim",
keys = {
{
"<cr>",
-- leave visual mode to set marks and make ObsidianLink command work
":ObsidianLink<cr>",
desc = "Search link",
ft = "markdown",
mode = "v",
},
},
} Some related links that might be helpful if we want to improve this in Here is an implementation of a user command in a different plugin which seems to work for this scenario: And |
@epwalsh This fixes my problem! Thanks much for taking care of that :D |
Yay! |
🐛 Describe the bug
I have ObsidianLink and ObsidianLinkNew bound to keys, and when I try to use them while having a keybind, the first time I use them they throw an error:
Even while I have text selected. If I clear my visual selection, select a different block of text, then use either command, they will perform the expected operation on the previously selected block.
Here's how I have these commands mapped:
However, if I just call the commands by hitting colon and typing the commands in, they work as expected.
I'm using lazy.nvim as my plugin manager and have the version set to "*". Neovim version is 0.9.5 release, though this behavior remains the same as of the latest dev build of neovim.
Thanks in advance!
Versions
The text was updated successfully, but these errors were encountered: