Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Added `opts.follow_img_func` option for customizing how to handle image paths.
- Added better handling for undefined template fields, which will now be prompted for.
- Added :ObsidianToggleCheckboxReverse command. This command goes in reverse order compared to the :ObsidianToggleCheckbox.

### Changed

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ _Keep in mind this plugin is not meant to replace Obsidian, but to complement it

- `:ObsidianToggleCheckbox` to cycle through checkbox options.

- `:ObsidianToggleCheckboxReverse` to cycle through checkbox options in a reverse order.

- `:ObsidianNewFromTemplate [TITLE]` to create a new note from a template in the templates folder. Selecting from a list using your preferred picker.
This command has one optional argument: the title of the new note.

Expand Down
3 changes: 3 additions & 0 deletions lua/obsidian/commands/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local iter = require("obsidian.itertools").iter
local command_lookups = {
ObsidianCheck = "obsidian.commands.check",
ObsidianToggleCheckbox = "obsidian.commands.toggle_checkbox",
ObsidianToggleCheckboxReverse = "obsidian.commands.toggle_checkbox_reverse",
ObsidianToday = "obsidian.commands.today",
ObsidianYesterday = "obsidian.commands.yesterday",
ObsidianTomorrow = "obsidian.commands.tomorrow",
Expand Down Expand Up @@ -170,6 +171,8 @@ M.register("ObsidianFollowLink", { opts = { nargs = "?", desc = "Follow referenc

M.register("ObsidianToggleCheckbox", { opts = { nargs = 0, desc = "Toggle checkbox" } })

M.register("ObsidianToggleCheckboxReverse", { opts = { nargs = 0, desc = "Toggle checkbox in reverse order" } })

M.register("ObsidianWorkspace", { opts = { nargs = "?", desc = "Check or switch workspace" } })

M.register(
Expand Down
10 changes: 10 additions & 0 deletions lua/obsidian/commands/toggle_checkbox_reverse.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
local toggle_checkbox = require("obsidian.util").toggle_checkbox

---@param client obsidian.Client
return function(client)
local checkboxes = vim.tbl_keys(client.opts.ui.checkboxes)
table.sort(checkboxes, function(a, b)
return (client.opts.ui.checkboxes[a].order or 1000) > (client.opts.ui.checkboxes[b].order or 1000)
end)
toggle_checkbox(checkboxes)
end