File tree Expand file tree Collapse file tree 3 files changed +31
-20
lines changed Expand file tree Collapse file tree 3 files changed +31
-20
lines changed Original file line number Diff line number Diff line change @@ -53,16 +53,16 @@ func! polyglot#detect#H(...)
53
53
for lnum in range (1 , min ([line (" $" ), 200 ]))
54
54
let line = getline (lnum)
55
55
if line = ~# ' ^\s*\(@\(interface\|class\|protocol\|property\|end\|synchronised\|selector\|implementation\)\(\<\|\>\)\|#import\s\+.\+\.h[">]\)'
56
- if exists (" g:c_syntax_for_h" )
56
+ if exists (' g:c_syntax_for_h' )
57
57
set ft = objc | return
58
58
endif
59
59
set ft = objcpp | return
60
60
endif
61
61
endfor
62
- if exists (" g:c_syntax_for_h" )
62
+ if exists (' g:c_syntax_for_h' )
63
63
set ft = c | return
64
64
endif
65
- if exists (" g:ch_syntax_for_h" )
65
+ if exists (' g:ch_syntax_for_h' )
66
66
set ft = ch | return
67
67
endif
68
68
set ft = cpp | return
@@ -82,7 +82,14 @@ func! polyglot#detect#M(...)
82
82
set ft = objc | return
83
83
endif
84
84
if line = ~# ' ^\s*%'
85
- set ft = octave | return
85
+ if ! has_key (g: polyglot_is_disabled , ' octave' )
86
+ set ft = octave | return
87
+ endif
88
+ endif
89
+ if line = ~# ' ^\s*%'
90
+ if has_key (g: polyglot_is_disabled , ' octave' )
91
+ set ft = matlab | return
92
+ endif
86
93
endif
87
94
if line = ~# ' ^\s*(\*'
88
95
set ft = mma | return
@@ -97,7 +104,12 @@ func! polyglot#detect#M(...)
97
104
if exists (" g:filetype_m" )
98
105
let &ft = g: filetype_m | return
99
106
endif
100
- set ft = octave | return
107
+ if ! has_key (g: polyglot_is_disabled , ' octave' )
108
+ set ft = octave | return
109
+ endif
110
+ if has_key (g: polyglot_is_disabled , ' octave' )
111
+ set ft = matlab | return
112
+ endif
101
113
endfunc
102
114
103
115
func ! polyglot#detect#Fs (... )
Original file line number Diff line number Diff line change @@ -28,12 +28,12 @@ rules:
28
28
- lines : 200
29
29
pattern : ' ^\s*(@(interface|class|protocol|property|end|synchronised|selector|implementation)\b|#import\s+.+\.h[">])'
30
30
rules :
31
- - if_exists : " g:c_syntax_for_h"
31
+ - if : " exists(' g:c_syntax_for_h') "
32
32
filetype : objc
33
33
- filetype : objcpp
34
- - if_exists : " g:c_syntax_for_h"
34
+ - if : " exists(' g:c_syntax_for_h') "
35
35
filetype : c
36
- - if_exists : " g:ch_syntax_for_h"
36
+ - if : " exists(' g:ch_syntax_for_h') "
37
37
filetype : ch
38
38
- filetype : cpp
39
39
---
@@ -46,16 +46,23 @@ rules:
46
46
- pattern : ' ^\s*(@(interface|class|protocol|property|end|synchronised|selector|implementation)\b|#import\s+.+\.h[">])'
47
47
filetype : objc
48
48
- pattern : ' ^\s*%'
49
+ if : " !has_key(g:polyglot_is_disabled, 'octave')"
49
50
filetype : octave
51
+ - pattern : ' ^\s*%'
52
+ if : " has_key(g:polyglot_is_disabled, 'octave')"
53
+ filetype : matlab
50
54
- pattern : ' ^\s*\(\*'
51
55
filetype : mma
52
56
- pattern : ' ^\s*((type|var)\b|--)'
53
57
ignore_case : true
54
58
filetype : murphi
55
- - if_set : " saw_comment"
59
+ - if : " saw_comment"
56
60
filetype : objc
57
61
- override : true
58
62
- filetype : octave
63
+ if : " !has_key(g:polyglot_is_disabled, 'octave')"
64
+ - filetype : matlab
65
+ if : " has_key(g:polyglot_is_disabled, 'octave')"
59
66
---
60
67
extensions : [fs]
61
68
rules :
Original file line number Diff line number Diff line change @@ -427,18 +427,10 @@ def rule_to_code(rule)
427
427
end . join ( "\n " )
428
428
end
429
429
430
- if rule . has_key? ( "if_set " )
430
+ if rule . has_key? ( "if " )
431
431
return <<~EOS
432
- if #{ rule [ "negative" ] ? "!" : "" } #{ rule [ "if_set" ] }
433
- #{ indent ( rule_to_code ( except ( rule , "if_set" , "negative" ) ) , 2 ) }
434
- endif
435
- EOS
436
- end
437
-
438
- if rule . has_key? ( "if_exists" )
439
- return <<~EOS
440
- if #{ rule [ "negative" ] ? "!" : "" } exists("#{ rule [ "if_exists" ] } ")
441
- #{ indent ( rule_to_code ( except ( rule , "if_exists" , "negative" ) ) , 2 ) }
432
+ if #{ rule [ "if" ] }
433
+ #{ indent ( rule_to_code ( except ( rule , "if" ) ) , 2 ) }
442
434
endif
443
435
EOS
444
436
end
You can’t perform that action at this time.
0 commit comments