Skip to content

Commit c89e5e0

Browse files
feat: add after render callback
## Details Request: #248 Adds `on.render` callback which is executed after this plugin finishes rendering a buffer. This happens after every render cycle, users should be aware that it will likely be called many times for a given buffer and use it with that in mind.
1 parent a7097f3 commit c89e5e0

File tree

7 files changed

+12
-3
lines changed

7 files changed

+12
-3
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ require('render-markdown').setup({
207207
on = {
208208
-- Called when plugin initially attaches to a buffer
209209
attach = function() end,
210+
-- Called after plugin renders a buffer
211+
render = function() end,
210212
},
211213
heading = {
212214
-- Turn on / off heading icon & background rendering

doc/render-markdown.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*render-markdown.txt* For 0.10.0 Last change: 2024 December 05
1+
*render-markdown.txt* For 0.10.0 Last change: 2024 December 06
22

33
==============================================================================
44
Table of Contents *render-markdown-table-of-contents*
@@ -254,6 +254,8 @@ Default Configuration ~
254254
on = {
255255
-- Called when plugin initially attaches to a buffer
256256
attach = function() end,
257+
-- Called after plugin renders a buffer
258+
render = function() end,
257259
},
258260
heading = {
259261
-- Turn on / off heading icon & background rendering

lua/render-markdown/core/ui.lua

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ function M.run_update(buf, win, parse)
134134
extmark:show(M.namespace, buf)
135135
end
136136
end
137+
state.on.render(buf)
137138
else
138139
M.clear(buf, buffer_state)
139140
end

lua/render-markdown/health.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local state = require('render-markdown.state')
44
local M = {}
55

66
---@private
7-
M.version = '7.6.11'
7+
M.version = '7.6.12'
88

99
function M.check()
1010
M.start('version')

lua/render-markdown/init.lua

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ local M = {}
1313

1414
---@class (exact) render.md.UserCallback
1515
---@field public attach? fun(buf: integer)
16+
---@field public render? fun(buf: integer)
1617

1718
---@class (exact) render.md.UserLatex
1819
---@field public enabled? boolean
@@ -341,6 +342,8 @@ M.default_config = {
341342
on = {
342343
-- Called when plugin initially attaches to a buffer
343344
attach = function() end,
345+
-- Called after plugin renders a buffer
346+
render = function() end,
344347
},
345348
heading = {
346349
-- Turn on / off heading icon & background rendering

lua/render-markdown/state.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ function M.validate()
307307
:check()
308308
end)
309309
:nested('on', function(on)
310-
on:type('attach', 'function'):check()
310+
on:type({ 'attach', 'render' }, 'function'):check()
311311
end)
312312
:nested('overrides', function(overrides)
313313
overrides

lua/render-markdown/types.lua

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
---@class (exact) render.md.Callback
44
---@field public attach fun(buf: integer)
5+
---@field public render fun(buf: integer)
56

67
---@class (exact) render.md.Latex
78
---@field public enabled boolean

0 commit comments

Comments
 (0)