Skip to content

Commit f732a7b

Browse files
author
zizhou teng (n451)
committed
more cleanup
1 parent 135e90e commit f732a7b

4 files changed

Lines changed: 56 additions & 43 deletions

File tree

.emmy/nvim-web-devicons.lua

Lines changed: 0 additions & 5 deletions
This file was deleted.

lua/obsidian/api.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ M.get_icon = function(path)
635635
return "󰉋"
636636
else
637637
local ok, res = pcall(function()
638+
---@diagnostic disable-next-line: unresolved-require
638639
local icon, hl_group = require("nvim-web-devicons").get_icon(path, nil, { default = true })
639640
return { icon, hl_group }
640641
end)

lua/obsidian/cache/init.lua

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,6 @@ function M.get_backend(name)
265265
return backend
266266
end
267267

268-
---@class obsidian.cache.SetupOpts
269-
---@field enabled? boolean
270-
---@field backend? string
271-
272268
---@param opts obsidian.config.CacheOpts
273269
function M.setup(opts)
274270
opts = opts or {}

lua/obsidian/commands/init.lua

Lines changed: 55 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,61 @@ end
1414
---@param is_note boolean
1515
---@return string[]
1616
local function get_commands_by_context(commands, is_visual, is_note)
17-
local choices = {}
18-
for _, config in ipairs(vim.tbl_values(commands)) do
19-
local include = true
20-
if is_visual then
21-
include = config.range ~= nil
22-
else
23-
include = config.range == nil
24-
end
25-
if include and not is_note then
26-
include = not config.note_action
27-
end
28-
if include and not Obsidian.opts.templates.enabled then
29-
include = config.name ~= "template" and config.name ~= "new_from_template"
30-
end
31-
if include and not Obsidian.opts.checkbox.enabled then
32-
include = config.name ~= "toggle_checkbox"
33-
end
34-
if include and not Obsidian.opts.daily_notes.enabled then
35-
include = config.name ~= "dailies"
36-
and config.name ~= "today"
37-
and config.name ~= "tomorrow"
38-
and config.name ~= "yesterday"
39-
end
40-
if include and not Obsidian.opts.unique_note.enabled then
41-
include = config.name ~= "unique_note"
42-
end
43-
if include and not Obsidian.opts.sync.enabled then
44-
include = config.name ~= "sync"
45-
end
46-
if include then
47-
choices[#choices + 1] = config.name
48-
end
49-
end
50-
return choices
17+
local choices = vim.tbl_values(commands)
18+
---@diagnostic disable-next-line: call-non-callable
19+
return vim
20+
.iter(choices)
21+
:filter(function(config)
22+
if is_visual then
23+
return config.range ~= nil
24+
else
25+
return config.range == nil
26+
end
27+
end)
28+
:filter(function(config)
29+
if is_note then
30+
return true
31+
else
32+
return not config.note_action
33+
end
34+
end)
35+
:filter(function(config)
36+
if not Obsidian.opts.templates.enabled then
37+
return config.name ~= "template" and config.name ~= "new_from_template"
38+
end
39+
return true
40+
end)
41+
:filter(function(config)
42+
if not Obsidian.opts.checkbox.enabled then
43+
return config.name ~= "toggle_checkbox"
44+
end
45+
return true
46+
end)
47+
:filter(function(config)
48+
if not Obsidian.opts.daily_notes.enabled then
49+
return config.name ~= "dailies"
50+
and config.name ~= "today"
51+
and config.name ~= "tomorrow"
52+
and config.name ~= "yesterday"
53+
end
54+
return true
55+
end)
56+
:filter(function(config)
57+
if not Obsidian.opts.unique_note.enabled then
58+
return config.name ~= "unique_note"
59+
end
60+
return true
61+
end)
62+
:filter(function(config)
63+
if not Obsidian.opts.sync.enabled then
64+
return config.name ~= "sync"
65+
end
66+
return true
67+
end)
68+
:map(function(config)
69+
return config.name
70+
end)
71+
:totable()
5172
end
5273
function M.show_menu(data)
5374
local is_visual, is_note = data.range ~= 0, in_note()

0 commit comments

Comments
 (0)