-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configurable backlinks view - telescope picker and/or vsplit #374
Comments
For a) one would have to make the From the user's perspective it cold look something like this: backlinks = {
view_strategy = "vsplit", -- vsplit|split|tabnew
...
} |
This is easy enough to support. I'd be happy to review a PR with your suggestion.
The Lua API for gathering backlinks is close to being stable. Once it's stable it would be easy enough for users to pipe that into telescope. And that would be a great example to add to the cookbook. |
I'm not sure if I have the time right now to implement this. So, anybody, feel free grab this one 👍 I also might wait for the stable API and then use telescope directly. |
Sounds good... there's not too much left to do to stabilize the API, I just want to move the functionality into a If you don't hear back from me about this within a week or two feel free to ping me. |
Ok, it's now pretty straightforward to create your own command for this. Here's a snippet: ---@type obsidian.Client
local client = require("obsidian").get_client()
local note = assert(client:resolve_note "OLMo research hub") -- replace with name or ID of your note
client:find_backlinks_async(note, true, function(backlinks)
local items = {}
for _, matches in ipairs(backlinks) do
local path = client:vault_relative_path(matches.path)
for _, match in ipairs(matches.matches) do
items[#items + 1] = {
value = { path = path, line = match.line },
display = string.format("%s:%s:%s", path, match.line, match.text),
ordinal = match.text,
filename = matches.path,
lnum = match.line,
}
end
end
local picker = assert(client:picker())
picker:pick(items, {
prompt_title = "Backlinks",
callback = function(value)
vim.cmd(string.format("e %s", value.path))
vim.api.nvim_win_set_cursor(0, { tonumber(value.line), 0 })
end,
})
end) I like this a lot, actually, so eventually I'm going to build this in as a configurable "view" for backlinks. |
Wow, this is actually so much better that I think I just want to make this the default and get rid of the current "location list" view. Of course with telescope you can always open a location list with the search results anyway. |
Instead of a "location list" buffer. Closes #374.
* Open picker for backlinks/tags location Instead of a "location list" buffer. Closes #374. * Improve filter field ("ordinal") * Consolidate code to open a buffer * improve the `open_buffer` command * Standardize how we resolve paths * Fix test * Revert change to `:vault_relative_path()` * choose picker on the fly * fix typo * Fix another bug with `Executor:map()` * Add icons and highlights * Make icons more robust
Thank so much @epwalsh. This is great! |
🚀 The feature, motivation and pitch
It would be great to have more configuration options for the backlink view. I often have many backlinks. The current implementation always opens the backlink view in a quickfix like view at the bottom and only the height is configurable.
It would be great,
a) if the view would be more configurable: use vsplit, tab, ...
b) or if the backlinks could be piped to telescope to that I can easily search and go to the notes with telescope.
(I guess a similar feature would be useful for tags as well: show all files with a given tag in telescope.)
Alternatives
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: