Skip to content

Commit 5e0ee61

Browse files
committed
🚿 Remove unnecessary internal functions
1 parent 0c5129a commit 5e0ee61

File tree

2 files changed

+23
-30
lines changed

2 files changed

+23
-30
lines changed

autoload/denops/_internal/plugin.vim

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,6 @@ const s:STATE_FAILED = 'failed'
55

66
let s:plugins = {}
77

8-
function! denops#_internal#plugin#collect() abort
9-
const l:pattern = denops#_internal#path#join(['denops', '*', 'main.ts'])
10-
let l:plugins = []
11-
for l:script in globpath(&runtimepath, l:pattern, 1, 1, 1)
12-
let l:name = fnamemodify(l:script, ':h:t')
13-
if l:name[:0] ==# '@' || !filereadable(l:script)
14-
continue
15-
endif
16-
call add(l:plugins, #{ name: l:name, script: l:script })
17-
endfor
18-
return l:plugins
19-
endfunction
20-
21-
function! denops#_internal#plugin#find(name) abort
22-
const l:pattern = denops#_internal#path#join(['denops', a:name, 'main.ts'])
23-
for l:script in globpath(&runtimepath, l:pattern, 1, 1, 1)
24-
let l:name = fnamemodify(l:script, ':h:t')
25-
if l:name[:0] ==# '@' || !filereadable(l:script)
26-
continue
27-
endif
28-
return #{ name: l:name, script: l:script }
29-
endfor
30-
throw printf('Denops plugin "%s" does not exist in the runtimepath', a:name)
31-
endfunction
32-
338
function! denops#_internal#plugin#get(name) abort
349
if !has_key(s:plugins, a:name)
3510
let s:plugins[a:name] = #{name: a:name, script: '', state: s:STATE_RESERVED, callbacks: []}

autoload/denops/plugin.vim

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,17 @@ function! denops#plugin#reload(name) abort
5858
endfunction
5959

6060
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
6570
endfor
71+
call denops#_internal#echo#debug(printf('%d plugins are discovered', l:counter))
6672
endfunction
6773

6874
function! denops#plugin#check_type(...) abort
@@ -93,12 +99,24 @@ function! denops#plugin#register(name, ...) abort
9399
\ 'denops#plugin#register() is deprecated. Use denops#plugin#load() instead.',
94100
\)
95101
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)
97103
else
98104
let l:script = a:1
99105
endif
100106
return denops#plugin#load(a:name, l:script)
101107
endfunction
102108

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+
103121
call denops#_internal#conf#define('denops#plugin#wait_interval', 200)
104122
call denops#_internal#conf#define('denops#plugin#wait_timeout', 30000)

0 commit comments

Comments
 (0)