Skip to content

Commit 66110dd

Browse files
feat: Allow users to set repeat linebreak for quotes / callouts
# Details Request: #114 Adds the a `quote -> repeat_linebreak` boolean that defaults to false. This setting applies both to regular block quotes as well as callouts. When set will create an extmark with the `virt_text_repeat_linebreak` option set. This value rquires neovim >= 0.10.0. With default settings if this option is set it will obscure text on the wrapped line. Have added suggestions for how to configure showbreak, breakindent, & breakindentopt to get decent results.
1 parent 6bb1d43 commit 66110dd

File tree

9 files changed

+53
-10
lines changed

9 files changed

+53
-10
lines changed

Diff for: README.md

+12
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,12 @@ require('render-markdown').setup({
337337
enabled = true,
338338
-- Replaces '>' of 'block_quote'
339339
icon = '',
340+
-- Whether to repeat icon on wrapped lines. Requires neovim >= 0.10. This will obscure text if
341+
-- not configured correctly with :h 'showbreak', :h 'breakindent' and :h 'breakindentopt'. A
342+
-- combination of these that is likely to work is showbreak = ' ' (2 spaces), breakindent = true,
343+
-- breakindentopt = '' (empty string). These values are not validated by this plugin. If you want
344+
-- to avoid adding these to your main configuration then set them in win_options for this plugin.
345+
repeat_linebreak = false,
340346
-- Highlight for the quote icon
341347
highlight = 'RenderMarkdownQuote',
342348
},
@@ -633,6 +639,12 @@ require('render-markdown').setup({
633639
enabled = true,
634640
-- Replaces '>' of 'block_quote'
635641
icon = '',
642+
-- Whether to repeat icon on wrapped lines. Requires neovim >= 0.10. This will obscure text if
643+
-- not configured correctly with :h 'showbreak', :h 'breakindent' and :h 'breakindentopt'. A
644+
-- combination of these that is likely to work is showbreak = ' ' (2 spaces), breakindent = true,
645+
-- breakindentopt = '' (empty string). These values are not validated by this plugin. If you want
646+
-- to avoid adding these to your main configuration then set them in win_options for this plugin.
647+
repeat_linebreak = false,
636648
-- Highlight for the quote icon
637649
highlight = 'RenderMarkdownQuote',
638650
},

Diff for: doc/render-markdown.txt

+12
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,12 @@ Full Default Configuration ~
370370
enabled = true,
371371
-- Replaces '>' of 'block_quote'
372372
icon = '▋',
373+
-- Whether to repeat icon on wrapped lines. Requires neovim >= 0.10. This will obscure text if
374+
-- not configured correctly with :h 'showbreak', :h 'breakindent' and :h 'breakindentopt'. A
375+
-- combination of these that is likely to work is showbreak = ' ' (2 spaces), breakindent = true,
376+
-- breakindentopt = '' (empty string). These values are not validated by this plugin. If you want
377+
-- to avoid adding these to your main configuration then set them in win_options for this plugin.
378+
repeat_linebreak = false,
373379
-- Highlight for the quote icon
374380
highlight = 'RenderMarkdownQuote',
375381
},
@@ -670,6 +676,12 @@ BLOCK QUOTES *render-markdown-setup-block-quotes*
670676
enabled = true,
671677
-- Replaces '>' of 'block_quote'
672678
icon = '▋',
679+
-- Whether to repeat icon on wrapped lines. Requires neovim >= 0.10. This will obscure text if
680+
-- not configured correctly with :h 'showbreak', :h 'breakindent' and :h 'breakindentopt'. A
681+
-- combination of these that is likely to work is showbreak = ' ' (2 spaces), breakindent = true,
682+
-- breakindentopt = '' (empty string). These values are not validated by this plugin. If you want
683+
-- to avoid adding these to your main configuration then set them in win_options for this plugin.
684+
repeat_linebreak = false,
673685
-- Highlight for the quote icon
674686
highlight = 'RenderMarkdownQuote',
675687
},

Diff for: lua/render-markdown/context.lua

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
local util = require('render-markdown.util')
2+
13
---@class render.md.Context
24
---@field private buf integer
35
---@field private win integer
@@ -88,7 +90,7 @@ end
8890
---@private
8991
---@return table<integer, [integer, integer][]>
9092
function Context:compute_conceal()
91-
local conceallevel = vim.api.nvim_get_option_value('conceallevel', { scope = 'local', win = self.win })
93+
local conceallevel = util.get_win(self.win, 'conceallevel')
9294
if conceallevel == 0 then
9395
return {}
9496
end

Diff for: lua/render-markdown/handler/markdown.lua

