@@ -4,6 +4,7 @@ let s:noswapfile = (2 == exists(':noswapfile')) ? 'noswapfile' : ''
4
4
let s: noau = ' silent noautocmd keepjumps'
5
5
let s: cb_map = {} " callback map
6
6
let s: rel = get (g: , ' dirvish_relative_paths' , 0 )
7
+ let s: virttext_feat = has (' nvim-0.8' ) ? ' extmark' : ((v: version >= 901 && has (' textprop' ))? ' textprop' : ' conceal' )
7
8
8
9
" Debug:
9
10
" echo '' > dirvish.log ; tail -F dirvish.log
@@ -426,9 +427,6 @@ func! s:apply_icons() abort
426
427
if 0 == len (s: cb_map )
427
428
return
428
429
endif
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
430
if s: virttext_feat == # ' extmark'
433
431
if ! exists (' s:ns_id' )
434
432
let s: ns_id = nvim_create_namespace (' dirvish.icons' )
@@ -446,29 +444,36 @@ func! s:apply_icons() abort
446
444
for f in getline (1 , ' $' )
447
445
let i += 1
448
446
for id in sort (keys (s: cb_map ))
449
- let l: icon = s: cb_map [id](f )
450
- if type (l: icon ) == v: t_string
451
- if -1 != match (l: icon , ' \S' )
447
+ let icon = s: cb_map [id](f )
448
+ if type (icon ) == type (' ' )
449
+ if -1 != match (icon , ' \S' )
450
+ unlet icon
452
451
break
453
452
endif
454
453
endif
455
454
endfor
456
455
if exists (' l:icon' )
457
456
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' ]]
457
+ let l: virt_text = type (icon ) == type ({}) ? [[icon .icon , icon .hl ]] : [[icon , ' DirvishColumnHead' ]]
459
458
call nvim_buf_set_extmark (0 , s: ns_id , i - 1 , 0 , #{virt_text: l: virt_text , virt_text_pos: ' inline' })
460
459
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 })
460
+ if type (icon ) == type (' ' )
461
+ call prop_add (i , 1 , #{type : s: prop_type , text: icon })
462
+ else
463
+ let l: prop_type = prop_type_get (' dirvish.' .icon .hl , {})
464
+ if l: prop_type == {}
465
+ call prop_type_add (' dirvish.' .icon .hl , #{highlight : icon .hl })
466
+ endif
467
+ call prop_add (i , 1 , #{type : ' dirvish.' .icon .hl , text: icon .icon })
463
468
endif
464
469
else
465
470
let isdir = (f [-1 :] == s: sep )
466
471
let f = substitute (s: f (f ), escape (s: sep ,' \' ).' $' , ' ' , ' g' ) " Full path, trim slash.
467
472
let tail_esc = escape (fnamemodify (f ,' :t' ).(isdir?(s: sep ):' ' ), ' [,*.^$~\' )
468
- exe ' syntax match DirvishColumnHead =\%' .i .' l^.\{-}\ze' .tail_esc.' $= conceal cchar=' .l: icon
473
+ exe ' syntax match DirvishColumnHead =\%' .i .' l^.\{-}\ze' .tail_esc.' $= conceal cchar=' .icon
469
474
endif
475
+ unlet icon
470
476
endif
471
- unlet l: icon
472
477
endfor
473
478
endf
474
479
0 commit comments