|
| 1 | +local colors = require('render-markdown.colors') |
1 | 2 | local component = require('render-markdown.component') |
2 | 3 | local icons = require('render-markdown.icons') |
3 | 4 | local list = require('render-markdown.list') |
@@ -53,12 +54,7 @@ M.render_node = function(namespace, buf, capture, node) |
53 | 54 | hl_eol = true, |
54 | 55 | }) |
55 | 56 |
|
56 | | - vim.api.nvim_buf_set_extmark(buf, namespace, info.start_row, info.start_col, { |
57 | | - end_row = info.end_row, |
58 | | - end_col = info.end_col, |
59 | | - sign_text = list.cycle(heading.signs, level), |
60 | | - sign_hl_group = foreground, |
61 | | - }) |
| 57 | + M.render_sign(namespace, buf, info, list.cycle(heading.signs, level), foreground) |
62 | 58 | elseif capture == 'dash' then |
63 | 59 | local dash = state.config.dash |
64 | 60 | if not dash.enabled then |
@@ -95,12 +91,7 @@ M.render_node = function(namespace, buf, capture, node) |
95 | 91 | if icon == nil or icon_highlight == nil then |
96 | 92 | return |
97 | 93 | end |
98 | | - vim.api.nvim_buf_set_extmark(buf, namespace, info.start_row, info.start_col, { |
99 | | - end_row = info.end_row, |
100 | | - end_col = info.end_col, |
101 | | - sign_text = icon, |
102 | | - sign_hl_group = icon_highlight, |
103 | | - }) |
| 94 | + M.render_sign(namespace, buf, info, icon, icon_highlight) |
104 | 95 | -- Requires inline extmarks |
105 | 96 | if not util.has_10 then |
106 | 97 | return |
@@ -221,6 +212,27 @@ M.render_node = function(namespace, buf, capture, node) |
221 | 212 | end |
222 | 213 | end |
223 | 214 |
|
| 215 | +---@param namespace integer |
| 216 | +---@param buf integer |
| 217 | +---@param info render.md.NodeInfo |
| 218 | +---@param text string |
| 219 | +---@param highlight string |
| 220 | +M.render_sign = function(namespace, buf, info, text, highlight) |
| 221 | + local sign = state.config.sign |
| 222 | + if not sign.enabled then |
| 223 | + return |
| 224 | + end |
| 225 | + if vim.tbl_contains(sign.exclude.buftypes, util.get_buftype(buf)) then |
| 226 | + return |
| 227 | + end |
| 228 | + vim.api.nvim_buf_set_extmark(buf, namespace, info.start_row, info.start_col, { |
| 229 | + end_row = info.end_row, |
| 230 | + end_col = info.end_col, |
| 231 | + sign_text = text, |
| 232 | + sign_hl_group = colors.combine(highlight, sign.highlight), |
| 233 | + }) |
| 234 | +end |
| 235 | + |
224 | 236 | ---@param namespace integer |
225 | 237 | ---@param buf integer |
226 | 238 | ---@param info render.md.NodeInfo |
|
0 commit comments