+1
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ function M.quote_marker(config, info, block_quote)
507507
end_col = info.end_col,
508508
virt_text = { { info.text:gsub('>', quote.icon), highlight } },
509509
virt_text_pos = 'overlay',
510+
virt_text_repeat_linebreak = quote.repeat_linebreak or nil,
510511
},
511512
}
512513
end

Diff for: lua/render-markdown/health.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local M = {}
55

66
---@private
77
---@type string
8-
M.version = '5.1.1'
8+
M.version = '5.1.2'
99

1010
function M.check()
1111
vim.health.start('markdown.nvim [version]')

Diff for: lua/render-markdown/init.lua

+9-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ local M = {}
1919
---@field public bottom_pad? integer
2020

2121
---@class (exact) render.md.UserWindowOption
22-
---@field public default? number|string
23-
---@field public rendered? number|string
22+
---@field public default? number|string|boolean
23+
---@field public rendered? number|string|boolean
2424

2525
---@class (exact) render.md.UserSign
2626
---@field public enabled? boolean
@@ -50,6 +50,7 @@ local M = {}
5050
---@class (exact) render.md.UserQuote
5151
---@field public enabled? boolean
5252
---@field public icon? string
53+
---@field public repeat_linebreak? boolean
5354
---@field public highlight? string
5455

5556
---@class (exact) render.md.UserCheckboxComponent
@@ -354,6 +355,12 @@ M.default_config = {
354355
enabled = true,
355356
-- Replaces '>' of 'block_quote'
356357
icon = '',
358+
-- Whether to repeat icon on wrapped lines. Requires neovim >= 0.10. This will obscure text if
359+
-- not configured correctly with :h 'showbreak', :h 'breakindent' and :h 'breakindentopt'. A
360+
-- combination of these that is likely to work is showbreak = ' ' (2 spaces), breakindent = true,
361+
-- breakindentopt = '' (empty string). These values are not validated by this plugin. If you want
362+
-- to avoid adding these to your main configuration then set them in win_options for this plugin.
363+
repeat_linebreak = false,
357364
-- Highlight for the quote icon
358365
highlight = 'RenderMarkdownQuote',
359366
},

Diff for: lua/render-markdown/state.lua

+3-2
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ function M.validate()
250250
append_errors(path .. '.quote', quote, {
251251
enabled = { quote.enabled, 'boolean', nilable },
252252
icon = { quote.icon, 'string', nilable },
253+
repeat_linebreak = { quote.repeat_linebreak, 'boolean', nilable },
253254
highlight = { quote.highlight, 'string', nilable },
254255
})
255256
end
@@ -299,8 +300,8 @@ function M.validate()
299300
if config.win_options ~= nil then
300301
for name, win_option in pairs(config.win_options) do
301302
append_errors(path .. '.win_options.' .. name, win_option, {
302-
default = { win_option.default, { 'number', 'string' } },
303-
rendered = { win_option.rendered, { 'number', 'string' } },
303+
default = { win_option.default, { 'number', 'string', 'boolean' } },
304+
rendered = { win_option.rendered, { 'number', 'string', 'boolean' } },
304305
})
305306
end
306307
end

Diff for: lua/render-markdown/types.lua

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
---@field public bottom_pad integer
99

1010
---@class (exact) render.md.WindowOption
11-
---@field public default number|string
12-
---@field public rendered number|string
11+
---@field public default number|string|boolean
12+
---@field public rendered number|string|boolean
1313

1414
---@class (exact) render.md.Sign
1515
---@field public enabled boolean
@@ -39,6 +39,7 @@
3939
---@class (exact) render.md.Quote
4040
---@field public enabled boolean
4141
---@field public icon string
42+
---@field public repeat_linebreak boolean
4243
---@field public highlight string
4344

4445
---@class (exact) render.md.CheckboxComponent

Diff for: lua/render-markdown/util.lua

+9-2
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,21 @@ end
2828

2929
---@param win integer
3030
---@param name string
31-
---@param value number|string
31+
---@return number|string|boolean
32+
function M.get_win(win, name)
33+
return vim.api.nvim_get_option_value(name, { scope = 'local', win = win })
34+
end
35+
36+
---@param win integer
37+
---@param name string
38+
---@param value number|string|boolean
3239
function M.set_win(win, name, value)
3340
vim.api.nvim_set_option_value(name, value, { scope = 'local', win = win })
3441
end
3542

3643
---@param buf integer
3744
---@param name string
38-
---@return number|string
45+
---@return number|string|boolean
3946
function M.get_buf(buf, name)
4047
return vim.api.nvim_get_option_value(name, { buf = buf })
4148
end

0 commit comments

Comments
 (0)