summaryrefslogtreecommitdiffstats
path: root/scripts/build
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2020-09-01 23:02:36 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2020-09-01 23:02:36 +0200
commitf2ef4cedecf554c0c9f0694f93df1d53a57bf70c (patch)
treeee95ac48f56aee9607aa3c92fe478cf63f9c26b7 /scripts/build
parent45c1923f43f2bb2e626fe910654d4395a0e50a04 (diff)
downloadvim-polyglot-4.7.1.tar.gz
vim-polyglot-4.7.1.zip
Fix reason filetype detection, closes #532v4.7.1
Diffstat (limited to 'scripts/build')
-rwxr-xr-xscripts/build14
1 files changed, 11 insertions, 3 deletions
diff --git a/scripts/build b/scripts/build
index 384c8423..1fe148e7 100755
--- a/scripts/build
+++ b/scripts/build
@@ -202,9 +202,17 @@ def indent(str, amount)
end
def pattern_to_condition(rule)
+ if rule.has_key?("or")
+ return rule["or"].map { |p| pattern_to_condition(p) }.join(" || ")
+ end
+
+ if rule.has_key?("or")
+ return rule["and"].map { |p| pattern_to_condition(p) }.join(" && ")
+ end
+
operator = (rule["negative"] ? "!" : "=") + "~" + (rule["ignore_case"] ? "?" : "#")
- "line #{operator} '#{rule["pattern"]}'"
+ return "line #{operator} '#{rule["pattern"]}'"
end
def rules_to_code(rules)
@@ -250,10 +258,10 @@ def rule_to_code(rule)
return rule["rules"].map { |r| indent(rule_to_code(r), 0) }.join("\n")
end
- if rule.has_key?("pattern")
+ if rule.has_key?("pattern") || rule.has_key?("or") || rule.has_key?("and")
return <<~EOS
if #{pattern_to_condition(rule)}
- #{indent(rule_to_code(except(rule, "pattern", "ignore_case", "negative")), 2)}
+ #{indent(rule_to_code(except(rule, "pattern", "or", "and", "ignore_case", "negative")), 2)}
endif
EOS
end