Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Multi-filetype support #23

Closed
rosenfeld opened this issue Feb 4, 2011 · 4 comments
Closed

Multi-filetype support #23

rosenfeld opened this issue Feb 4, 2011 · 4 comments

Comments

@rosenfeld
Copy link

My GSP files are set to filetype=gsp.html

Is there anyway of telling NERDCommenter to use the rule for 'gsp' instead of 'html'. It doesn't matter if the filetype is set to 'gsp.html' or 'html.gsp'. The 'html' comment type will have precedence. If I set the filetype to 'gsp' only, the comment type for 'GSP' works as expected. It would be great to be able to decide which one to use from NERDCommenter

@scrooloose
Copy link
Collaborator

Hey Rodrigo

What was probably happening was that the filetype was getting set to html by vim's filetype.vim first, then changed to gsp.html by your autocommand. So nerdcommenter was setting up the html delimiters, but then didnt know how to handle the 'gsp.html' filetype and so left the delimiters as html.

Ive pushed a couple of fixes to this. First, if the filetype is compound (e.g. foo.bar.baz) and the script doesnt know how to handle it, it will break down the filetype into its parts and set the delimiters for the first part that it recognizes. So you could set the filetype to gsp.html and gsp comment delimiters will be set.

Also, i have added a new option called NERDCustomDelimiters. This lets you override or add delimiters for unknown filetypes. In short, you could add something like this to your vimrc:

let g:NERDCustomDelimiters = {
\ 'gsp.html': { 'left': '<!--', 'right': '-->', 'leftAlt': '<%--', 'rightAlt': '--%>' }
\ }

If you install the latest dev version you can see :help NERDCustomDelimiters.

HTH :)

@rosenfeld
Copy link
Author

Hi Scrooloose, I've just tested it and it worked great! Thank you a lot!

Let me ask you just one more feature if you don't mind. All GSP files are also HTML files as far as I can tell you. So, it would be great if you could set its alternative comments the same as HTML. Another approach would to automatically set the alternative comment style, when absent, to the main comment style from the second filetype when using multiple filetypes. I still need to set GSP filetype as gsp.html so that I can take advantage of the HTML snippets from the snipMate plugin.

Thank you a lot!

@scrooloose
Copy link
Collaborator

I have added html delimiters as the alternative delimiters for gsp.

Your suggestion about using the next known filetype's main delimiters as the alternative delimiters is pretty good, but for now I think ill keep it simple.

@rosenfeld
Copy link
Author

Thank you very much!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants