@@ -17,33 +17,28 @@ M._last = {
1717 position = nil ,
1818}
1919
20- --- Executes a Neo-tree action from outside of a Neo-tree window,
21- --- such as show, hide, navigate, etc.
22- --- @param args table The action to execute. The table can have the following keys :
23- --- action = string The action to execute, can be one of:
24- --- "close",
25- --- "focus", <-- default value
26- --- "show",
27- --- source = string The source to use for this action. This will default
28- --- to the default_source specified in the user's config.
29- --- Can be one of:
30- --- "filesystem",
31- --- "buffers",
32- --- "git_status",
33- -- "migrations"
34- --- position = string The position this action will affect. This will default
35- --- to the the last used position or the position specified
36- --- in the user's config for the given source. Can be one of:
37- --- "left",
38- --- "right",
39- --- "float",
40- --- "current"
41- --- toggle = boolean Whether to toggle the visibility of the Neo-tree window.
42- --- reveal = boolean Whether to reveal the current file in the Neo-tree window.
43- --- reveal_file = string The specific file to reveal.
44- --- dir = string The root directory to set.
45- --- git_base = string The git base used for diff
46- M .execute = function (args )
20+ --- @class neotree.command.execute.Args
21+ --- The action to execute
22+ --- @field action string | " focus" | " show" | " close" ?
23+ --- The source to use for this action. This will default to the default_source specified in the user's config.
24+ --- @field source string | " filesystem" | " buffers" | " git_status" | " migrations" | " last" ?
25+ --- The position this action will affect. This will default to the the last used position or the position specified in
26+ --- the user's config for the given source.
27+ --- @field position string | " left" | " right" | " float" | " current" ?
28+ --- @field toggle boolean ? Whether to toggle the visibility of the Neo-tree window.
29+ --- @field selector boolean ? Whether to toggle the visibility of the Neo-tree window.
30+ --- @field reveal boolean ? Whether to reveal the current file in the Neo-tree window.
31+ --- @field reveal_file string ? The specific file to reveal.
32+ --- @field reveal_force_cwd boolean ? Whether to always change directories when a reveal file is outside the cwd.
33+ --- @field dir string ? The root directory to set.
34+ --- @field git_base string ? The git base used for diff
35+
36+ --- @class (partial ) neotree.command.execute.StateConfigOverride : neotree.Config.Filesystem , neotree.Config.Buffers , neotree.Config.GitStatus , neotree.Config.DocumentSymbols
37+
38+ --- Executes a Neo-tree command, like focus/show/close.
39+ --- @param args neotree.command.execute.Args
40+ --- @param state_config_override neotree.command.execute.StateConfigOverride ?
41+ M .execute = function (args , state_config_override )
4742 local nt = require (" neo-tree" )
4843 nt .ensure_config ()
4944
@@ -100,8 +95,14 @@ M.execute = function(args)
10095 if requested_position == " current" then
10196 local winid = vim .api .nvim_get_current_win ()
10297 state = manager .get_state (args .source , nil , winid )
98+ if state_config_override then
99+ state = manager ._change_state (args .source , nil , winid , state_config_override )
100+ end
103101 else
104102 state = manager .get_state (args .source , nil , nil )
103+ if state_config_override then
104+ state = manager ._change_state (args .source , nil , nil , state_config_override )
105+ end
105106 end
106107
107108 -- Next handle toggle, the rest is irrelevant if there is a window to toggle
@@ -113,12 +114,8 @@ M.execute = function(args)
113114 end
114115
115116 -- Handle position override
116- local default_position = nt .config [args .source ].window .position
117- local current_position = state .current_position or default_position
118- local position_changed = false
119117 if args .position then
120118 state .current_position = args .position
121- position_changed = args .position ~= current_position
122119 end
123120
124121 -- Handle setting directory if requested
0 commit comments