Get Language from file


I am trying to get the language of a file using


this works properly giving source.js for javascript.

But for php it gives text.html.php

So is this a bug in the php language?
Also what is the right way to get the language of a file?


That is the correct way to get the currently configured grammar scope of a file. And that is the correct scope for PHP, at least according to the grammar definition.


@leedohm Should it not be something like source.php?


That depends on whether you consider PHP to be a real programming language or a glorified templating language :wink:

All kidding aside, since a file with a .php extension may or may not have HTML in it, it is best to assume that it does have HTML in it and treat it as such. From a grammar perspective anyway.