initial setup of obsidian plugin
This commit is contained in:
parent
2e2e6751fc
commit
a440c30e2e
1 changed files with 72 additions and 1 deletions
|
@ -28,7 +28,41 @@ return {
|
|||
-- Trigger completion at 2 chars.
|
||||
min_chars = 1,
|
||||
},
|
||||
|
||||
mappings = {
|
||||
-- Overrides the 'gf' mapping to work on markdown/wiki links within your vault.
|
||||
["gf"] = {
|
||||
action = function()
|
||||
return require("obsidian").util.gf_passthrough()
|
||||
end,
|
||||
opts = { noremap = false, expr = true, buffer = true },
|
||||
},
|
||||
-- paste image
|
||||
["<Space>Op"] = {
|
||||
action = function()
|
||||
return "<cmd>ObsidianPasteImg<cr>"
|
||||
end,
|
||||
opts = { noremap = false, expr = true, buffer = true },
|
||||
},
|
||||
-- Toggle check-boxes.
|
||||
["<leader>ch"] = {
|
||||
action = function()
|
||||
return require("obsidian").util.toggle_checkbox()
|
||||
end,
|
||||
opts = { buffer = true },
|
||||
},
|
||||
["<cr>"] = {
|
||||
action = function()
|
||||
return require("obsidian").util.gf_passthrough()
|
||||
end,
|
||||
opts = { buffer = true, expr = true },
|
||||
},
|
||||
["bl"] = {
|
||||
action = function()
|
||||
return "<cmd>ObsidianBacklinks<cr>"
|
||||
end,
|
||||
opts = { noremap = false, expr = true, buffer = true },
|
||||
},
|
||||
},
|
||||
new_notes_location = "current_dir",
|
||||
wiki_link_func = "use_alias_only",
|
||||
preferred_link_style = "wiki",
|
||||
|
@ -36,6 +70,43 @@ return {
|
|||
return title;
|
||||
end,
|
||||
disable_frontmatter = true,
|
||||
|
||||
-- Optional, by default when you use `:ObsidianFollowLink` on a link to an external
|
||||
-- URL it will be ignored but you can customize this behavior here.
|
||||
---@param url string
|
||||
follow_url_func = function(url)
|
||||
-- Open the URL in the default web browser.
|
||||
-- vim.fn.jobstart({ "open", url }) -- Mac OS
|
||||
vim.fn.jobstart({"xdg-open", url}) -- linux
|
||||
-- vim.cmd(':silent exec "!start ' .. url .. '"') -- Windows
|
||||
-- vim.ui.open(url) -- need Neovim 0.10.0+
|
||||
end,
|
||||
|
||||
-- Optional, by default when you use `:ObsidianFollowLink` on a link to an image
|
||||
-- file it will be ignored but you can customize this behavior here.
|
||||
---@param img string
|
||||
follow_img_func = function(img)
|
||||
-- vim.fn.jobstart { "qlmanage", "-p", img } -- Mac OS quick look preview
|
||||
vim.fn.jobstart({"xdg-open", url}) -- linux
|
||||
-- vim.cmd(':silent exec "!start ' .. url .. '"') -- Windows
|
||||
end,
|
||||
attachments = {
|
||||
-- The default folder to place images in via `:ObsidianPasteImg`.
|
||||
-- If this is a relative path it will be interpreted as relative to the vault root.
|
||||
-- You can always override this per image by passing a full path to the command instead of just a filename.
|
||||
img_folder = "images", -- This is the default
|
||||
|
||||
-- A function that determines the text to insert in the note when pasting an image.
|
||||
-- It takes two arguments, the `obsidian.Client` and an `obsidian.Path` to the image file.
|
||||
-- This is the default implementation.
|
||||
---@param client obsidian.Client
|
||||
---@param path obsidian.Path the absolute path to the image file
|
||||
---@return string
|
||||
img_text_func = function(client, path)
|
||||
path = client:vault_relative_path(path) or path
|
||||
return string.format("", path.name, path)
|
||||
end,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue