@@ -114,12 +114,32 @@ dirvish#add_icon_fn(fn)
114
114
a given path, wins. Best practice: if you don't have anything meaningful
115
115
to show for a given path, return empty string (or whitespace).
116
116
117
- {fn} is any | Funcref | that takes a path (string) and returns a string
118
- (the "icon"). Example: >vim
117
+ {fn} is any | Funcref | that takes a path (string) and returns an `icon - item` as
118
+ a | string | or a | dict | with the following keys:
119
+ - "icon" (| string | ): the string representing the icon.
120
+ - "hl" (| string | ): the highlight group to use for the icon.
121
+
122
+ Note: If your Vim isn't Vim 9.1+ with | +textprop | or Nvim 0.8+, `icon - item`
123
+ can only be a character.
124
+
125
+ Example that returns a string: >vim
119
126
call dirvish#add_icon_fn({p -> p[-1:]=='/'?'📂':'📄'})
120
127
<
121
- Note: multi-character icons are only supported on Nvim 0.8+ or Vim 9.1+
122
- with | +textprop | .
128
+ Example that uses | mini.icons | <https://github.com/echasnovski/mini.icons >
129
+ 0.15.0 as icon provider >lua
130
+ --- NOTE: mini.icons must be loaded before vim-dirvish
131
+ vim.fn['dirvish#add_icon_fn'](function(p)
132
+ local get = require('mini.icons').get
133
+ local icon, hl
134
+ if p:sub(-1) == '/' then
135
+ icon, hl = get('directory' , p)
136
+ else
137
+ icon, hl = get('file' , p)
138
+ end
139
+ icon = icon .. ' '
140
+ return { icon = icon, hl = hl }
141
+ end)
142
+ <
123
143
124
144
*dirvish#remove_icon_fn()*
125
145
dirvish#remove_icon_fn(fn_id)
0 commit comments