Skip to content

Commit ca86b59

Browse files
feat: add scope_highlight to wiki config
## Details Adds `link.wiki.scope_highlight` option, `nil` by default. When set the body of the wiki link will have the corresponding highlight group applied to it.
1 parent 146d4ff commit ca86b59

File tree

6 files changed

+17
-1
lines changed

6 files changed

+17
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ require('render-markdown').setup({
775775
return nil
776776
end,
777777
highlight = 'RenderMarkdownWikiLink',
778+
scope_highlight = nil,
778779
},
779780
-- Define custom destination patterns so icons can quickly inform you of what a link
780781
-- contains. Applies to 'inline_link', 'uri_autolink', and wikilink nodes. When multiple
@@ -1503,6 +1504,7 @@ require('render-markdown').setup({
15031504
return nil
15041505
end,
15051506
highlight = 'RenderMarkdownWikiLink',
1507+
scope_highlight = nil,
15061508
},
15071509
-- Define custom destination patterns so icons can quickly inform you of what a link
15081510
-- contains. Applies to 'inline_link', 'uri_autolink', and wikilink nodes. When multiple

doc/render-markdown.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,7 @@ Default Configuration ~
841841
return nil
842842
end,
843843
highlight = 'RenderMarkdownWikiLink',
844+
scope_highlight = nil,
844845
},
845846
-- Define custom destination patterns so icons can quickly inform you of what a link
846847
-- contains. Applies to 'inline_link', 'uri_autolink', and wikilink nodes. When multiple
@@ -1549,6 +1550,7 @@ Link Configuration ~
15491550
return nil
15501551
end,
15511552
highlight = 'RenderMarkdownWikiLink',
1553+
scope_highlight = nil,
15521554
},
15531555
-- Define custom destination patterns so icons can quickly inform you of what a link
15541556
-- contains. Applies to 'inline_link', 'uri_autolink', and wikilink nodes. When multiple

lua/render-markdown/config/link.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
---@field icon string
2626
---@field body fun(ctx: render.md.link.Context): render.md.mark.Text|string?
2727
---@field highlight string
28+
---@field scope_highlight? string
2829

2930
---@class (exact) render.md.link.custom.Config
3031
---@field pattern string
@@ -74,6 +75,7 @@ M.default = {
7475
return nil
7576
end,
7677
highlight = 'RenderMarkdownWikiLink',
78+
scope_highlight = nil,
7779
},
7880
-- Define custom destination patterns so icons can quickly inform you of what a link
7981
-- contains. Applies to 'inline_link', 'uri_autolink', and wikilink nodes. When multiple
@@ -118,6 +120,7 @@ function M.validate(spec)
118120
wiki:type('icon', 'string')
119121
wiki:type('body', 'function')
120122
wiki:type('highlight', 'string')
123+
wiki:type('scope_highlight', { 'string', 'nil' })
121124
wiki:check()
122125
end)
123126
spec:nested('custom', function(patterns)

lua/render-markdown/health.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local state = require('render-markdown.state')
55
local M = {}
66

77
---@private
8-
M.version = '8.7.5'
8+
M.version = '8.7.6'
99

1010
function M.check()
1111
M.start('versions')

lua/render-markdown/render/common/wiki.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ function Render:run()
5454
virt_text = { icon },
5555
virt_text_pos = 'inline',
5656
})
57+
-- apply scope highlight
58+
local highlight = self.config.scope_highlight
59+
if highlight then
60+
self.marks:add('link', row, start_col, {
61+
end_col = end_col,
62+
hl_group = highlight,
63+
})
64+
end
5765
-- hide destination if there is an alias
5866
if alias then
5967
self:hide(start_col, #destination + 1)

lua/render-markdown/types.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@
216216
---@field icon? string
217217
---@field body? fun(ctx: render.md.link.Context): render.md.mark.Text|string?
218218
---@field highlight? string
219+
---@field scope_highlight? string
219220

220221
---@class (exact) render.md.link.custom.UserConfig
221222
---@field pattern? string

0 commit comments

Comments
 (0)