summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build26
-rwxr-xr-xscripts/test2
-rw-r--r--scripts/test_extensions.vim2
-rw-r--r--scripts/test_filetypes.vim28
4 files changed, 29 insertions, 29 deletions
diff --git a/scripts/build b/scripts/build
index b100b80a..07bc301b 100755
--- a/scripts/build
+++ b/scripts/build
@@ -29,15 +29,8 @@ def load_data()
deps = Hash.new { |h, k| h[k] = [] }
- for package in packages.values
- for name in [package.fetch("after", [])].flatten
- packages[name] or raise "#{package["name"]} depends on unknown package: #{name}"
- deps[name] << package["name"]
- end
- end
-
each_node = lambda {|&b| packages.keys.each(&b) }
- each_child = lambda {|n, &b| deps[n].each(&b) }
+ each_child = lambda {|n, &b| [packages[n].fetch("after", [])].flatten.each(&b) }
languages = load_languages
@@ -327,13 +320,13 @@ def rule_to_code(rule)
if rule.has_key?("override")
return <<~EOS
if exists("#{rule["override"]}")
- exe "setf " . #{rule["override"]} | return
+ call s:Setf(#{rule["override"]}) | return
endif
EOS
end
if rule.has_key?("filetype")
- return "setf #{rule["filetype"]} | return"
+ return "call s:Setf('#{rule["filetype"]}') | return"
end
return ""
@@ -350,8 +343,7 @@ def extract(packages)
FileUtils.rm_rf(all_dirs)
output = []
- # We need to reverse packages so they are included in proper order
- packages.reverse.map do |package|
+ packages.map do |package|
repo, branch, path, dir = parse_remote(package["remote"])
dirs = package.fetch("dirs", default_dirs)
ignored_dirs = package.fetch("ignored_dirs", [])
@@ -462,7 +454,7 @@ def generate_ftdetect(packages, heuristics)
name = filetype.fetch("name")
syntax = filetype["syntax"] ? " | set syntax=#{filetype["syntax"]}" : ""
- set_command = "setf #{name}"
+ set_command = "call s:Setf('#{name}')"
if filetype["syntax"]
set_command = "if !did_filetype() | set ft=#{name} syntax=#{filetype["syntax"]} | endif"
@@ -544,6 +536,14 @@ def generate_ftdetect(packages, heuristics)
let s:cpo_save = &cpo
set cpo&vim
+ " We need it because scripts.vim in vim uses "set ft=" which cannot be
+ " overridden with setf (and we can't use set ft= so our scripts.vim work)
+ func! s:Setf(ft)
+ if &filetype !~# '\<'.a:ft.'\>'
+ let &filetype = a:ft
+ endif
+ endfunc
+
func! polyglot#Heuristics()
" Try to detect filetype from shebang
let l:filetype = polyglot#Shebang()
diff --git a/scripts/test b/scripts/test
index e5418fa4..9e023bb9 100755
--- a/scripts/test
+++ b/scripts/test
@@ -6,7 +6,7 @@ vim --clean -N -u <(echo "
let &rtp='$PWD,'.&rtp
let g:polyglot_test = 1
source scripts/test_extensions.vim
- \"source scripts/test_filetypes.vim
+ source scripts/test_filetypes.vim
qa!
")
diff --git a/scripts/test_extensions.vim b/scripts/test_extensions.vim
index b0dad298..f2aaf66c 100644
--- a/scripts/test_extensions.vim
+++ b/scripts/test_extensions.vim
@@ -6,7 +6,7 @@ function! TestExtension(filetype, filename, content)
1delete _
filetype detect
exec "if &filetype != '" . a:filetype . "' \nthrow &filetype\nendif"
- exec ":q!"
+ exec ":bw!"
catch
echo g:message
echo "Filename '" . a:filename . "' does not resolve to extension '" . a:filetype . "'"
diff --git a/scripts/test_filetypes.vim b/scripts/test_filetypes.vim
index 4d7cc0d8..a84b39e3 100644
--- a/scripts/test_filetypes.vim
+++ b/scripts/test_filetypes.vim
@@ -11,6 +11,7 @@ function! TestFiletype(filetype)
endfunction
call TestFiletype('8th')
+call TestFiletype('haproxy')
call TestFiletype('a2ps')
call TestFiletype('a65')
call TestFiletype('aap')
@@ -26,16 +27,20 @@ call TestFiletype('aidl')
call TestFiletype('alsaconf')
call TestFiletype('aml')
call TestFiletype('ampl')
+call TestFiletype('xml')
call TestFiletype('ant')
call TestFiletype('apache')
call TestFiletype('apiblueprint')
call TestFiletype('applescript')
call TestFiletype('aptconf')
call TestFiletype('arch')
+call TestFiletype('cpp')
+call TestFiletype('c')
call TestFiletype('arduino')
call TestFiletype('art')
call TestFiletype('asciidoc')
call TestFiletype('autohotkey')
+call TestFiletype('elf')
call TestFiletype('automake')
call TestFiletype('asn')
call TestFiletype('aspvbs')
@@ -44,9 +49,6 @@ call TestFiletype('atlas')
call TestFiletype('autoit')
call TestFiletype('ave')
call TestFiletype('awk')
-call TestFiletype('reason')
-call TestFiletype('cpp')
-call TestFiletype('c')
call TestFiletype('caddyfile')
call TestFiletype('carp')
call TestFiletype('clojure')
@@ -61,7 +63,6 @@ call TestFiletype('cucumber')
call TestFiletype('cuesheet')
call TestFiletype('dart')
call TestFiletype('dhall')
-call TestFiletype('grub')
call TestFiletype('d')
call TestFiletype('dcov')
call TestFiletype('dd')
@@ -69,7 +70,6 @@ call TestFiletype('ddoc')
call TestFiletype('dsdl')
call TestFiletype('Dockerfile')
call TestFiletype('yaml.docker-compose')
-call TestFiletype('elf')
call TestFiletype('elixir')
call TestFiletype('eelixir')
call TestFiletype('elm')
@@ -81,23 +81,26 @@ call TestFiletype('ferm')
call TestFiletype('fish')
call TestFiletype('fbs')
call TestFiletype('forth')
+call TestFiletype('glsl')
call TestFiletype('fsharp')
call TestFiletype('gdscript3')
call TestFiletype('gitconfig')
call TestFiletype('gitrebase')
call TestFiletype('gitsendemail')
call TestFiletype('gitcommit')
-call TestFiletype('glsl')
call TestFiletype('gmpl')
call TestFiletype('gnuplot')
call TestFiletype('go')
call TestFiletype('gomod')
call TestFiletype('gohtmltmpl')
+call TestFiletype('javascript')
+call TestFiletype('flow')
+call TestFiletype('javascriptreact')
call TestFiletype('graphql')
call TestFiletype('groovy')
+call TestFiletype('grub')
call TestFiletype('haml')
call TestFiletype('mustache')
-call TestFiletype('haproxy')
call TestFiletype('haskell')
call TestFiletype('haxe')
call TestFiletype('hcl')
@@ -109,9 +112,6 @@ call TestFiletype('idris')
call TestFiletype('idris2')
call TestFiletype('lidris2')
call TestFiletype('ion')
-call TestFiletype('javascriptreact')
-call TestFiletype('javascript')
-call TestFiletype('flow')
call TestFiletype('Jenkinsfile')
call TestFiletype('jinja.html')
call TestFiletype('jq')
@@ -131,7 +131,6 @@ call TestFiletype('log')
call TestFiletype('lua')
call TestFiletype('m4')
call TestFiletype('mako')
-call TestFiletype('octave')
call TestFiletype('mma')
call TestFiletype('markdown')
call TestFiletype('markdown.mdx')
@@ -152,12 +151,13 @@ call TestFiletype('ocamlbuild_tags')
call TestFiletype('ocpbuild')
call TestFiletype('ocpbuildroot')
call TestFiletype('sexplib')
+call TestFiletype('octave')
call TestFiletype('opencl')
call TestFiletype('perl')
call TestFiletype('sql')
call TestFiletype('cql')
-call TestFiletype('blade')
call TestFiletype('php')
+call TestFiletype('blade')
call TestFiletype('plantuml')
call TestFiletype('pony')
call TestFiletype('ps1')
@@ -178,6 +178,7 @@ call TestFiletype('ragel')
call TestFiletype('raku')
call TestFiletype('raml')
call TestFiletype('razor')
+call TestFiletype('reason')
call TestFiletype('rst')
call TestFiletype('ruby')
call TestFiletype('eruby')
@@ -218,10 +219,9 @@ call TestFiletype('velocity')
call TestFiletype('vmasm')
call TestFiletype('vue')
call TestFiletype('xdc')
-call TestFiletype('xml')
call TestFiletype('xsl')
-call TestFiletype('yaml.ansible')
call TestFiletype('yaml')
+call TestFiletype('yaml.ansible')
call TestFiletype('helm')
call TestFiletype('help')
call TestFiletype('zephir')