Skip to content

Commit e174f52

Browse files
feat: configurable scope priority
## Details Request: #534 Adds `scope_priority` option to `bullet` & `checkbox` configurations. This gets set as the priority for the scope highlight extmarks. The default value is set to `nil` to avoid any changes to behavior, this results in the extmark having the default priority of `4096`. Users can configure it to a custom value to prefer showing treesitter highlights or handle other potential conflicts.
1 parent da260dd commit e174f52

File tree

7 files changed

+29
-1
lines changed

7 files changed

+29
-1
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,8 @@ require('render-markdown').setup({
583583
-- Highlight for item associated with the bullet point.
584584
-- Output is evaluated using the same logic as 'icons'.
585585
scope_highlight = {},
586+
-- Priority to assign to scope highlight.
587+
scope_priority = nil,
586588
},
587589
checkbox = {
588590
-- Checkboxes are a special instance of a 'list_item' that start with a 'shortcut_link'.
@@ -625,6 +627,8 @@ require('render-markdown').setup({
625627
custom = {
626628
todo = { raw = '[-]', rendered = '󰥔 ', highlight = 'RenderMarkdownTodo', scope_highlight = nil },
627629
},
630+
-- Priority to assign to scope highlight.
631+
scope_priority = nil,
628632
},
629633
quote = {
630634
-- Turn on / off block quote & callout rendering.
@@ -1244,6 +1248,8 @@ require('render-markdown').setup({
12441248
-- Highlight for item associated with the bullet point.
12451249
-- Output is evaluated using the same logic as 'icons'.
12461250
scope_highlight = {},
1251+
-- Priority to assign to scope highlight.
1252+
scope_priority = nil,
12471253
},
12481254
})
12491255
```
@@ -1301,6 +1307,8 @@ require('render-markdown').setup({
13011307
custom = {
13021308
todo = { raw = '[-]', rendered = '󰥔 ', highlight = 'RenderMarkdownTodo', scope_highlight = nil },
13031309
},
1310+
-- Priority to assign to scope highlight.
1311+
scope_priority = nil,
13041312
},
13051313
})
13061314
```

doc/render-markdown.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,8 @@ Default Configuration ~
645645
-- Highlight for item associated with the bullet point.
646646
-- Output is evaluated using the same logic as 'icons'.
647647
scope_highlight = {},
648+
-- Priority to assign to scope highlight.
649+
scope_priority = nil,
648650
},
649651
checkbox = {
650652
-- Checkboxes are a special instance of a 'list_item' that start with a 'shortcut_link'.
@@ -687,6 +689,8 @@ Default Configuration ~
687689
custom = {
688690
todo = { raw = '[-]', rendered = '󰥔 ', highlight = 'RenderMarkdownTodo', scope_highlight = nil },
689691
},
692+
-- Priority to assign to scope highlight.
693+
scope_priority = nil,
690694
},
691695
quote = {
692696
-- Turn on / off block quote & callout rendering.
@@ -1296,6 +1300,8 @@ Bullet Point Configuration ~
12961300
-- Highlight for item associated with the bullet point.
12971301
-- Output is evaluated using the same logic as 'icons'.
12981302
scope_highlight = {},
1303+
-- Priority to assign to scope highlight.
1304+
scope_priority = nil,
12991305
},
13001306
})
13011307
<
@@ -1351,6 +1357,8 @@ Checkbox Configuration ~
13511357
custom = {
13521358
todo = { raw = '[-]', rendered = '󰥔 ', highlight = 'RenderMarkdownTodo', scope_highlight = nil },
13531359
},
1360+
-- Priority to assign to scope highlight.
1361+
scope_priority = nil,
13541362
},
13551363
})
13561364
<

lua/render-markdown/health.lua

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

88
---@private
9-
M.version = '8.9.1'
9+
M.version = '8.9.2'
1010

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

lua/render-markdown/render/markdown/bullet.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ function Render:scope()
161161
return
162162
end
163163
self.marks:over(self.config, true, self.node:scope(), {
164+
priority = self.config.scope_priority,
164165
hl_group = highlight,
165166
})
166167
end

lua/render-markdown/render/markdown/checkbox.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ function Render:scope()
123123
return
124124
end
125125
self.marks:over(self.config, 'check_scope', self.node:scope(), {
126+
priority = self.config.scope_priority,
126127
hl_group = highlight,
127128
})
128129
end

lua/render-markdown/settings.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ M.bullet = {}
118118
---@field right_pad render.md.bullet.Integer
119119
---@field highlight render.md.bullet.String
120120
---@field scope_highlight render.md.bullet.String
121+
---@field scope_priority? integer
121122

122123
---@class (exact) render.md.bullet.Context
123124
---@field level integer
@@ -174,6 +175,8 @@ M.bullet.default = {
174175
-- Highlight for item associated with the bullet point.
175176
-- Output is evaluated using the same logic as 'icons'.
176177
scope_highlight = {},
178+
-- Priority to assign to scope highlight.
179+
scope_priority = nil,
177180
}
178181

179182
---@return render.md.Schema
@@ -198,6 +201,7 @@ function M.bullet.schema()
198201
right_pad = integer_provider,
199202
highlight = string_provider,
200203
scope_highlight = string_provider,
204+
scope_priority = { optional = true, type = 'number' },
201205
})
202206
end
203207

@@ -280,6 +284,7 @@ M.checkbox = {}
280284
---@field unchecked render.md.checkbox.component.Config
281285
---@field checked render.md.checkbox.component.Config
282286
---@field custom table<string, render.md.checkbox.custom.Config>
287+
---@field scope_priority? integer
283288

284289
---@class (exact) render.md.checkbox.component.Config
285290
---@field icon string
@@ -334,6 +339,8 @@ M.checkbox.default = {
334339
custom = {
335340
todo = { raw = '[-]', rendered = '󰥔 ', highlight = 'RenderMarkdownTodo', scope_highlight = nil },
336341
},
342+
-- Priority to assign to scope highlight.
343+
scope_priority = nil,
337344
}
338345

339346
---@return render.md.Schema
@@ -362,6 +369,7 @@ function M.checkbox.schema()
362369
unchecked = component,
363370
checked = component,
364371
custom = { map = { { type = 'string' }, custom } },
372+
scope_priority = { optional = true, type = 'number' },
365373
})
366374
end
367375

lua/render-markdown/types.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
---@field right_pad? render.md.bullet.Integer
5959
---@field highlight? render.md.bullet.String
6060
---@field scope_highlight? render.md.bullet.String
61+
---@field scope_priority? integer
6162

6263
---@alias render.md.callout.UserConfigs table<string, render.md.callout.UserConfig>
6364

@@ -75,6 +76,7 @@
7576
---@field unchecked? render.md.checkbox.component.UserConfig
7677
---@field checked? render.md.checkbox.component.UserConfig
7778
---@field custom? table<string, render.md.checkbox.custom.UserConfig>
79+
---@field scope_priority? integer
7880

7981
---@class (exact) render.md.checkbox.component.UserConfig
8082
---@field icon? string

0 commit comments

Comments
 (0)