@@ -426,7 +426,20 @@ func! s:apply_icons() abort
426426 if 0 == len (s: cb_map )
427427 return
428428 endif
429- highlight clear Conceal
429+ let l: feat = has (' nvim-0.8' ) ? ' extmark' : ((v: version >= 901 && has (' textprop' ))? ' textprop' : ' conceal' )
430+ if l: feat == # ' extmark'
431+ if ! exists (' s:ns_id' )
432+ let s: ns_id = nvim_create_namespace (' dirvish.icons' )
433+ endif
434+ elseif l: feat == # ' textprop'
435+ if ! exists (' s:prop_type' )
436+ let s: prop_type = ' dirvish.icons'
437+ call prop_type_add (s: prop_type , {})
438+ endif
439+ else
440+ highlight clear Conceal
441+ endif
442+
430443 let i = 0
431444 for f in getline (1 , ' $' )
432445 let i += 1
@@ -438,10 +451,16 @@ func! s:apply_icons() abort
438451 endif
439452 endfor
440453 if icon != ' '
441- let isdir = (f [-1 :] == s: sep )
442- let f = substitute (s: f (f ), escape (s: sep ,' \' ).' $' , ' ' , ' g' ) " Full path, trim slash.
443- let tail_esc = escape (fnamemodify (f ,' :t' ).(isdir?(s: sep ):' ' ), ' [,*.^$~\' )
444- exe ' syntax match DirvishColumnHead =\%' .i .' l^.\{-}\ze' .tail_esc.' $= conceal cchar=' .icon
454+ if l: feat == # ' extmark'
455+ call nvim_buf_set_extmark (0 , s: ns_id , i - 1 , 0 , #{virt_text: [[icon , ' DirvishColumnHead' ]], virt_text_pos: ' inline' })
456+ elseif l: feat == # ' textprop'
457+ call prop_add (i , 1 , #{type : s: prop_type , text: icon })
458+ else
459+ let isdir = (f [-1 :] == s: sep )
460+ let f = substitute (s: f (f ), escape (s: sep ,' \' ).' $' , ' ' , ' g' ) " Full path, trim slash.
461+ let tail_esc = escape (fnamemodify (f ,' :t' ).(isdir?(s: sep ):' ' ), ' [,*.^$~\' )
462+ exe ' syntax match DirvishColumnHead =\%' .i .' l^.\{-}\ze' .tail_esc.' $= conceal cchar=' .icon
463+ endif
445464 endif
446465 endfor
447466endf
0 commit comments