mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-10 04:23:51 -05:00
Disable languages also from heuristics, fixes #673
This commit is contained in:
@@ -53,16 +53,16 @@ func! polyglot#detect#H(...)
|
|||||||
for lnum in range(1, min([line("$"), 200]))
|
for lnum in range(1, min([line("$"), 200]))
|
||||||
let line = getline(lnum)
|
let line = getline(lnum)
|
||||||
if line =~# '^\s*\(@\(interface\|class\|protocol\|property\|end\|synchronised\|selector\|implementation\)\(\<\|\>\)\|#import\s\+.\+\.h[">]\)'
|
if line =~# '^\s*\(@\(interface\|class\|protocol\|property\|end\|synchronised\|selector\|implementation\)\(\<\|\>\)\|#import\s\+.\+\.h[">]\)'
|
||||||
if exists("g:c_syntax_for_h")
|
if exists('g:c_syntax_for_h')
|
||||||
set ft=objc | return
|
set ft=objc | return
|
||||||
endif
|
endif
|
||||||
set ft=objcpp | return
|
set ft=objcpp | return
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
if exists("g:c_syntax_for_h")
|
if exists('g:c_syntax_for_h')
|
||||||
set ft=c | return
|
set ft=c | return
|
||||||
endif
|
endif
|
||||||
if exists("g:ch_syntax_for_h")
|
if exists('g:ch_syntax_for_h')
|
||||||
set ft=ch | return
|
set ft=ch | return
|
||||||
endif
|
endif
|
||||||
set ft=cpp | return
|
set ft=cpp | return
|
||||||
@@ -82,8 +82,15 @@ func! polyglot#detect#M(...)
|
|||||||
set ft=objc | return
|
set ft=objc | return
|
||||||
endif
|
endif
|
||||||
if line =~# '^\s*%'
|
if line =~# '^\s*%'
|
||||||
|
if !has_key(g:polyglot_is_disabled, 'octave')
|
||||||
set ft=octave | return
|
set ft=octave | return
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
if line =~# '^\s*%'
|
||||||
|
if has_key(g:polyglot_is_disabled, 'octave')
|
||||||
|
set ft=matlab | return
|
||||||
|
endif
|
||||||
|
endif
|
||||||
if line =~# '^\s*(\*'
|
if line =~# '^\s*(\*'
|
||||||
set ft=mma | return
|
set ft=mma | return
|
||||||
endif
|
endif
|
||||||
@@ -97,7 +104,12 @@ func! polyglot#detect#M(...)
|
|||||||
if exists("g:filetype_m")
|
if exists("g:filetype_m")
|
||||||
let &ft = g:filetype_m | return
|
let &ft = g:filetype_m | return
|
||||||
endif
|
endif
|
||||||
|
if !has_key(g:polyglot_is_disabled, 'octave')
|
||||||
set ft=octave | return
|
set ft=octave | return
|
||||||
|
endif
|
||||||
|
if has_key(g:polyglot_is_disabled, 'octave')
|
||||||
|
set ft=matlab | return
|
||||||
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func! polyglot#detect#Fs(...)
|
func! polyglot#detect#Fs(...)
|
||||||
|
|||||||
@@ -28,12 +28,12 @@ rules:
|
|||||||
- lines: 200
|
- lines: 200
|
||||||
pattern: '^\s*(@(interface|class|protocol|property|end|synchronised|selector|implementation)\b|#import\s+.+\.h[">])'
|
pattern: '^\s*(@(interface|class|protocol|property|end|synchronised|selector|implementation)\b|#import\s+.+\.h[">])'
|
||||||
rules:
|
rules:
|
||||||
- if_exists: "g:c_syntax_for_h"
|
- if: "exists('g:c_syntax_for_h')"
|
||||||
filetype: objc
|
filetype: objc
|
||||||
- filetype: objcpp
|
- filetype: objcpp
|
||||||
- if_exists: "g:c_syntax_for_h"
|
- if: "exists('g:c_syntax_for_h')"
|
||||||
filetype: c
|
filetype: c
|
||||||
- if_exists: "g:ch_syntax_for_h"
|
- if: "exists('g:ch_syntax_for_h')"
|
||||||
filetype: ch
|
filetype: ch
|
||||||
- filetype: cpp
|
- filetype: cpp
|
||||||
---
|
---
|
||||||
@@ -46,16 +46,23 @@ rules:
|
|||||||
- pattern: '^\s*(@(interface|class|protocol|property|end|synchronised|selector|implementation)\b|#import\s+.+\.h[">])'
|
- pattern: '^\s*(@(interface|class|protocol|property|end|synchronised|selector|implementation)\b|#import\s+.+\.h[">])'
|
||||||
filetype: objc
|
filetype: objc
|
||||||
- pattern: '^\s*%'
|
- pattern: '^\s*%'
|
||||||
|
if: "!has_key(g:polyglot_is_disabled, 'octave')"
|
||||||
filetype: octave
|
filetype: octave
|
||||||
|
- pattern: '^\s*%'
|
||||||
|
if: "has_key(g:polyglot_is_disabled, 'octave')"
|
||||||
|
filetype: matlab
|
||||||
- pattern: '^\s*\(\*'
|
- pattern: '^\s*\(\*'
|
||||||
filetype: mma
|
filetype: mma
|
||||||
- pattern: '^\s*((type|var)\b|--)'
|
- pattern: '^\s*((type|var)\b|--)'
|
||||||
ignore_case: true
|
ignore_case: true
|
||||||
filetype: murphi
|
filetype: murphi
|
||||||
- if_set: "saw_comment"
|
- if: "saw_comment"
|
||||||
filetype: objc
|
filetype: objc
|
||||||
- override: true
|
- override: true
|
||||||
- filetype: octave
|
- filetype: octave
|
||||||
|
if: "!has_key(g:polyglot_is_disabled, 'octave')"
|
||||||
|
- filetype: matlab
|
||||||
|
if: "has_key(g:polyglot_is_disabled, 'octave')"
|
||||||
---
|
---
|
||||||
extensions: [fs]
|
extensions: [fs]
|
||||||
rules:
|
rules:
|
||||||
|
|||||||
@@ -427,18 +427,10 @@ def rule_to_code(rule)
|
|||||||
end.join("\n")
|
end.join("\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
if rule.has_key?("if_set")
|
if rule.has_key?("if")
|
||||||
return <<~EOS
|
return <<~EOS
|
||||||
if #{rule["negative"] ? "!" : ""}#{rule["if_set"]}
|
if #{rule["if"]}
|
||||||
#{indent(rule_to_code(except(rule, "if_set", "negative")), 2)}
|
#{indent(rule_to_code(except(rule, "if")), 2)}
|
||||||
endif
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
|
|
||||||
if rule.has_key?("if_exists")
|
|
||||||
return <<~EOS
|
|
||||||
if #{rule["negative"] ? "!" : ""}exists("#{rule["if_exists"]}")
|
|
||||||
#{indent(rule_to_code(except(rule, "if_exists", "negative")), 2)}
|
|
||||||
endif
|
endif
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user