Skip to content
Closed
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `should_write` option on `Note.create` is removed. Call `note:write {}` explicitly instead.

### Fixed

- Backlink command supports 3rd party "quickfix/qf" pickers. No dual windows. Auto enter parent link unless parents > 1. Parents < 1 no empty quickpick window.
- Preserve anchors and blocks when creating notes from unresolved links.
- WIP: proper async jobs and no `block_on` calls which performs bad on windows.
- snacks picker now honors `picker.note_mappings.new` (and any other query mappings) for `find_files`, `grep` and `pick`, so creating a new note from the typed query (e.g. `<C-x>`) works on par with the telescope/fzf integrations.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ There's one entry point user command for this plugin: `Obsidian`

- `:Obsidian backlinks` - get a picker list of references to the current note
- `grr`/`vim.lsp.buf.references` to see references in quickfix list
- no supports 3rd party pickers see CHANGELOG.MD
- `:Obsidian follow_link [STRATEGY]` - follow a note reference under the cursor
- available strategies: `vsplit, hsplit, vsplit_force, hsplit_force`
- If the link does not exist, you will be prompted to create it. If you choose to create it, the link in the buffer will be automatically updated with the new note's ID and alias.
Expand Down
16 changes: 15 additions & 1 deletion lua/obsidian/commands/backlinks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,24 @@ local obsidian = require "obsidian"
return function()
require "obsidian.lsp.handlers._references"(nil, { tag = false }, function(_, locations)
local items = vim.lsp.util.locations_to_items(locations, "utf-8")
if #items == 0 then
obsidian.log.info "No backlinks"
return
end
if #items == 1 then
obsidian.api.open_note(items[1])
else
Obsidian.picker.pick(items, { prompt_title = "Resolve link" }) -- calls open_qf_entry by default
Obsidian.picker.pick(items, {
prompt_title = "Resolve link",
format_item = function(item)
return vim.fs.basename(item.filename) .. ":" .. item.lnum .. " - " .. vim.trim(item.text)
end,
callback = function(selected_item)
if selected_item then
obsidian.api.open_note(selected_item)
end
end,
})
end
end)
end
Loading