1
1
local utils = require " nvim-tree.utils"
2
2
local core = require " nvim-tree.core"
3
+ local modified = require " nvim-tree.modified"
3
4
4
5
local git = require " nvim-tree.renderer.components.git"
5
6
local pad = require " nvim-tree.renderer.components.padding"
@@ -68,10 +69,11 @@ function Builder:configure_git_icons_placement(where)
68
69
return self
69
70
end
70
71
71
- function Builder :configure_modified (modified_icon , modified_placement , modified )
72
- self .modified = modified
73
- self .modified .icon = modified_icon
74
- self .modified .placement = modified_placement
72
+ function Builder :configure_modified (modified_icon , modified_placement )
73
+ self .modified = {
74
+ icon = modified_icon ,
75
+ placement = modified_placement ,
76
+ }
75
77
return self
76
78
end
77
79
@@ -118,6 +120,9 @@ function Builder:_build_folder(node, padding, git_hl, git_icons_tbl)
118
120
local offset = string.len (padding )
119
121
120
122
local name = get_folder_name (node )
123
+ if modified .is_modified (node ) then
124
+ name = name .. self .modified .icon
125
+ end
121
126
local has_children = # node .nodes ~= 0 or node .has_children
122
127
local icon = icons .get_folder_icon (node .open , node .link_to ~= nil , has_children )
123
128
@@ -213,7 +218,7 @@ function Builder:_highlight_opened_files(node, offset, icon_length, git_icons_le
213
218
self :_insert_highlight (" NvimTreeOpenedFile" , from , to )
214
219
end
215
220
216
- function Builder :_build_file (node , padding , git_highlight , git_icons_tbl , unloaded_bufnr , modified )
221
+ function Builder :_build_file (node , padding , git_highlight , git_icons_tbl , unloaded_bufnr )
217
222
local offset = string.len (padding )
218
223
219
224
local icon = self :_build_file_icon (node , offset )
@@ -222,7 +227,7 @@ function Builder:_build_file(node, padding, git_highlight, git_icons_tbl, unload
222
227
local git_icons = self :_unwrap_git_data (git_icons_tbl , git_icons_starts_at )
223
228
224
229
local name = node .name
225
- if modified then
230
+ if modified . is_modified ( node ) then
226
231
name = name .. self .modified .icon
227
232
end
228
233
self :_insert_line (self :_format_line (padding .. icon , name , git_icons ))
@@ -274,8 +279,6 @@ function Builder:_build_line(node, idx, num_children, unloaded_bufnr)
274
279
end
275
280
end
276
281
277
- local modified = vim .fn .bufloaded (node .absolute_path ) > 0 and vim .fn .getbufinfo (node .absolute_path )[1 ].changed == 1
278
-
279
282
local is_folder = node .nodes ~= nil
280
283
local is_symlink = node .link_to ~= nil
281
284
@@ -284,7 +287,7 @@ function Builder:_build_line(node, idx, num_children, unloaded_bufnr)
284
287
elseif is_symlink then
285
288
self :_build_symlink (node , padding , git_highlight , git_icons_tbl )
286
289
else
287
- self :_build_file (node , padding , git_highlight , git_icons_tbl , unloaded_bufnr , modified )
290
+ self :_build_file (node , padding , git_highlight , git_icons_tbl , unloaded_bufnr )
288
291
end
289
292
self .index = self .index + 1
290
293
0 commit comments