Skip to content

Commit e099bd8

Browse files
Change default heading highlights
# Details Use `@markup.heading.*.markdown` instead of `markdownH*`. Seems supported by more colorschemes.
1 parent b84a788 commit e099bd8

File tree

11 files changed

+89
-356
lines changed

11 files changed

+89
-356
lines changed

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,14 @@ require('render-markdown').setup({
187187
backgrounds = { 'DiffAdd', 'DiffChange', 'DiffDelete' },
188188
-- The 'level' is used to index into the array using a clamp
189189
-- Highlight for the heading and sign icons
190-
foregrounds = { 'markdownH1', 'markdownH2', 'markdownH3', 'markdownH4', 'markdownH5', 'markdownH6' },
190+
foregrounds = {
191+
'@markup.heading.1.markdown',
192+
'@markup.heading.2.markdown',
193+
'@markup.heading.3.markdown',
194+
'@markup.heading.4.markdown',
195+
'@markup.heading.5.markdown',
196+
'@markup.heading.6.markdown',
197+
},
191198
},
192199
code = {
193200
-- Turn on / off code block & inline code rendering
@@ -368,7 +375,14 @@ require('render-markdown').setup({
368375
backgrounds = { 'DiffAdd', 'DiffChange', 'DiffDelete' },
369376
-- The 'level' is used to index into the array using a clamp
370377
-- Highlight for the heading and sign icons
371-
foregrounds = { 'markdownH1', 'markdownH2', 'markdownH3', 'markdownH4', 'markdownH5', 'markdownH6' },
378+
foregrounds = {
379+
'@markup.heading.1.markdown',
380+
'@markup.heading.2.markdown',
381+
'@markup.heading.3.markdown',
382+
'@markup.heading.4.markdown',
383+
'@markup.heading.5.markdown',
384+
'@markup.heading.6.markdown',
385+
},
372386
},
373387
})
374388
```

doc/render-markdown.txt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*render-markdown.txt* For 0.10.0 Last change: 2024 July 09
1+
*render-markdown.txt* For 0.10.0 Last change: 2024 July 10
22

33
==============================================================================
44
Table of Contents *render-markdown-table-of-contents*
@@ -224,7 +224,14 @@ Full Default Configuration ~
224224
backgrounds = { 'DiffAdd', 'DiffChange', 'DiffDelete' },
225225
-- The 'level' is used to index into the array using a clamp
226226
-- Highlight for the heading and sign icons
227-
foregrounds = { 'markdownH1', 'markdownH2', 'markdownH3', 'markdownH4', 'markdownH5', 'markdownH6' },
227+
foregrounds = {
228+
'@markup.heading.1.markdown',
229+
'@markup.heading.2.markdown',
230+
'@markup.heading.3.markdown',
231+
'@markup.heading.4.markdown',
232+
'@markup.heading.5.markdown',
233+
'@markup.heading.6.markdown',
234+
},
228235
},
229236
code = {
230237
-- Turn on / off code block & inline code rendering
@@ -404,7 +411,14 @@ HEADINGS *render-markdown-setup-headings*
404411
backgrounds = { 'DiffAdd', 'DiffChange', 'DiffDelete' },
405412
-- The 'level' is used to index into the array using a clamp
406413
-- Highlight for the heading and sign icons
407-
foregrounds = { 'markdownH1', 'markdownH2', 'markdownH3', 'markdownH4', 'markdownH5', 'markdownH6' },
414+
foregrounds = {
415+
'@markup.heading.1.markdown',
416+
'@markup.heading.2.markdown',
417+
'@markup.heading.3.markdown',
418+
'@markup.heading.4.markdown',
419+
'@markup.heading.5.markdown',
420+
'@markup.heading.6.markdown',
421+
},
408422
},
409423
})
410424
<

lua/render-markdown/init.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,14 @@ M.default_config = {
177177
backgrounds = { 'DiffAdd', 'DiffChange', 'DiffDelete' },
178178
-- The 'level' is used to index into the array using a clamp
179179
-- Highlight for the heading and sign icons
180-
foregrounds = { 'markdownH1', 'markdownH2', 'markdownH3', 'markdownH4', 'markdownH5', 'markdownH6' },
180+
foregrounds = {
181+
'@markup.heading.1.markdown',
182+
'@markup.heading.2.markdown',
183+
'@markup.heading.3.markdown',
184+
'@markup.heading.4.markdown',
185+
'@markup.heading.5.markdown',
186+
'@markup.heading.6.markdown',
187+
},
181188
},
182189
code = {
183190
-- Turn on / off code block & inline code rendering

tests/box_dash_quote_spec.lua

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,7 @@ async_tests.describe('box_dash_quote.md', function()
88
local expected = {}
99

1010
-- Heading
11-
vim.list_extend(expected, {
12-
{
13-
row = { 0, 1 },
14-
col = { 0, 0 },
15-
hl_eol = true,
16-
hl_group = 'DiffAdd',
17-
virt_text = { { '󰲡 ', { 'markdownH1', 'DiffAdd' } } },
18-
virt_text_pos = 'overlay',
19-
},
20-
{
21-
row = { 0, 0 },
22-
col = { 0, 1 },
23-
sign_text = '󰫎 ',
24-
sign_hl_group = 'markdownH1',
25-
},
26-
})
11+
vim.list_extend(expected, util.heading(0, 1))
2712

2813
-- Checkboxes
2914
vim.list_extend(expected, {

tests/callout_spec.lua

Lines changed: 6 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,8 @@ async_tests.describe('callout.md', function()
99
local quote = ''
1010

1111
local note_start = 0
12+
vim.list_extend(expected, util.heading(note_start, 1))
1213
vim.list_extend(expected, {
13-
-- Heading
14-
{
15-
row = { note_start, note_start + 1 },
16-
col = { 0, 0 },
17-
hl_eol = true,
18-
hl_group = 'DiffAdd',
19-
virt_text = { { '󰲡 ', { 'markdownH1', 'DiffAdd' } } },
20-
virt_text_pos = 'overlay',
21-
},
22-
{
23-
row = { note_start, note_start },
24-
col = { 0, 1 },
25-
sign_text = '󰫎 ',
26-
sign_hl_group = 'markdownH1',
27-
},
2814
-- Quote start
2915
{
3016
row = { note_start + 2, note_start + 2 },
@@ -67,22 +53,8 @@ async_tests.describe('callout.md', function()
6753
})
6854

6955
local tip_start = 8
56+
vim.list_extend(expected, util.heading(tip_start, 1))
7057
vim.list_extend(expected, {
71-
-- Heading
72-
{
73-
row = { tip_start, tip_start + 1 },
74-
col = { 0, 0 },
75-
hl_eol = true,
76-
hl_group = 'DiffAdd',
77-
virt_text = { { '󰲡 ', { 'markdownH1', 'DiffAdd' } } },
78-
virt_text_pos = 'overlay',
79-
},
80-
{
81-
row = { tip_start, tip_start },
82-
col = { 0, 1 },
83-
sign_text = '󰫎 ',
84-
sign_hl_group = 'markdownH1',
85-
},
8658
-- Quote start
8759
{
8860
row = { tip_start + 2, tip_start + 2 },
@@ -143,22 +115,8 @@ async_tests.describe('callout.md', function()
143115
})
144116

145117
local important_start = 16
118+
vim.list_extend(expected, util.heading(important_start, 1))
146119
vim.list_extend(expected, {
147-
-- Heading
148-
{
149-
row = { important_start, important_start + 1 },
150-
col = { 0, 0 },
151-
hl_eol = true,
152-
hl_group = 'DiffAdd',
153-
virt_text = { { '󰲡 ', { 'markdownH1', 'DiffAdd' } } },
154-
virt_text_pos = 'overlay',
155-
},
156-
{
157-
row = { important_start, important_start },
158-
col = { 0, 1 },
159-
sign_text = '󰫎 ',
160-
sign_hl_group = 'markdownH1',
161-
},
162120
-- Quote start
163121
{
164122
row = { important_start + 2, important_start + 2 },
@@ -183,22 +141,8 @@ async_tests.describe('callout.md', function()
183141
})
184142

185143
local warning_start = 21
144+
vim.list_extend(expected, util.heading(warning_start, 1))
186145
vim.list_extend(expected, {
187-
-- Heading
188-
{
189-
row = { warning_start, warning_start + 1 },
190-
col = { 0, 0 },
191-
hl_eol = true,
192-
hl_group = 'DiffAdd',
193-
virt_text = { { '󰲡 ', { 'markdownH1', 'DiffAdd' } } },
194-
virt_text_pos = 'overlay',
195-
},
196-
{
197-
row = { warning_start, warning_start },
198-
col = { 0, 1 },
199-
sign_text = '󰫎 ',
200-
sign_hl_group = 'markdownH1',
201-
},
202146
-- Quote start
203147
{
204148
row = { warning_start + 2, warning_start + 2 },
@@ -223,22 +167,8 @@ async_tests.describe('callout.md', function()
223167
})
224168

225169
local caution_start = 26
170+
vim.list_extend(expected, util.heading(caution_start, 1))
226171
vim.list_extend(expected, {
227-
-- Heading
228-
{
229-
row = { caution_start, caution_start + 1 },
230-
col = { 0, 0 },
231-
hl_eol = true,
232-
hl_group = 'DiffAdd',
233-
virt_text = { { '󰲡 ', { 'markdownH1', 'DiffAdd' } } },
234-
virt_text_pos = 'overlay',
235-
},
236-
{
237-
row = { caution_start, caution_start },
238-
col = { 0, 1 },
239-
sign_text = '󰫎 ',
240-
sign_hl_group = 'markdownH1',
241-
},
242172
-- Quote start
243173
{
244174
row = { caution_start + 2, caution_start + 2 },
@@ -263,22 +193,8 @@ async_tests.describe('callout.md', function()
263193
})
264194

265195
local bug_start = 31
196+
vim.list_extend(expected, util.heading(bug_start, 1))
266197
vim.list_extend(expected, {
267-
-- Heading
268-
{
269-
row = { bug_start, bug_start + 1 },
270-
col = { 0, 0 },
271-
hl_eol = true,
272-
hl_group = 'DiffAdd',
273-
virt_text = { { '󰲡 ', { 'markdownH1', 'DiffAdd' } } },
274-
virt_text_pos = 'overlay',
275-
},
276-
{
277-
row = { bug_start, bug_start },
278-
col = { 0, 1 },
279-
sign_text = '󰫎 ',
280-
sign_hl_group = 'markdownH1',
281-
},
282198
-- Quote start
283199
{
284200
row = { bug_start + 2, bug_start + 2 },

tests/custom_handler_spec.lua

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,8 @@ async_tests.describe('custom_handler.md', function()
2020
local expected = {}
2121

2222
-- Heading / inline code
23+
vim.list_extend(expected, util.heading(0, 1))
2324
vim.list_extend(expected, {
24-
{
25-
row = { 0, 1 },
26-
col = { 0, 0 },
27-
hl_eol = true,
28-
hl_group = 'DiffAdd',
29-
virt_text = { { '󰲡 ', { 'markdownH1', 'DiffAdd' } } },
30-
virt_text_pos = 'overlay',
31-
},
32-
{
33-
row = { 0, 0 },
34-
col = { 0, 1 },
35-
sign_text = '󰫎 ',
36-
sign_hl_group = 'markdownH1',
37-
},
3825
{
3926
row = { 0, 0 },
4027
col = { 9, 18 },
@@ -59,22 +46,7 @@ async_tests.describe('custom_handler.md', function()
5946
local expected = {}
6047

6148
-- Heading / no inline code
62-
vim.list_extend(expected, {
63-
{
64-
row = { 0, 1 },
65-
col = { 0, 0 },
66-
hl_eol = true,
67-
hl_group = 'DiffAdd',
68-
virt_text = { { '󰲡 ', { 'markdownH1', 'DiffAdd' } } },
69-
virt_text_pos = 'overlay',
70-
},
71-
{
72-
row = { 0, 0 },
73-
col = { 0, 1 },
74-
sign_text = '󰫎 ',
75-
sign_hl_group = 'markdownH1',
76-
},
77-
})
49+
vim.list_extend(expected, util.heading(0, 1))
7850

7951
-- Backslash escapes
8052
vim.list_extend(expected, {
@@ -107,21 +79,8 @@ async_tests.describe('custom_handler.md', function()
10779
local expected = {}
10880

10981
-- Heading / inline code
82+
vim.list_extend(expected, util.heading(0, 1))
11083
vim.list_extend(expected, {
111-
{
112-
row = { 0, 1 },
113-
col = { 0, 0 },
114-
hl_eol = true,
115-
hl_group = 'DiffAdd',
116-
virt_text = { { '󰲡 ', { 'markdownH1', 'DiffAdd' } } },
117-
virt_text_pos = 'overlay',
118-
},
119-
{
120-
row = { 0, 0 },
121-
col = { 0, 1 },
122-
sign_text = '󰫎 ',
123-
sign_hl_group = 'markdownH1',
124-
},
12584
{
12685
row = { 0, 0 },
12786
col = { 9, 18 },

0 commit comments

Comments
 (0)