@@ -12,36 +12,16 @@ function! s:detect(dir)
12
12
let is_node = 0
13
13
let is_node = is_node || filereadable (dir . " /package.json" )
14
14
let is_node = is_node || isdirectory (dir . " /node_modules" )
15
- if is_node | return node#initialize (dir ) | endif
15
+ if is_node | call node#javascript () | return node#initialize (dir ) | endif
16
16
17
17
let parent = fnamemodify (dir , " :h" )
18
18
if parent == dir | return | endif
19
19
let dir = parent
20
20
endwhile
21
21
endfunction
22
22
23
- function ! s: permutate (ft )
24
- " Don't know right now how to detect javascript.jsx and other permutations
25
- " without precomputing them in advance. Please let me know if you do.
26
- return [a: ft , a: ft . " .*" , " *." . a: ft , " *." . a: ft . " .*" ]
27
- endfunction
28
-
29
- function ! s: flatten (list )
30
- let values = []
31
- for value in a: list
32
- if type (value) == type ([]) | call extend (values , value)
33
- else | add (values , value)
34
- endif
35
- endfor
36
- return values
37
- endfunction
38
-
39
23
augroup Node
40
24
au !
41
- au VimEnter * if empty (expand (" <amatch>" )) | call s: detect (getcwd ()) | endif
42
- au BufRead ,BufNewFile * call s: detect (expand (" <amatch>:p" ))
43
-
44
- let s: filetype_patterns = s: flatten (map (s: filetypes , " <SID>permutate(v:val)" ))
45
- let s: filetype_patterns_joined = join (s: filetype_patterns , " ," )
46
- execute " au FileType " s: filetype_patterns_joined " call node#javascript()"
25
+ let s: filetype_patterns_joined = join (s: filetypes , " ," )
26
+ execute " au FileType " s: filetype_patterns_joined ' call <SID>detect(expand("\<afile>:p"))'
47
27
augroup end
0 commit comments