Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
TwIStOy committed Apr 25, 2024
1 parent 47f2df1 commit e07a3bb
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions lua/dotvim/pkgs/editor/plugins/obsidian.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,39 @@ return {
end
return out
end,
callbacks = {
enter_note = function(client, note)
local util = require("obsidian.util")
local vault_name = client:vault_name()
local path =
tostring(client:vault_relative_path(note.path, { strict = true }))
local encoded_vault = util.urlencode(vault_name)
local encoded_path = util.urlencode(path)
local line = vim.api.nvim_win_get_cursor(0)[1] or 1
local uri = ("obsidian://advanced-uri?vault=%s&filepath=%s&line=%i&viewmode=preview"):format(
encoded_vault,
encoded_path,
line
)
uri = vim.fn.shellescape(uri)
local cmd = "open"
local args = { "-a", "/Applications/Obsidian.app", "--background", uri }
local cmd_with_args = cmd .. " " .. table.concat(args, " ")
vim.fn.jobstart(cmd_with_args, {
on_exit = function(_, exit_code)
if exit_code ~= 0 then
vim.notify(
("open command failed with exit code '%s': %s"):format(
exit_code,
cmd_with_args
),
vim.log.levels.ERROR
)
end
end,
})
end,
},
yaml_parser = "yq",
},
}

0 comments on commit e07a3bb

Please sign in to comment.