Closed devstefancho closed 1 year ago
Hey @devstefancho, it looks like this would be pretty straightforward to add. We could add an autocommand that only runs in the vault directories and sets buffer-local keymaps like this:
vim.keymap.set("n", "gf", "<cmd>ObsidianFollowLink<cr>", { buffer = true })
Actually we already have the autocommand for this:
So it's just a matter of adding this option to the config and then setting the keymaps in the lazy_setup()
function.
@epwalsh Thanks, it works only for my vault š
I have one more question this is not related with this plugin I have already have "gd" keymap with another plugin (lspsaga.nvim) and now I want "gd" keymap have more priority for obisidian only in the vault
-- Definition
keymap("<leader>gd", "<Cmd>Lspsaga lsp_finder<CR>", "[g]o to [d]efinition of usages") -- Show usages
but this obisidian load faster than lspsaga.nvim ( I've tried priority = 1
for obisidian.nvim)
return {
"epwalsh/obsidian.nvim",
config = function()
require("obsidian").setup({
dir = "~/iCloud/Documents/my-vault",
daily_notes = {
folder = "daily",
},
})
vim.keymap.set("n", "<M-o>", "<Cmd>ObsidianQuickSwitch<CR>", { desc = "[Obsidian] Quick Search" })
vim.keymap.set("n", "gd", "<cmd>ObsidianFollowLink<cr>", { buffer = true }) -- Perfectly Work
end,
lazy = false,
}
@devstefancho I think the issue is that you have lazy = false
. Have you tried something like this:
return {
"epwalsh/obsidian.nvim",
config = function()
require("obsidian").setup({
dir = "~/iCloud/Documents/my-vault",
daily_notes = {
folder = "daily",
},
})
vim.keymap.set("n", "<M-o>", "<Cmd>ObsidianQuickSwitch<CR>", { desc = "[Obsidian] Quick Search" })
vim.keymap.set("n", "gd", "<cmd>ObsidianFollowLink<cr>", { buffer = true }) -- Perfectly Work
end,
lazy = true,
event = { "BufReadPre " .. vim.fn.expand "~" .. "/iCloud/Documents/my-vault/**.md" },
}
@epwalsh Thanks! It work, Setting lazy to true then I load :Lazy load obsidian.nvim
which is overriding previous global keymap
but this keymap is only applied to the first opened buffer,
now I need to figure out myself why BufReadPre is not working.
so I better to close this issue and will update more comment with my solution
š The feature, motivation and pitch
It would be great If I can use custom mappings in the Vault For example gd for FollowLink and Enter for creating new link and go into new file (this feature is in vimwiki)
mappings are possible in telescope and also other popular plugins I have no knowlege for creating this stuff, but it would be great If I can defined mappings to using only for the Vault
Alternatives
Another solution is just binding with cmd to another keymap. but when I work in the Vault, most files are markdown so I don't need to use "go to definition"(gd) so In this case, I want to override this only in Vault
Additional context
No response