@@ -11,5 +11,85 @@ return {
11
11
return not vim .g .neovide
12
12
end ,
13
13
},
14
+ {
15
+ " alpha-nvim" ,
16
+ opts = function (_ , opts )
17
+ --- @type dora.lib
18
+ local lib = require (" dora.lib" )
19
+
20
+ --- @param sc string
21
+ --- @param txt string | fun (): string
22
+ --- @param callback string | fun (): any
23
+ --- @param bopts ? table
24
+ local function make_button (sc , txt , callback , bopts )
25
+ bopts = bopts or {}
26
+ local on_press = lib .func .normalize_callback (
27
+ callback ,
28
+ vim .F .if_nil (bopts .feedkeys , true )
29
+ )
30
+ bopts = vim .tbl_extend (" force" , {
31
+ position = " center" ,
32
+ shortcut = sc ,
33
+ cursor = 3 ,
34
+ width = 50 ,
35
+ align_shortcut = " right" ,
36
+ hl_shortcut = " Keyword" ,
37
+ keymap = {
38
+ " n" ,
39
+ sc ,
40
+ " " ,
41
+ {
42
+ noremap = true ,
43
+ silent = true ,
44
+ nowait = true ,
45
+ callback = function ()
46
+ on_press ()
47
+ end ,
48
+ },
49
+ },
50
+ }, bopts )
51
+ return {
52
+ type = " button" ,
53
+ val = txt ,
54
+ on_press = bopts .keymap [4 ].callback ,
55
+ opts = bopts ,
56
+ }
57
+ end
58
+
59
+ table.insert (
60
+ opts .layout [6 ].val ,
61
+ 4 ,
62
+ make_button (" u" , " Update Plugins" , " :Lazy update<CR>" )
63
+ )
64
+
65
+ local function make_fortune_text ()
66
+ local stats = require (" lazy" ).stats ()
67
+ return string.format (
68
+ " %d/%d plugins loaded in %dms" ,
69
+ stats .loaded ,
70
+ stats .count ,
71
+ stats .startuptime
72
+ )
73
+ end
74
+
75
+ local vault_dir = function ()
76
+ return vim .F .if_nil (
77
+ lib .lazy .opts (" obsidian.nvim" ).dir ,
78
+ vim .fn .expand (" ~/obsidian-data" )
79
+ )
80
+ end
81
+
82
+ if vim .uv .fs_stat (vault_dir ()) then
83
+ table.insert (
84
+ opts .layout [6 ].val ,
85
+ 5 ,
86
+ make_button (" t" , " Today Note" , " :ObsidianToday<CR>" )
87
+ )
88
+ end
89
+
90
+ opts .layout [8 ].val = make_fortune_text
91
+ opts .layout [8 ].opts .hl = " Function"
92
+ end ,
93
+ },
14
94
},
15
95
}
0 commit comments