askama icon indicating copy to clipboard operation
askama copied to clipboard

suggestions for (neo)vim and intellij code formatting

Open yatesco opened this issue 2 years ago • 0 comments

Hi there - does anybody have any hints on how to configure either vim or IntelliJ so code formatting works.

I am using the example template:

<h1>Hello, {{ name }}!</h1>
<div>
    <a>1</a>
    <a>2</a>
    <a>3</a>
</div>

{% let name = "hi there" %}
{% let len = name.len() %}

{% let val -%}
{% if len == 0 -%}
  {% let val = "foo" -%}
{% else -%}
  {% let val = name -%}
{% endif -%}
{{ val }}

vim

I use https://github.com/neoclide/coc.nvim and I haven't done anything specific to html or ninja templates, but when I format it I get:

<h1>Hello, {{ name }}!</h1>
<div>
  <a>1</a>
  <a>2</a>
  <a>3</a>
</div>

{% let name = "hi there" %} {% let len = name.len() %} {% let val -%} {% if len
== 0 -%} {% let val = "foo" -%} {% else -%} {% let val = name -%} {% endif -%}
{{ val }}

IntelliJ

With the https://plugins.jetbrains.com/plugin/16591-askama-template-support plugin I get the normal HTML stuff, and some basic syntax highlighting, but it doesn't format the askama specific syntax, so, for example, if I paste vim's butchery into it, it leaves it exactly as is. (I've renamed the file extension so the plugin is taking effect).

Any suggestions?

Thanks!

yatesco avatar Jul 28 '22 10:07 yatesco