Skip to content

Commit e9beded

Browse files
committed
feat: init dora.nvim usage
1 parent 90ce1f7 commit e9beded

File tree

3 files changed

+186
-0
lines changed

3 files changed

+186
-0
lines changed

lua/dotvim/init.lua

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
local function install_missing_dora()
2+
local dora_path = vim.fn.stdpath("data") .. "/lazy/dora.nvim"
3+
4+
if not vim.uv.fs_stat(dora_path) then
5+
vim
6+
.system({
7+
"git",
8+
"clone",
9+
"https://github.com/TwIStOy/dora.nvim.git",
10+
dora_path,
11+
})
12+
:wait()
13+
end
14+
15+
vim.opt.rtp:prepend(dora_path)
16+
end
17+
18+
local M = {}
19+
20+
function M.setup(opts)
21+
install_missing_dora()
22+
23+
---@class dora
24+
local dora = require("dora")
25+
26+
opts = opts or {}
27+
28+
opts.packages = {
29+
"dora.packages._builtin",
30+
"dora.packages.coding",
31+
"dora.packages.editor",
32+
"dora.packages.treesitter",
33+
"dora.packages.lsp",
34+
"dora.packages.ui",
35+
"dora.packages.extra.ui",
36+
"dora.packages.extra.misc.tools",
37+
"dora.packages.extra.misc.darwin",
38+
"dora.packages.extra.editor",
39+
"dora.packages.extra.lang.cpp",
40+
"dora.packages.extra.lang.cmake",
41+
"dora.packages.extra.lang.lua",
42+
"dora.packages.extra.lang.latex",
43+
"dora.packages.extra.lang.markdown",
44+
"dora.packages.extra.lang.python",
45+
"dora.packages.extra.lang.rust",
46+
"dora.packages.extra.lang.dart",
47+
"dora.packages.extra.lang.swift",
48+
"dora.packages.extra.lang.typescript",
49+
"dora.packages.extra.lang.nix",
50+
"dora.packages.extra.misc.competitive-programming",
51+
"dora.packages.extra.obsidian",
52+
"dora.packages.extra.misc.copilot",
53+
"dora.packages.extra.misc.wakatime",
54+
"dora.packages.extra.misc.rime",
55+
56+
"dotvim.packages.obsidian",
57+
"dotvim.packages.lsp",
58+
}
59+
60+
dora.setup(opts)
61+
62+
vim.cmd("colorscheme catppuccin")
63+
end
64+
65+
return M

lua/dotvim/packages/lsp.lua

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---@type dora.core.package.PackageOption
2+
return {
3+
name = "dotvim.packages.lsp",
4+
deps = {
5+
"dora.packages.extra.lsp",
6+
},
7+
plugins = {
8+
{
9+
"aerial.nvim",
10+
opts = function(_, opts)
11+
local function post_parse_symbol(_, _item, ctx)
12+
local function merge_nested_namespaces(item)
13+
if
14+
item.kind == "Namespace"
15+
and #item.children == 1
16+
and item.children[1].kind == "Namespace"
17+
and item.lnum == item.children[1].lnum
18+
and item.end_lnum == item.children[1].end_lnum
19+
then
20+
item.name = item.name .. "::" .. item.children[1].name
21+
item.children = item.children[1].children
22+
for _, child in ipairs(item.children) do
23+
child.parent = item
24+
child.level = item.level + 1
25+
end
26+
merge_nested_namespaces(item)
27+
end
28+
end
29+
if ctx.backend_name == "lsp" and ctx.lang == "clangd" then
30+
merge_nested_namespaces(_item)
31+
end
32+
return true
33+
end
34+
35+
opts.post_parse_symbol = post_parse_symbol
36+
end,
37+
},
38+
},
39+
}

lua/dotvim/packages/obsidian.lua

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
local default_vault_path = {
2+
"~/Documents/Main",
3+
"~/Projects/obsidian-data/Main",
4+
}
5+
6+
local function resolve_obsidna_vault()
7+
for _, path in ipairs(default_vault_path) do
8+
local p = vim.fn.resolve(vim.fn.expand(path))
9+
if vim.fn.isdirectory(p) == 1 then
10+
return p
11+
end
12+
end
13+
return vim.fn.resolve(vim.fn.expand(default_vault_path[1]))
14+
end
15+
16+
---@type dora.core.package.PackageOption
17+
return {
18+
name = "dotvim.packages.obsidian",
19+
deps = {
20+
"dora.packages.extra.obsidian",
21+
},
22+
plugins = {
23+
{
24+
"obsidian.nvim",
25+
opts = {
26+
dir = resolve_obsidna_vault(),
27+
notes_subdir = "3-Resources/0-Zettel",
28+
log_level = vim.log.levels.WARN,
29+
daily_notes = {
30+
folder = "3-Resources/0-Dairy",
31+
date_format = "%Y-%m-%d",
32+
alias_format = "%B %-d, %Y",
33+
template = "Templates.nvim/daily-note.md",
34+
},
35+
new_notes_location = "notes_subdir",
36+
completion = {
37+
nvim_cmp = true,
38+
},
39+
templates = {
40+
subdir = "0-Assets",
41+
substitutions = {
42+
daily_title = function()
43+
return os.date("%B %-d, %Y")
44+
end,
45+
daily_date = function()
46+
return os.date("%Y-%m-%d")
47+
end,
48+
},
49+
},
50+
use_advanced_uri = true,
51+
mappings = {},
52+
note_id_func = function(_)
53+
return ("%0x-%04x-%4x"):format(
54+
os.time(),
55+
math.random(0, 0xffff),
56+
math.random(0, 0xffff)
57+
)
58+
end,
59+
note_frontmatter_func = function(note)
60+
local out = {
61+
id = note.id,
62+
aliases = note.aliases,
63+
tags = note.tags,
64+
lastModifiedTime = os.date("%Y-%m-%d"),
65+
}
66+
if note.metadata ~= nil and not vim.tbl_isempty(note.metadata) then
67+
for k, v in pairs(note.metadata) do
68+
if out[k] == nil then
69+
out[k] = v
70+
end
71+
end
72+
end
73+
if out["createdTime"] == nil then
74+
out["createdTime"] = out["lastModifiedTime"]
75+
end
76+
return out
77+
end,
78+
yaml_parser = "yq",
79+
},
80+
},
81+
},
82+
}

0 commit comments

Comments
 (0)