@@ -7,76 +7,76 @@ local M = {
77 REF = " <REF>" ,
88}
99
10- -- For lists, the first value is the default value.
11- local arguments = {
12- action = {
13- type = M .LIST ,
14- values = {
15- " close" ,
16- " focus" ,
17- " show" ,
10+ M .setup = function (all_source_names )
11+ local source_names = utils .table_copy (all_source_names )
12+ table.insert (source_names , " migrations" )
13+
14+ -- For lists, the first value is the default value.
15+ local arguments = {
16+ action = {
17+ type = M .LIST ,
18+ values = {
19+ " close" ,
20+ " focus" ,
21+ " show" ,
22+ },
1823 },
19- },
20- position = {
21- type = M . LIST ,
22- values = {
23- " left " ,
24- " right " ,
25- -- "top ", --technically valid, but why show it if no one will use it?
26- -- "bottom", --technically valid, but why show it if no one will use it?
27- " float " ,
28- " current " ,
24+ position = {
25+ type = M . LIST ,
26+ values = {
27+ " left " ,
28+ " right " ,
29+ -- "top", --technically valid, but why show it if no one will use it?
30+ -- "bottom ", --technically valid, but why show it if no one will use it?
31+ " float " ,
32+ " current " ,
33+ } ,
2934 },
30- },
31- source = {
32- type = M .LIST ,
33- values = {
34- " filesystem" ,
35- " buffers" ,
36- " git_status" ,
37- " migrations" ,
35+ source = {
36+ type = M .LIST ,
37+ values = source_names ,
3838 },
39- },
40- dir = { type = M .PATH , stat_type = " directory" },
41- reveal_file = { type = M .PATH , stat_type = " file" },
42- git_base = { type = M .REF },
43- toggle = { type = M .FLAG },
44- reveal = { type = M .FLAG },
45- reveal_force_cwd = { type = M .FLAG },
46- }
39+ dir = { type = M .PATH , stat_type = " directory" },
40+ reveal_file = { type = M .PATH , stat_type = " file" },
41+ git_base = { type = M .REF },
42+ toggle = { type = M .FLAG },
43+ reveal = { type = M .FLAG },
44+ reveal_force_cwd = { type = M .FLAG },
45+ }
4746
48- local arg_type_lookup = {}
49- local list_args = {}
50- local path_args = {}
51- local ref_args = {}
52- local flag_args = {}
53- local reverse_lookup = {}
54- for name , def in pairs (arguments ) do
55- arg_type_lookup [name ] = def .type
56- if def .type == M .LIST then
57- table.insert (list_args , name )
58- for _ , vv in ipairs (def .values ) do
59- reverse_lookup [tostring (vv )] = name
47+ local arg_type_lookup = {}
48+ local list_args = {}
49+ local path_args = {}
50+ local ref_args = {}
51+ local flag_args = {}
52+ local reverse_lookup = {}
53+ for name , def in pairs (arguments ) do
54+ arg_type_lookup [name ] = def .type
55+ if def .type == M .LIST then
56+ table.insert (list_args , name )
57+ for _ , vv in ipairs (def .values ) do
58+ reverse_lookup [tostring (vv )] = name
59+ end
60+ elseif def .type == M .PATH then
61+ table.insert (path_args , name )
62+ elseif def .type == M .FLAG then
63+ table.insert (flag_args , name )
64+ reverse_lookup [name ] = M .FLAG
65+ elseif def .type == M .REF then
66+ table.insert (ref_args , name )
67+ else
68+ error (" Unknown type: " .. def .type )
6069 end
61- elseif def .type == M .PATH then
62- table.insert (path_args , name )
63- elseif def .type == M .FLAG then
64- table.insert (flag_args , name )
65- reverse_lookup [name ] = M .FLAG
66- elseif def .type == M .REF then
67- table.insert (ref_args , name )
68- else
69- error (" Unknown type: " .. def .type )
7070 end
71- end
7271
73- M .arguments = arguments
74- M .list_args = list_args
75- M .path_args = path_args
76- M .ref_args = ref_args
77- M .flag_args = flag_args
78- M .arg_type_lookup = arg_type_lookup
79- M .reverse_lookup = reverse_lookup
72+ M .arguments = arguments
73+ M .list_args = list_args
74+ M .path_args = path_args
75+ M .ref_args = ref_args
76+ M .flag_args = flag_args
77+ M .arg_type_lookup = arg_type_lookup
78+ M .reverse_lookup = reverse_lookup
79+ end
8080
8181M .resolve_path = function (path , validate_type )
8282 local expanded = vim .fn .expand (path )
@@ -101,7 +101,7 @@ local parse_arg = function(result, arg)
101101 if eq then
102102 local key = arg :sub (1 , eq - 1 )
103103 local value = arg :sub (eq + 1 )
104- local def = arguments [key ]
104+ local def = M . arguments [key ]
105105 if not def .type then
106106 error (" Invalid argument: " .. arg )
107107 end
@@ -126,7 +126,7 @@ local parse_arg = function(result, arg)
126126 end
127127 else
128128 local value = arg
129- local key = reverse_lookup [value ]
129+ local key = M . reverse_lookup [value ]
130130 if key == nil then
131131 -- maybe it's a git ref
132132 if M .verify_git_ref (value ) then
@@ -155,6 +155,7 @@ local parse_arg = function(result, arg)
155155end
156156
157157M .parse = function (args , strict_checking )
158+ require (" neo-tree" ).ensure_config ()
158159 local result = {}
159160
160161 if type (args ) == " string" then
0 commit comments