Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Force comment type in file? #223

Open
eirabben opened this issue Aug 24, 2018 · 4 comments
Open

Force comment type in file? #223

eirabben opened this issue Aug 24, 2018 · 4 comments

Comments

@eirabben
Copy link

Is there any way to force a single comment type in a file?

I have a twig file like this:

{% extends '_layouts/default' %}

{% block content %}
  <section>
    <p>404</p>
    </section>
{% endblock %}

When commenting with Tcomment, it uses html style comments by default. If I set the commentstring using autocmd FileType html.twig setlocal commentstring=\{#%s#\} or call tcomment#type#Define('html.twig', '{# %s #}') it uses Twig comments on the lines that start with Twig syntax, but not on lines starting with HTML.

I would like all comments in the file to be Twig comments. Is there any way to do this?

@tomtom
Copy link
Owner

tomtom commented Aug 24, 2018 via email

@eirabben
Copy link
Author

eirabben commented Aug 24, 2018

The filetype is html.twig. But none of these seem to work for me, neither does g:tcomment#filetype#guess_html_twig. I still get HTML comments on HTML lines and block comments with multiple lines.

I am using sheerun/vim-polyglot for the Twig syntax, if that makes a difference.

@tomtom
Copy link
Owner

tomtom commented Aug 24, 2018 via email

@eirabben
Copy link
Author

Ok, so this works for me:

autocmd FileType html.twig setlocal commentstring=\{#%s#\} in init.vim
Running let g:tcomment#filetype#map['html.twig'] = 'twig' after using the plugin once

Is there a way to automate execution of the plugin so it can run every time i open a Twig file?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants