File tree 1 file changed +11
-7
lines changed
1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change 1
- function ! DetectCfn (type )
1
+ function ! DetectCfn ()
2
2
let likely = 0
3
3
let pointsRequired = 10
4
4
@@ -50,16 +50,20 @@ function! DetectCfn(type)
50
50
\[ ' Resources' , 1 ],
51
51
\[ ' Outputs' , 1 ],
52
52
\]
53
+ let json_type = 0
53
54
for lineContents in getline (1 , line (' $' ))
54
55
for strPoints in pointMap
55
56
if lineContents = ~ strPoints[0 ]
56
57
let likely += strPoints[1 ]
57
58
endif
59
+ if lineContents = ~ " ^\s *\{ "
60
+ let json_type = 1
61
+ endif
58
62
if likely > pointsRequired
59
- if a: type = ~ " yaml"
60
- set filetype = yaml.cloudformation
61
- elseif a: type = ~ " json"
63
+ if json_type == 1
62
64
set filetype = json.cloudformation
65
+ else
66
+ set filetype = yaml.cloudformation
63
67
endif
64
68
return
65
69
endif
@@ -68,7 +72,7 @@ function! DetectCfn(type)
68
72
endfunction
69
73
70
74
augroup filetypedetect
71
- au BufRead ,BufNewFile *.yaml,*.yml call DetectCfn (' yaml ' )
72
- au BufRead ,BufNewFile *.json call DetectCfn (' json ' )
73
- au BufNewFile ,BufRead *.template setfiletype yaml.cloudformation
75
+ au BufRead ,BufNewFile *.yaml,*.yml call DetectCfn ()
76
+ au BufRead ,BufNewFile *.json call DetectCfn ()
77
+ au BufNewFile ,BufRead *.template call DetectCfn ()
74
78
augroup END
You can’t perform that action at this time.
0 commit comments