slim-template/vim-slim

Vim sets filetype to HTML (not Slim) when using 'doctype html'

patricklewis opened this issue · 15 comments

I was editing my Rails application layout file in Vim 7.3 with this vim-slim plugin installed and noticed that Vim was using a filetype of HTML instead of Slim for my application.html.slim file and not providing syntax highlighting.

My other views that followed the *.html.slim naming convention were correctly using the Slim filetype and syntax.

The culprit seemed to be the first line of the file, which was doctype html. I changed it to the equivalent doctype 5 and now Vim correctly sets the filetype to Slim for this file.

Same here.

👍 Yep… same thing here.

Any idea why this happens or how to fix it?

I thought Vim uses only the extension for resolving the type

This is the change that broke it for me… 1e4e488#commitcomment-3871242

When I revert it, it works just fine. Good catch on the doctype thing though… now we just need to figure out why.

1e4e488 should be reverted.

Vim's filetype.vim has an autocmd that tries to detect html files based on doctype and this is triggered before scripts in ftdetect/* are sourced. IMO that seems wrong, but what can you do I guess.

Sorry for the hassle everyone.

suan commented

@jacknagel Has it really been reverted? I still see the code in master and am getting the issue in a fresh clone

I don't think so. I don't have commit access to this repo, though.

Very annoying indeed. Until fixed (although this repo seems quite dead...) I use in .vimrc:

autocmd BufNewFile,BufRead *.slim set ft=slim

@cram1010 Create a pull request?!

yeah... it would be great if I had the time... Maybe did my comment sound like a criticism? No my intention, it was just an ascertainment. I understand it is difficult to find the time to maintain a project, like I find difficult to find the time to prepare the pull request...

It was meant more like an encouragement 😄

great :)

fb commented

f8180ad which is merged in master fixes this issue for me.

I updated the plugin and now it works for me, too. Thanks!!