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 @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added "insert link" selection mapping in `ObsidianTags`' callback
- 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.

Expand Down
1 change: 1 addition & 0 deletions lua/obsidian/commands/tags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ local function gather_tag_picker_list(client, picker, tags)
callback = function(value)
util.open_buffer(value.path, { line = value.line, col = value.col })
end,
selection_mappings = picker:_tagged_note_selection_mappings(),
})
end)
end, { search = { sort = true } })
Expand Down
21 changes: 21 additions & 0 deletions lua/obsidian/pickers/picker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,27 @@ Picker._note_selection_mappings = function(self)
return mappings
end

--- Get selection mappings to use for `pick_tag()`'s callback note selection'.
---@return obsidian.PickerMappingTable
Picker._tagged_note_selection_mappings = function(self)
---@type obsidian.PickerMappingTable
local mappings = {}

if self.client.opts.picker.note_mappings and key_is_set(self.client.opts.picker.note_mappings.insert_link) then
mappings[self.client.opts.picker.note_mappings.insert_link] = {
desc = "insert link",
callback = function(value)
local note = Note.from_file(value.path)
local link = self.client:format_link(note, {})
vim.api.nvim_put({ link }, "", false, true)
self.client:update_ui()
end,
}
end

return mappings
end

--- Get selection mappings to use for `pick_tag()`.
---@return obsidian.PickerMappingTable
Picker._tag_selection_mappings = function(self)
Expand Down