obsidian.nvim
obsidian.nvim copied to clipboard
A setting in the config to make ObsidianLink default to opening the picker when a note to link to does not exist
🚀 The feature, motivation and pitch
Pretty much the title. What i do now is:
{ "<leader>l", ObsidianLinkWithCheck, mode = "v", ft = "markdown" },
{ "<leader>l", function() vim.cmd("normal! viw") ObsidianLinkWithCheck() end, mode = "n", ft = "markdown" },
local function ObsidianLinkWithCheck()
local current_line = vim.api.nvim_get_current_line()
vim.cmd("ObsidianLink")
local check_line = vim.schedule_wrap(function()
local new_line = vim.api.nvim_get_current_line()
if new_line == current_line then
vim.cmd("ObsidianLink .md")
end
end)
vim.defer_fn(check_line, 1)
end
Alternatives
No response
Additional context
No response
Hey @DRKolev-code, sure, happy to accept a PR with this. The best way to add this would be to update the logic here:
https://github.com/epwalsh/obsidian.nvim/blob/16e98b45b6755222fe74a6b778c958d26bf61edd/lua/obsidian/client.lua#L683
Instead of returning early here, you could call picker:find_notes().
Will try to do one these days. :)