tcomment doesn't seem to handle dotted filetype syntax very nicely.
What really bugs me is this: if I visualy select these two lines and gc them
<!-- A comment. -->
If my filetype is xml I get
<!-- <gel:out>Hello World!</gel:out> -->
<!-- <!-- A comment. --> -->
If my filetype is jelly.xml I get
<!--<!-- A comment. -->-->
The second line is not well formed xml.
Also, when editting an XML file, a linewise comment will include spaces between the original text and the comment markers, e.g.:
<!-- <sometag name="blablabla"/> -->
That is if the filetype is xml. If, however, the filetype is jelly.xml, the result will be
That is a minor annoyance, but I run into it all the time because I like to type my comments raw and then select them to comment.
Maybe I missed something: is this sort of sub-filetype officially supported by vim?
IIRC I originally added this for eruby or something similar. In that case "FT1.FT2" actually wants comments to be in FT1 style. In your case, it's the other way around. tcomment would expect that filetype to be "xml.jelly".
I can add a "map" dictionary to map those special cases onto the right filetype. For this I had to know what is the more right way to construct such compound filenames.
Do you use a plugin that uses "jelly.xml"?
Hi Tom, thanks for the speedy reply!
I don't think you missed anything, I saw this dotted filetype thing in UltiSnips and just assumed it was a general vim thing, but I can't find it anywhere else then UltiSnips or snipMate documentation. My bad, sorry.
(Still, syntax highlighting works, so I don't know really just how much official support it has...)
However, it would be a nice thing to have anyway, so maybe consider this a feature request? :)
As for the order, yes, I use jelly.xml, the logic behind it is that jelly is a special kind of xml, so anything defined for the jelly filetype supersedes stuff defined do xml, and anything found for xml and not for jelly would be "active".
So, in this particular case, I would like tcomment to detect that I don't have comments defined for the jelly filetype and just use whatever it uses for xml. As I said, it already does this to some extent (which is why I thought this whole thing was supported in the first place) but it's not perfect.
Also, if this is not possible, I would like to know if there is any way I can write a plugin that will ship with tcomment support for a new filetype. I ask this because, despite it making sense to include official support for jelly in tcomment, I actualy work with a very specific jelly variation called gelscript. I don't think any other unfortunate soul that has to work with this filetype uses vim anyway (yet! we'll see when I finish my plugin...)
Reading my comment above I realize I was not very clear and I don't know how I can edit it to make it better, but xml.jelly works just fine!
Unfortunately it conflicts with the way UltiSnips uses the dotted filetype syntax, so what I am really asking for is an option to interpret the dotted.filetype the other way around.
More flexible handling of "dotted" filetypes (fixes #45)
Could you please check if this version works better? I hope it doesn't break things for eruby users.
It works great, thank you!
I don't know any eruby or even ruby so I can't really test it, sorry...
I edit eruby often, and use the plugins tcomment, neosnippet and vim-rails. In order to utilize the snippets for view files(eruby, snippets put under "snippets/rails-views), I have an autocommand in vimrc
autocmd User Rails.view* set filetype=rails-views.eruby
Everything works fine except commenting. When I hit gcc in a line, tcomment will report error E767: too many arguments for printf()
E767: too many arguments for printf()
If I run :set ft=eruby and run gcc again, everything is perfect. HTML get html comment and ruby tags get ruby comment.
If I switch the filetype order to run :set ft=eruby.rails-views, eruby syntax highlight broken. When I run gcc over lines, all of them get ruby comments including HTML lines.
I wonder if there is any workaround to make mutiple filetypes working, with "eruby" at the end? Even a special setting tailored to this filetype in vimrc is okay.
Thanks a lot!
s:GuessFileType(): If there is no custom definition for the fallback …
…filetype, use the filetype (fixes #45)
g:tcomment#filetype_map now works on filetype parts (when using dotte…
…d filetype) & special support for rails-views (fixes #45)
The new commit works perfectly now. Here is the effect:
If I select two lines and hit gc:
<!-- <div class="published_at"> -->
<!-- <%= @post.published_at %> -->
If I only hit gcc on the second line:
<%# <%= @post.published_at %>
And when I hit gcc again all lines could be back.
Thanks a lot, Tom!