summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--autoload/polyglot.vim6
-rw-r--r--heuristics.yaml3
-rw-r--r--scripts/test_filetypes.vim244
-rw-r--r--tests/extensions.vim3
4 files changed, 12 insertions, 244 deletions
diff --git a/autoload/polyglot.vim b/autoload/polyglot.vim
index b7113f31..325287fc 100644
--- a/autoload/polyglot.vim
+++ b/autoload/polyglot.vim
@@ -370,6 +370,12 @@ func! polyglot#DetectHtmlFiletype()
if line =~# '^\(%\|<[%&].*>\)'
set ft=mason | return
endif
+ for lnum in range(1, min([line("$"), 50]))
+ let line = getline(lnum)
+ if line =~# '{{.*}}\|{%-\=\s*\(end.*\|extends\|block\|macro\|set\|if\|for\|include\|trans\)\(\<\|\>\)'
+ set ft=jinja.html | return
+ endif
+ endfor
set ft=html | return
endfunc
diff --git a/heuristics.yaml b/heuristics.yaml
index 35350a69..7cc6a273 100644
--- a/heuristics.yaml
+++ b/heuristics.yaml
@@ -180,5 +180,8 @@ rules:
- lines: 1
pattern: '^(%|<[%&].*>)'
filetype: mason
+- lines: 50
+ pattern: '{{.*}}|{%-?\s*(end.*|extends|block|macro|set|if|for|include|trans)\b'
+ filetype: jinja.html
- filetype: html
diff --git a/scripts/test_filetypes.vim b/scripts/test_filetypes.vim
deleted file mode 100644
index 4ce20e72..00000000
--- a/scripts/test_filetypes.vim
+++ /dev/null
@@ -1,244 +0,0 @@
-function! TestFiletype(filetype)
- call Log('Loading ' . a:filetype . ' filetype...')
-
- try
- enew
- exec 'set ft=' . a:filetype
- catch
- echo 'Error loading filetype ' . a:filetype . ':'
- echo v:exception
- echo v:throwpoint
- exec ':cq!'
- endtry
-endfunction
-
-call TestFiletype('8th')
-call TestFiletype('haproxy')
-call TestFiletype('a2ps')
-call TestFiletype('a65')
-call TestFiletype('aap')
-call TestFiletype('abap')
-call TestFiletype('abaqus')
-call TestFiletype('abc')
-call TestFiletype('abel')
-call TestFiletype('acedb')
-call TestFiletype('asl')
-call TestFiletype('ada')
-call TestFiletype('ahdl')
-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')
-call TestFiletype('aspperl')
-call TestFiletype('atlas')
-call TestFiletype('autoit')
-call TestFiletype('ave')
-call TestFiletype('awk')
-call TestFiletype('caddyfile')
-call TestFiletype('carp')
-call TestFiletype('clojure')
-call TestFiletype('cmake')
-call TestFiletype('coffee')
-call TestFiletype('litcoffee')
-call TestFiletype('cryptol')
-call TestFiletype('crystal')
-call TestFiletype('ecrystal')
-call TestFiletype('csv')
-call TestFiletype('cucumber')
-call TestFiletype('cuesheet')
-call TestFiletype('dart')
-call TestFiletype('dhall')
-call TestFiletype('d')
-call TestFiletype('dcov')
-call TestFiletype('dd')
-call TestFiletype('ddoc')
-call TestFiletype('dsdl')
-call TestFiletype('Dockerfile')
-call TestFiletype('yaml.docker-compose')
-call TestFiletype('elixir')
-call TestFiletype('eelixir')
-call TestFiletype('elm')
-call TestFiletype('ember-script')
-call TestFiletype('emblem')
-call TestFiletype('erlang')
-call TestFiletype('fennel')
-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('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('haskell')
-call TestFiletype('haxe')
-call TestFiletype('hcl')
-call TestFiletype('hive')
-call TestFiletype('html')
-call TestFiletype('i3config')
-call TestFiletype('icalendar')
-call TestFiletype('idris')
-call TestFiletype('idris2')
-call TestFiletype('lidris2')
-call TestFiletype('ion')
-call TestFiletype('Jenkinsfile')
-call TestFiletype('jinja.html')
-call TestFiletype('jq')
-call TestFiletype('json5')
-call TestFiletype('json')
-call TestFiletype('jsonnet')
-call TestFiletype('jst')
-call TestFiletype('julia')
-call TestFiletype('kotlin')
-call TestFiletype('ledger')
-call TestFiletype('less')
-call TestFiletype('lilypond')
-call TestFiletype('livescript')
-call TestFiletype('llvm')
-call TestFiletype('tablegen')
-call TestFiletype('log')
-call TestFiletype('lua')
-call TestFiletype('m4')
-call TestFiletype('mako')
-call TestFiletype('mma')
-call TestFiletype('markdown')
-call TestFiletype('markdown.mdx')
-call TestFiletype('meson')
-call TestFiletype('dosini')
-call TestFiletype('moon')
-call TestFiletype('murphi')
-call TestFiletype('nginx')
-call TestFiletype('nim')
-call TestFiletype('nix')
-call TestFiletype('objc')
-call TestFiletype('ocaml')
-call TestFiletype('omake')
-call TestFiletype('opam')
-call TestFiletype('oasis')
-call TestFiletype('dune')
-call TestFiletype('ocamlbuild_tags')
-call TestFiletype('ocpbuild')
-call TestFiletype('ocpbuildroot')
-call TestFiletype('sexplib')
-call TestFiletype('octave')
-call TestFiletype('opencl')
-call TestFiletype('perl')
-call TestFiletype('pod')
-call TestFiletype('mason')
-call TestFiletype('tt2')
-call TestFiletype('tt2html')
-call TestFiletype('xs')
-call TestFiletype('sql')
-call TestFiletype('cql')
-call TestFiletype('php')
-call TestFiletype('blade')
-call TestFiletype('plantuml')
-call TestFiletype('pony')
-call TestFiletype('ps1')
-call TestFiletype('ps1xml')
-call TestFiletype('proto')
-call TestFiletype('pug')
-call TestFiletype('puppet')
-call TestFiletype('embeddedpuppet')
-call TestFiletype('purescript')
-call TestFiletype('python')
-call TestFiletype('requirements')
-call TestFiletype('qmake')
-call TestFiletype('qml')
-call TestFiletype('r')
-call TestFiletype('rhelp')
-call TestFiletype('racket')
-call TestFiletype('ragel')
-call TestFiletype('raku')
-call TestFiletype('raml')
-call TestFiletype('razor')
-call TestFiletype('reason')
-call TestFiletype('rst')
-call TestFiletype('ruby')
-call TestFiletype('eruby')
-call TestFiletype('ruby')
-call TestFiletype('brewfile')
-call TestFiletype('rust')
-call TestFiletype('scala')
-call TestFiletype('sbt.scala')
-call TestFiletype('scss')
-call TestFiletype('sh')
-call TestFiletype('zsh')
-call TestFiletype('slim')
-call TestFiletype('slime')
-call TestFiletype('smt2')
-call TestFiletype('solidity')
-call TestFiletype('stylus')
-call TestFiletype('svelte')
-call TestFiletype('svg')
-call TestFiletype('swift')
-call TestFiletype('sxhkdrc')
-call TestFiletype('systemd')
-call TestFiletype('terraform')
-call TestFiletype('textile')
-call TestFiletype('thrift')
-call TestFiletype('tmux')
-call TestFiletype('toml')
-call TestFiletype('tptp')
-call TestFiletype('html.twig')
-call TestFiletype('xml.twig')
-call TestFiletype('typescript')
-call TestFiletype('typescriptreact')
-call TestFiletype('unison')
-call TestFiletype('v')
-call TestFiletype('vala')
-call TestFiletype('vbnet')
-call TestFiletype('vcl')
-call TestFiletype('velocity')
-call TestFiletype('vmasm')
-call TestFiletype('vue')
-call TestFiletype('xdc')
-call TestFiletype('xsl')
-call TestFiletype('yaml')
-call TestFiletype('yaml.ansible')
-call TestFiletype('helm')
-call TestFiletype('help')
-call TestFiletype('zephir')
-call TestFiletype('zir')
-call TestFiletype('zig')
-call TestFiletype('trasys')
-call TestFiletype('basic')
-call TestFiletype('vb')
-call TestFiletype('dosini')
-call TestFiletype('odin')
-call TestFiletype('bzl')
-call TestFiletype('prolog')
-call TestFiletype('tads')
diff --git a/tests/extensions.vim b/tests/extensions.vim
index 98a93796..d792ac3c 100644
--- a/tests/extensions.vim
+++ b/tests/extensions.vim
@@ -356,3 +356,6 @@ call TestExtension("tt2html", "html.tt2", "<html>")
call TestExtension("html", "empty.html", "")
call TestExtension("mason", "mason1.html", "% my $planet = 42;")
call TestExtension("mason", "mason2.html", "<%filter></%filter>")
+call TestExtension("jinja.html", "jinja.html", "{{ item.href }}")
+call TestExtension("jinja.html", "jinja.html", "{% for item in navigation %}{% endfor %}")
+call TestExtension("jinja.html", "jinja.html", "{% block head %}")