Loading...
Loading...
Compare original and translation side by side
return {
"obsidian-nvim/obsidian.nvim",
version = "*",
ft = "markdown",
opts = {
workspaces = {
{ name = "personal", path = "~/vaults/personal" },
},
},
}return {
"obsidian-nvim/obsidian.nvim",
version = "*",
ft = "markdown",
opts = {
workspaces = {
{ name = "personal", path = "~/vaults/personal" },
},
},
}brew install ripgrepbrew install pngpastebrew install ripgrepbrew install pngpasterequire("obsidian").setup({
-- Workspace configuration (required)
workspaces = {
{ name = "personal", path = "~/vaults/personal" },
{ name = "work", path = "~/vaults/work" },
},
-- Daily notes
daily_notes = {
folder = "daily",
date_format = "%Y-%m-%d",
alias_format = "%B %-d, %Y",
default_tags = { "daily-notes" },
},
-- Templates
templates = {
folder = "templates",
date_format = "%Y-%m-%d",
time_format = "%H:%M",
},
-- Note ID generation (Zettelkasten-style by default)
note_id_func = function(title)
local suffix = ""
if title ~= nil then
suffix = title:gsub(" ", "-"):gsub("[^A-Za-z0-9-]", ""):lower()
else
for _ = 1, 4 do
suffix = suffix .. string.char(math.random(65, 90))
end
end
return tostring(os.time()) .. "-" .. suffix
end,
-- Completion settings
completion = {
nvim_cmp = true, -- or blink = true for blink.cmp
min_chars = 2,
},
-- UI customization
ui = {
enable = true,
checkboxes = {
[" "] = { char = "", hl_group = "ObsidianTodo" },
["x"] = { char = "", hl_group = "ObsidianDone" },
},
},
})require("obsidian").setup({
-- 工作区配置(必填)
workspaces = {
{ name = "personal", path = "~/vaults/personal" },
{ name = "work", path = "~/vaults/work" },
},
-- 日常笔记设置
daily_notes = {
folder = "daily",
date_format = "%Y-%m-%d",
alias_format = "%B %-d, %Y",
default_tags = { "daily-notes" },
},
-- 模板设置
templates = {
folder = "templates",
date_format = "%Y-%m-%d",
time_format = "%H:%M",
},
-- 笔记ID生成(默认采用 Zettelkasten 风格)
note_id_func = function(title)
local suffix = ""
if title ~= nil then
suffix = title:gsub(" ", "-"):gsub("[^A-Za-z0-9-]", ""):lower()
else
for _ = 1, 4 do
suffix = suffix .. string.char(math.random(65, 90))
end
end
return tostring(os.time()) .. "-" .. suffix
end,
-- 自动补全设置
completion = {
nvim_cmp = true, -- 或设置为 blink = true 以使用 blink.cmp
min_chars = 2,
},
-- UI自定义设置
ui = {
enable = true,
checkboxes = {
[" "] = { char = "", hl_group = "ObsidianTodo" },
["x"] = { char = "", hl_group = "ObsidianDone" },
},
},
})| Command | Description |
|---|---|
| Open command picker |
| Open/create daily note |
| Create new note |
| Search vault with ripgrep |
| Fuzzy find notes |
| Show references to current note |
| Insert template |
| Switch workspace |
| 命令 | 说明 |
|---|---|
| 打开命令选择器 |
| 打开/创建今日笔记(支持偏移量) |
| 创建新笔记 |
| 使用 ripgrep 搜索 vault |
| 模糊查找笔记 |
| 显示当前笔记的引用链接 |
| 插入模板 |
| 切换工作区 |
| Command | Description |
|---|---|
| Link selection to existing note |
| Create note and link selection |
| Extract selection to new note |
| 命令 | 说明 |
|---|---|
| 将选中内容链接到已有笔记 |
| 创建新笔记并链接选中内容 |
| 将选中内容提取为新笔记 |
<CR><CR>vim.keymap.set("n", "<CR>", function()
if require("obsidian").util.cursor_on_markdown_link() then
return "<cmd>Obsidian follow_link<CR>"
else
return "<CR>"
end
end, { expr = true })vim.keymap.set("n", "<CR>", function()
if require("obsidian").util.cursor_on_markdown_link() then
return "<cmd>Obsidian follow_link<CR>"
else
return "<CR>"
end
end, { expr = true })vim.keymap.set("n", "[o", function()
require("obsidian").util.nav_link("prev")
end, { buffer = true, desc = "Previous link" })
vim.keymap.set("n", "]o", function()
require("obsidian").util.nav_link("next")
end, { buffer = true, desc = "Next link" })vim.keymap.set("n", "[o", function()
require("obsidian").util.nav_link("prev")
end, { buffer = true, desc = "上一个链接" })
vim.keymap.set("n", "]o", function()
require("obsidian").util.nav_link("next")
end, { buffer = true, desc = "下一个链接" })picker = {
name = "telescope", -- or "fzf-lua", "mini.pick", "snacks.picker"
note_mappings = {
new = "<C-x>",
insert_link = "<C-l>",
},
tag_mappings = {
tag_note = "<C-x>",
insert_tag = "<C-l>",
},
},picker = {
name = "telescope", -- 可选 "fzf-lua", "mini.pick", "snacks.picker"
note_mappings = {
new = "<C-x>",
insert_link = "<C-l>",
},
tag_mappings = {
tag_note = "<C-x>",
insert_tag = "<C-l>",
},
},completion = {
blink = true,
nvim_cmp = false,
min_chars = 2,
},completion = {
blink = true,
nvim_cmp = false,
min_chars = 2,
},completion = {
nvim_cmp = true,
blink = false,
min_chars = 2,
},[[[#completion = {
nvim_cmp = true,
blink = false,
min_chars = 2,
},[[[#| Variable | Description |
|---|---|
| Note title |
| Current date |
| Current time |
| Note ID |
| 变量 | 说明 |
|---|---|
| 笔记标题 |
| 当前日期 |
| 当前时间 |
| 笔记ID |
templates = {
folder = "templates",
substitutions = {
yesterday = function()
return os.date("%Y-%m-%d", os.time() - 86400)
end,
tomorrow = function()
return os.date("%Y-%m-%d", os.time() + 86400)
end,
},
},templates = {
folder = "templates",
substitutions = {
yesterday = function()
return os.date("%Y-%m-%d", os.time() - 86400)
end,
tomorrow = function()
return os.date("%Y-%m-%d", os.time() + 86400)
end,
},
},frontmatter = {
enabled = true,
func = function(note)
local out = { id = note.id, aliases = note.aliases, tags = note.tags }
if note.metadata ~= nil and not vim.tbl_isempty(note.metadata) then
for k, v in pairs(note.metadata) do
out[k] = v
end
end
return out
end,
sort = { "id", "aliases", "tags" },
},frontmatter = {
enabled = true,
func = function(note)
local out = { id = note.id, aliases = note.aliases, tags = note.tags }
if note.metadata ~= nil and not vim.tbl_isempty(note.metadata) then
for k, v in pairs(note.metadata) do
out[k] = v
end
end
return out
end,
sort = { "id", "aliases", "tags" },
},:checkhealth obsidian:checkhealth obsidian| Issue | Solution |
|---|---|
| Completion not working | Install ripgrep: |
| Picker not opening | Verify picker name matches installed plugin |
| Images not pasting | macOS: |
| Links not following | Ensure cursor is on |
| Checkboxes not rendering | Set |
| Workspace not found | Verify path exists and file is inside vault |
| 问题 | 解决方法 |
|---|---|
| 自动补全无法工作 | 安装 ripgrep:执行 |
| 选择器无法打开 | 确认选择器名称与已安装的插件匹配 |
| 图片无法粘贴 | macOS:执行 |
| 链接无法跳转 | 确保光标位于 |
| 复选框无法正常渲染 | 设置 |
| 工作区无法找到 | 确认路径存在且文件位于 vault 内 |
log_level = vim.log.levels.DEBUG,log_level = vim.log.levels.DEBUG,