@@ -58,11 +58,17 @@ function! denops#plugin#reload(name) abort
58
58
endfunction
59
59
60
60
function ! denops#plugin#discover () abort
61
- let l: plugins = denops#_internal#plugin#collect ()
62
- call denops#_internal#echo#debug (printf (' %d plugins are discovered' , len (l: plugins )))
63
- for l: plugin in l: plugins
64
- call denops#plugin#load (l: plugin .name, l: plugin .script )
61
+ const l: pattern = denops#_internal#path#join ([' denops' , ' *' , ' main.ts' ])
62
+ let l: counter = 0
63
+ for l: script in globpath (&runtimepath , l: pattern , 1 , 1 , 1 )
64
+ let l: name = fnamemodify (l: script , ' :h:t' )
65
+ if l: name [:0 ] == # ' @' || ! filereadable (l: script )
66
+ continue
67
+ endif
68
+ call denops#plugin#load (l: name , l: script )
69
+ let l: counter += 1
65
70
endfor
71
+ call denops#_internal#echo#debug (printf (' %d plugins are discovered' , l: counter ))
66
72
endfunction
67
73
68
74
function ! denops#plugin#check_type (... ) abort
@@ -93,12 +99,24 @@ function! denops#plugin#register(name, ...) abort
93
99
\ ' denops#plugin#register() is deprecated. Use denops#plugin#load() instead.' ,
94
100
\)
95
101
if a: 0 is # 0 || type (a: 1 ) is # v: t_dict
96
- let l: script = denops#_internal#plugin#find (a: name ). script
102
+ let l: script = s: find_script (a: name )
97
103
else
98
104
let l: script = a: 1
99
105
endif
100
106
return denops#plugin#load (a: name , l: script )
101
107
endfunction
102
108
109
+ function ! s: find_script (name) abort
110
+ const l: pattern = denops#_internal#path#join ([' denops' , a: name , ' main.ts' ])
111
+ for l: script in globpath (&runtimepath , l: pattern , 1 , 1 , 1 )
112
+ let l: name = fnamemodify (l: script , ' :h:t' )
113
+ if l: name [:0 ] == # ' @' || ! filereadable (l: script )
114
+ continue
115
+ endif
116
+ return l: script
117
+ endfor
118
+ throw printf (' Denops plugin "%s" does not exist in the runtimepath' , a: name )
119
+ endfunction
120
+
103
121
call denops#_internal#conf#define (' denops#plugin#wait_interval' , 200 )
104
122
call denops#_internal#conf#define (' denops#plugin#wait_timeout' , 30000 )
0 commit comments