Skip to content
Discussion options

You must be logged in to vote

Oh, that helped, thanks! I did this approach, without need for autocmds

pre_write_note = function(client, note)
	-- Anchor, two lines after which to find placholder
	local parent_anchor = "#up"
	-- Placeholder to overwrite with parent link
	local parent_placeholder = "#TODO: parent if exists"

	local backs = client:find_backlinks(note)
	if #backs ~= 1 then
		return
	end
	local parent = backs[1]
	local id, alias = parent.note.id, parent.note.aliases[1]
	local anchor = note:resolve_anchor_link(parent_anchor)
	if anchor == nil then
		return
	end
	local anchor_line_number = anchor.line
	local anchor_line =
		vim.api.nvim_buf_get_lines(0, anchor_line_number + 1, anchor_line_number + 2, false)[…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Anaritus
Comment options

Answer selected by Anaritus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants