Open gardar opened 4 years ago
What is the file type you are using? Do you use any jinja2 plugin?
I don't believe there is an official file extension, but from what I've seen .j2 .jinja and .jinja2 are widely accepted I'm mostly working with jinja in ansible and then It's usually with the .j2 file extension.
I do have the following set: au BufRead,BufNewFile *.j2 setfiletype jinja
Other than that I'm currently just using a pretty minimal setup of nvim with deoplete, but I don't think deoplete or deoplete-jedi has any affect on jinja files.
Should be possible to define a set of regexes for the jinja tags, like
au FileType jinja let b:match_words = get(b:, 'match_words', '')
\ . ',{%-\?\s*if.\{-}-\?%}:{%-\?\s*else\s*-\?%}:{%-\?*\s*endif\s*-\?%}'
\ . ',{%-\?\s*for.\{-}-\?%}:{%-\?\s*endfor\s*-\?%}'
Supporting this in general is hard because it depends on the underlying filetype- I guess usually it is html (e.g., https://github.com/Glench/Vim-Jinja2-Syntax/), but in your case you don't seem to have an html document filetype at all.
I opened an issue for that plugin (https://github.com/Glench/Vim-Jinja2-Syntax/issues/29) , but actually I it may be related to Match-up.
For the moment, Vim-Jinja2-Syntax does not match multi-line statements:
{% for very_long in dict
if true and not false %}
[...]
{% endfor %}
I tried to fix that by just adding \_
on the last line (and I don't quite understand the other stuff, its looks quite like magic :sweat_smile: ) [Edit: I just realized the other 3 lines are just from the html file of Matchup.]
let b:match_words = '<:>,' .
\ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' .
\ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' .
\ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>,' .
\ '{%[-+]\? *\%(end\)\@!\(\w\+\)\>\_.\{-}%}:{%-\? *end\1\>.\{-}%}'
Here is the error I get when the cursor hits endfor
:
Error detected while processing function 5[3]..6[82]..matchup#delim#get_matching[20]..<SNR>134_get_matching_delims:
line 101:
E684: list index out of range: 0
(Sorry if this should go in its own issue)
Could we get support for jinja2?
For: {% if %} {% else %} {% endif %} {% for %} {% endfor %} etc.
Related to #68 since jinja2 originates from python but imo shouldn't necessarily depend on python being supported.