Skip to content

Commit af819f3

Browse files
Add horizontal break support from PR 13
# Details Adds just the horizontal break feature from: #13 Co-Authored-By: Dmitriy <[email protected]>
1 parent a0da7cf commit af819f3

File tree

6 files changed

+32
-1
lines changed

6 files changed

+32
-1
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Plugin to improve viewing Markdown files in Neovim
1111
- Changes `conceallevel` between `rendered` and `raw` view based on configuration
1212
- Supports rendering `markdown` injected into other file types
1313
- Highlights headings with different groups depending on level and replaces `#`
14+
- Updates horizontal breaks with full-width lines
1415
- Highlights code blocks and inline code to better stand out
1516
- Replaces bullet points with provided character based on level
1617
- Replaces block quote leading `>` with provided character
@@ -58,6 +59,8 @@ require('render-markdown').setup({
5859
(atx_h6_marker)
5960
] @heading)
6061
62+
(thematic_break) @dash
63+
6164
(fenced_code_block) @code
6265
6366
[
@@ -85,6 +88,8 @@ require('render-markdown').setup({
8588
render_modes = { 'n', 'c' },
8689
-- Characters that will replace the # at the start of headings
8790
headings = { '󰲡 ', '󰲣 ', '󰲥 ', '󰲧 ', '󰲩 ', '󰲫 ' },
91+
-- Character to use for the horizontal break
92+
dash = '',
8893
-- Character to use for the bullet points in lists
8994
bullets = { '', '', '', '' },
9095
-- Character that will replace the > at the start of block quotes
@@ -113,6 +118,8 @@ require('render-markdown').setup({
113118
'markdownH6',
114119
},
115120
},
121+
-- Horizontal break
122+
dash = 'LineNr',
116123
-- Code blocks
117124
code = 'ColorColumn',
118125
-- Bullet points in list

demo/sample.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ if __name__ == "__main__":
3333
2. Item 2
3434
3. Item 3
3535

36+
---
37+
3638
> Quote line 1
3739
> Quote line 2
3840

doc/render-markdown.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*render-markdown.txt* For 0.9.5 Last change: 2024 April 01
1+
*render-markdown.txt* For 0.9.5 Last change: 2024 April 11
22

33
==============================================================================
44
Table of Contents *render-markdown-table-of-contents*
@@ -31,6 +31,7 @@ Plugin to improve viewing Markdown files in Neovim
3131
- Changes `conceallevel` between `rendered` and `raw` view based on configuration
3232
- Supports rendering `markdown` injected into other file types
3333
- Highlights headings with different groups depending on level and replaces `#`
34+
- Updates horizontal breaks with full-width lines
3435
- Highlights code blocks and inline code to better stand out
3536
- Replaces bullet points with provided character based on level
3637
- Replaces block quote leading `>` with provided character
@@ -85,6 +86,8 @@ modified by the user.
8586
(atx_h6_marker)
8687
] @heading)
8788

89+
(thematic_break) @dash
90+
8891
(fenced_code_block) @code
8992

9093
[
@@ -112,6 +115,8 @@ modified by the user.
112115
render_modes = { 'n', 'c' },
113116
-- Characters that will replace the # at the start of headings
114117
headings = { '󰲡 ', '󰲣 ', '󰲥 ', '󰲧 ', '󰲩 ', '󰲫 ' },
118+
-- Character to use for the horizontal break
119+
dash = '—',
115120
-- Character to use for the bullet points in lists
116121
bullets = { '●', '○', '◆', '◇' },
117122
-- Character that will replace the > at the start of block quotes
@@ -140,6 +145,8 @@ modified by the user.
140145
'markdownH6',
141146
},
142147
},
148+
-- Horizontal break
149+
dash = 'LineNr',
143150
-- Code blocks
144151
code = 'ColorColumn',
145152
-- Bullet points in list

lua/render-markdown/handler/markdown.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ M.render = function(namespace, root)
3333
virt_text_pos = 'overlay',
3434
hl_eol = true,
3535
})
36+
elseif capture == 'dash' then
37+
local width = vim.api.nvim_win_get_width(0)
38+
local virt_text = { state.config.dash:rep(width), highlights.dash }
39+
vim.api.nvim_buf_set_extmark(0, namespace, start_row, 0, {
40+
virt_text = { virt_text },
41+
virt_text_pos = 'overlay',
42+
})
3643
elseif capture == 'code' then
3744
vim.api.nvim_buf_set_extmark(0, namespace, start_row, 0, {
3845
end_row = end_row,

lua/render-markdown/init.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ local M = {}
1313

1414
---@class UserHighlights
1515
---@field public heading? UserHeadingHighlights
16+
---@field public dash? string
1617
---@field public code? string
1718
---@field public bullet? string
1819
---@field public table? UserTableHighlights
@@ -29,6 +30,7 @@ local M = {}
2930
---@field public file_types? string[]
3031
---@field public render_modes? string[]
3132
---@field public headings? string[]
33+
---@field public dash? string
3234
---@field public bullets? string[]
3335
---@field public quote? string
3436
---@field public conceal? UserConceal
@@ -49,6 +51,8 @@ function M.setup(opts)
4951
(atx_h6_marker)
5052
] @heading)
5153
54+
(thematic_break) @dash
55+
5256
(fenced_code_block) @code
5357
5458
[
@@ -71,6 +75,7 @@ function M.setup(opts)
7175
file_types = { 'markdown' },
7276
render_modes = { 'n', 'c' },
7377
headings = { '󰲡 ', '󰲣 ', '󰲥 ', '󰲧 ', '󰲩 ', '󰲫 ' },
78+
dash = '',
7479
bullets = { '', '', '', '' },
7580
quote = '',
7681
conceal = {
@@ -90,6 +95,7 @@ function M.setup(opts)
9095
'markdownH6',
9196
},
9297
},
98+
dash = 'LineNr',
9399
code = 'ColorColumn',
94100
bullet = 'Normal',
95101
table = {

lua/render-markdown/state.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
---@class Highlights
1010
---@field public heading HeadingHighlights
11+
---@field public dash string
1112
---@field public code string
1213
---@field public bullet string
1314
---@field public table TableHighlights
@@ -24,6 +25,7 @@
2425
---@field public file_types string[]
2526
---@field public render_modes string[]
2627
---@field public headings string[]
28+
---@field public dash string
2729
---@field public bullets string[]
2830
---@field public quote string
2931
---@field public conceal Conceal

0 commit comments

Comments
 (0)