Concealing wikilink with note's title #228
Replies: 4 comments 6 replies
-
Populating content based on information from diagnostic is an interesting idea, thanks for sharing! Adding the changes needed here as a reference in case the fork goes away:
---@param node render.md.Node
---@return string?
function Context:get_diagnostic(node)
local row, col = node.start_row, node.start_col
local diagnostics = vim.diagnostic.get(self.buf, {
severity = vim.diagnostic.severity.HINT,
})
for _, diagnostic in pairs(diagnostics) do
if diagnostic.col == col and diagnostic.lnum == row then
return diagnostic.message
end
end
return nil
end |
Beta Was this translation helpful? Give feedback.
-
look like this fork has some merge conflicts. @MeanderingProgrammer Do you think we can get this merged to upstream, so we don't run into an outdated fork again? |
Beta Was this translation helpful? Give feedback.
-
I've implemented a version of this here: 0df6719, which takes inspiration from your PR. Unless more use cases crop up I wanted to keep the diagnostics specific logic out of the repo, but still enable the feature. After updating you'll need to set something like this as your configuration: require('render-markdown').setup({
change_events = { 'DiagnosticChanged' },
link = {
wiki = {
body = function(ctx)
local diagnostics = vim.diagnostic.get(ctx.buf, {
lnum = ctx.row,
severity = vim.diagnostic.severity.HINT,
})
for _, diagnostic in ipairs(diagnostics) do
if diagnostic.col == ctx.start_col and diagnostic.source == 'zk' then
return diagnostic.message
end
end
return nil
end,
},
},
}) |
Beta Was this translation helpful? Give feedback.
-
Rather than returning the alias when The behavior of rendering When the returned value is The difference is when body returns a self.marks:add_over('link', self.node, {
virt_text = { { icon .. body, highlight } },
virt_text_pos = 'inline',
conceal = '',
]}, { 0, 1, 0, -1 }) Which hides the entire node and Compare this to the alternative: self.marks:add(true, self.node.start_row, ctx.start_col + 2, {
end_col = ctx.start_col + 2 + #ctx.destination + 1,
conceal = '',
}) Which doesn't inline text and instead conceals a the range corresponding to the destination. |
Beta Was this translation helpful? Give feedback.
-
I use
render-markdown.nvim
with zk-nvim for my notes.zk-nvim
provides title of a note in diagnostics. I wanted to conceal wikilink with that title and made a fork that does it.without fork
with fork
Beta Was this translation helpful? Give feedback.
All reactions