11local Buffer = require (' render-markdown.lib.buffer' )
22local Compat = require (' render-markdown.lib.compat' )
3- local Context = require (' render-markdown.lib .context' )
3+ local Context = require (' render-markdown.request .context' )
44local Env = require (' render-markdown.lib.env' )
55local Extmark = require (' render-markdown.lib.extmark' )
66local Iter = require (' render-markdown.lib.iter' )
@@ -108,19 +108,15 @@ function M.run_update(buf, win, change)
108108 local initial = buffer :initial ()
109109 if initial or parse then
110110 M .clear_buffer (buf , buffer )
111- buffer : set_marks ( M .parse_buffer ({
112- buf = buf ,
113- win = win ,
114- config = config ,
115- mode = mode ,
116- }))
111+ local extmarks = M .parse_buffer (buf , win , config , mode )
112+ buffer : set_marks ( extmarks )
113+ if initial then
114+ Compat . fix_lsp_window ( buf , win , extmarks )
115+ M . config . on . initial ({ buf = buf , win = win })
116+ end
117117 end
118118 local range = config :hidden (mode , row )
119119 local extmarks = buffer :get_marks ()
120- if initial then
121- Compat .fix_lsp_window (buf , win , extmarks )
122- M .config .on .initial ({ buf = buf , win = win })
123- end
124120 for _ , extmark in ipairs (extmarks ) do
125121 if extmark :get ().conceal and extmark :overlaps (range ) then
126122 extmark :hide (M .ns , buf )
@@ -154,19 +150,21 @@ function M.clear_buffer(buf, buffer)
154150end
155151
156152--- @private
157- --- @param props render.md.context.Props
153+ --- @param buf integer
154+ --- @param win integer
155+ --- @param config render.md.main.Config
156+ --- @param mode string
158157--- @return render.md.Extmark[]
159- function M .parse_buffer (props )
160- local buf = props .buf
158+ function M .parse_buffer (buf , win , config , mode )
161159 local has_parser , parser = pcall (vim .treesitter .get_parser , buf )
162160 if not has_parser or not parser then
163161 log .buf (' error' , ' fail' , buf , ' no treesitter parser found' )
164162 return {}
165163 end
166164 -- reset buffer context
167- local context = Context .reset ( props )
165+ local context = Context .start ( buf , win , config , mode )
168166 -- make sure injections are processed
169- context :parse (parser )
167+ context . view :parse (parser )
170168 -- parse markdown after other nodes to get accurate state
171169 local marks = {} --- @type render.md.Mark[]
172170 local markdown = {} --- @type render.md.handler.Context[]
@@ -189,13 +187,13 @@ end
189187--- Run user & builtin handlers when available. User handler is always executed,
190188--- builtin handler is skipped if user handler does not specify extends.
191189--- @private
192- --- @param context render.md.Context
190+ --- @param context render.md.request. Context
193191--- @param ctx render.md.handler.Context
194192--- @param language string
195193--- @return render.md.Mark[]
196194function M .parse_tree (context , ctx , language )
197195 log .buf (' debug' , ' language' , ctx .buf , language )
198- if not context :overlaps (ctx .root ) then
196+ if not context . view :overlaps (ctx .root ) then
199197 return {}
200198 end
201199
0 commit comments