obsidian.nvim icon indicating copy to clipboard operation
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

Open DRKolev-code opened this issue 1 year ago • 2 comments

🚀 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

DRKolev-code avatar Apr 24 '24 06:04 DRKolev-code

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().

epwalsh avatar Apr 30 '24 23:04 epwalsh

Will try to do one these days. :)

DRKolev-code avatar May 01 '24 07:05 DRKolev-code