File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,29 @@ local DEFAULT_CONFIG = {
114
114
}
115
115
}
116
116
117
+ local function merge_mappings (user_mappings )
118
+ if # user_mappings == 0 then
119
+ return M .View .mappings
120
+ end
121
+
122
+ local user_keys = {}
123
+ for _ , map in pairs (user_mappings ) do
124
+ if type (map .key ) == " table" then
125
+ for _ , key in pairs (map .key ) do
126
+ table.insert (user_keys , key )
127
+ end
128
+ else
129
+ table.insert (user_keys , map .key )
130
+ end
131
+ end
132
+
133
+ local view_mappings = vim .tbl_filter (function (map )
134
+ return not vim .tbl_contains (user_keys , map .key )
135
+ end , M .View .mappings )
136
+
137
+ return vim .fn .extend (view_mappings , user_mappings )
138
+ end
139
+
117
140
function M .setup (opts )
118
141
local options = vim .tbl_deep_extend (' force' , DEFAULT_CONFIG , opts )
119
142
M .View .side = options .side
@@ -122,7 +145,7 @@ function M.setup(opts)
122
145
if options .mappings .custom_only then
123
146
M .View .mappings = options .mappings .list
124
147
else
125
- M .View .mappings = vim . fn . extend ( M . View . mappings , options .mappings .list )
148
+ M .View .mappings = merge_mappings ( options .mappings .list )
126
149
end
127
150
128
151
vim .cmd " augroup NvimTreeView"
You can’t perform that action at this time.
0 commit comments