Glench / Vim-Jinja2-Syntax

An up-to-date jinja2 syntax file.
https://github.com/mitsuhiko/jinja2
BSD 3-Clause "New" or "Revised" License
343 stars 64 forks source link

Twig commentary #28

Open Herz3h opened 3 years ago

Herz3h commented 3 years ago

I'm using this plugin for twig tempaltes which are very similar to jinja ones. But I struggle to use vim-commentary (tpope's plugin) with twig template. When I type gcc (to comment a single line):

Consider this example:

{% block stylesheets %}
    <link rel="stylesheet" href="{{ asset('documents.css') }}">
{% endblock %}

Cursor being at second line, pressing gcc, preprends ## to the line and give this result:

{% block stylesheets %}
##    <link rel="stylesheet" href="{{ cached_asset('js-lib/modele-workflow-save.css') }}">
{% endblock %}

Which is not valid syntax for twig file, instead it should use

{# .... comment here .... #}

How do I change this behavior ?

Glench commented 3 years ago

It looks like you can use vim-commentary's setting to change the comment behavior: https://github.com/tpope/vim-commentary#faq

Herz3h commented 3 years ago

I have tried that but it prefixes the line with # giving:

# .... comment here ....

Which is not valid commentary :/

Glench commented 3 years ago

I think you need to change that line to include the correct comment, so include {# #} in your vin configuration

On Wed, Jul 15, 2020 at 03:20 Ahmed El Moden notifications@github.com wrote:

I have tried that but it prefixes the line with # giving:

.... comment here ....

Which is not valid commentary :/

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/Glench/Vim-Jinja2-Syntax/issues/28#issuecomment-658593250, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADOHBOCOEGJ2VUISZRZPRLR3VKC3ANCNFSM4OWMCEAA .

thanegill commented 3 years ago

@Herz3h This is what you want:

autocmd FileType jinja setlocal commentstring={#\ %s\ #}