@@ -426,12 +426,14 @@ func! s:apply_icons() abort
426
426
if 0 == len (s: cb_map )
427
427
return
428
428
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'
431
433
if ! exists (' s:ns_id' )
432
434
let s: ns_id = nvim_create_namespace (' dirvish.icons' )
433
435
endif
434
- elseif l: feat == # ' textprop'
436
+ elseif s: virttext_feat == # ' textprop'
435
437
if ! exists (' s:prop_type' )
436
438
let s: prop_type = ' dirvish.icons'
437
439
call prop_type_add (s: prop_type , {})
@@ -443,25 +445,30 @@ func! s:apply_icons() abort
443
445
let i = 0
444
446
for f in getline (1 , ' $' )
445
447
let i += 1
446
- let icon = ' '
447
448
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
451
454
endif
452
455
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
458
464
else
459
465
let isdir = (f [-1 :] == s: sep )
460
466
let f = substitute (s: f (f ), escape (s: sep ,' \' ).' $' , ' ' , ' g' ) " Full path, trim slash.
461
467
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
463
469
endif
464
470
endif
471
+ unlet l: icon
465
472
endfor
466
473
endf
467
474
0 commit comments