@@ -426,12 +426,14 @@ func! s:apply_icons() abort
426426 if 0 == len (s: cb_map )
427427 return
428428 endif
429- let l: feat = has (' nvim-0.8' ) ? ' extmark' : ((v: version >= 901 && has (' textprop' ))? ' textprop' : ' conceal' )
430- if l: feat == # ' extmark'
429+ if ! exists (' s:virttext_feat' )
430+ let s: virttext_feat = has (' nvim-0.8' ) ? ' extmark' : ((v: version >= 901 && has (' textprop' ))? ' textprop' : ' conceal' )
431+ endif
432+ if s: virttext_feat == # ' extmark'
431433 if ! exists (' s:ns_id' )
432434 let s: ns_id = nvim_create_namespace (' dirvish.icons' )
433435 endif
434- elseif l: feat == # ' textprop'
436+ elseif s: virttext_feat == # ' textprop'
435437 if ! exists (' s:prop_type' )
436438 let s: prop_type = ' dirvish.icons'
437439 call prop_type_add (s: prop_type , {})
@@ -443,25 +445,30 @@ func! s:apply_icons() abort
443445 let i = 0
444446 for f in getline (1 , ' $' )
445447 let i += 1
446- let icon = ' '
447448 for id in sort (keys (s: cb_map ))
448- let icon = s: cb_map [id](f )
449- if -1 != match (icon , ' \S' )
450- break
449+ let l: icon = s: cb_map [id](f )
450+ if type (l: icon ) == v: t_string
451+ if -1 != match (l: icon , ' \S' )
452+ break
453+ endif
451454 endif
452455 endfor
453- if 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 })
456+ if exists (' l:icon' )
457+ if s: virttext_feat == # ' extmark'
458+ let l: virt_text = type (l: icon ) == v: t_dict ? [[l: icon .icon , l: icon .hl ]] : [[l: icon , ' DirvishColumnHead' ]]
459+ call nvim_buf_set_extmark (0 , s: ns_id , i - 1 , 0 , #{virt_text: l: virt_text , virt_text_pos: ' inline' })
460+ elseif s: virttext_feat == # ' textprop'
461+ if type (l: icon ) == v: t_string
462+ call prop_add (i , 1 , #{type : s: prop_type , text: l: icon })
463+ endif
458464 else
459465 let isdir = (f [-1 :] == s: sep )
460466 let f = substitute (s: f (f ), escape (s: sep ,' \' ).' $' , ' ' , ' g' ) " Full path, trim slash.
461467 let tail_esc = escape (fnamemodify (f ,' :t' ).(isdir?(s: sep ):' ' ), ' [,*.^$~\' )
462- exe ' syntax match DirvishColumnHead =\%' .i .' l^.\{-}\ze' .tail_esc.' $= conceal cchar=' .icon
468+ exe ' syntax match DirvishColumnHead =\%' .i .' l^.\{-}\ze' .tail_esc.' $= conceal cchar=' .l: icon
463469 endif
464470 endif
471+ unlet l: icon
465472 endfor
466473endf
467474
0 commit comments