diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2021-06-09 14:23:57 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2021-06-09 14:23:57 +0200 |
commit | f05dea8dd765b0ce5b6c6ea92b049a5ae7547180 (patch) | |
tree | fa6b1381d5eb99e24d177e4ffd73697bb944e8f1 | |
parent | e3ad29ce799fd94e7e3e5617443761c1e24b37de (diff) | |
download | vim-polyglot-f05dea8dd765b0ce5b6c6ea92b049a5ae7547180.tar.gz vim-polyglot-f05dea8dd765b0ce5b6c6ea92b049a5ae7547180.zip |
Disable languages also from heuristics, fixes #673
-rw-r--r-- | autoload/polyglot/detect.vim | 22 | ||||
-rw-r--r-- | heuristics.yaml | 15 | ||||
-rwxr-xr-x | scripts/build | 14 |
3 files changed, 31 insertions, 20 deletions
diff --git a/autoload/polyglot/detect.vim b/autoload/polyglot/detect.vim index b1b5d6d7..cac826cf 100644 --- a/autoload/polyglot/detect.vim +++ b/autoload/polyglot/detect.vim @@ -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(...) diff --git a/heuristics.yaml b/heuristics.yaml index 23f63bb4..fd7fbe94 100644 --- a/heuristics.yaml +++ b/heuristics.yaml @@ -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: diff --git a/scripts/build b/scripts/build index 7d278a8a..77d71cdd 100755 --- a/scripts/build +++ b/scripts/build @@ -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 |