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