@@ -425,15 +425,21 @@ typst.heading = function (buffer, item)
425425 line_hl_group = utils .set_hl (config .hl )
426426 });
427427 elseif config .style == " icon" then
428+ local shift_width = main_config .shift_width or 0 ;
429+ local shift_char = " " ;
430+
428431 vim .api .nvim_buf_set_extmark (buffer , typst .ns , range .row_start , range .col_start , {
429432 undo_restore = false , invalidate = true ,
430433 end_col = range .col_start + item .level + 1 ,
434+
431435 conceal = " " ,
436+
432437 sign_text = config .sign ,
433438 sign_hl_group = utils .set_hl (config .sign_hl ),
439+
434440 virt_text_pos = " inline" ,
435441 virt_text = {
436- { string.rep (" " , item .level * spec . get ({ " typst " , " headings " , " shift_width" }, { fallback = 1 }) ) },
442+ { string.rep (shift_char , ( item .level - 1 ) * shift_width ) },
437443 { config .icon or " " , utils .set_hl (config .icon_hl or config .hl ) },
438444 },
439445 line_hl_group = utils .set_hl (config .hl ),
@@ -1569,6 +1575,68 @@ typst.text = function (buffer, item)
15691575 });
15701576end
15711577
1578+ --- Render org mode like section indentations.
1579+ --- @param buffer integer
1580+ --- @param item markview.parsed.typst.sections
1581+ typst .section = function (buffer , item )
1582+ --- @type markview.config.typst.headings ?
1583+ local main_config = spec .get ({ " typst" , " headings" }, { fallback = nil , eval_args = { buffer , item } });
1584+
1585+ if main_config == nil then
1586+ return ;
1587+ elseif main_config .org_indent ~= true then
1588+ --- Org indent mode disabled.
1589+ return ;
1590+ end
1591+
1592+ local shift_width = main_config .org_shift_width or main_config .shift_width or 0 ;
1593+ local shift_char = main_config .org_shift_char or " " ;
1594+
1595+ local range = item .range ;
1596+
1597+ for l = range .row_start + 1 , range .org_end do
1598+ vim .api .nvim_buf_set_extmark (buffer , typst .ns , l , 0 , {
1599+ undo_restore = false , invalidate = true ,
1600+
1601+ virt_text_pos = " inline" ,
1602+ virt_text = {
1603+ {
1604+ string.rep (
1605+ shift_char ,
1606+ math.max (
1607+ 0 ,
1608+ shift_width * (item .level - 1 )
1609+ )
1610+ )
1611+ }
1612+ },
1613+
1614+ right_gravity = false ,
1615+ hl_mode = " combine"
1616+ });
1617+ end
1618+
1619+ --- @type integer , integer Start & end fold level.
1620+ local foldlevel_s , foldlevel_e ;
1621+
1622+ vim .api .nvim_buf_call (buffer , function ()
1623+ foldlevel_s = vim .fn .foldlevel (range .row_start + 1 );
1624+ foldlevel_e = vim .fn .foldlevel (range .row_end + 1 );
1625+ end )
1626+
1627+ if foldlevel_s ~= 0 or foldlevel_e ~= 0 then
1628+ --- Text was folded.
1629+ return ;
1630+ end
1631+
1632+ local win = utils .buf_getwin (buffer );
1633+
1634+ if win and main_config .org_indent_wrap == true and vim .wo [win ].wrap == true then
1635+ --- When `wrap` is enabled, run post-processing effects.
1636+ table.insert (typst .cache , item );
1637+ end
1638+ end
1639+
15721640--- Renders typst previews.
15731641--- @param buffer integer
15741642--- @param content markview.parsed.typst[]
0 commit comments