ilich / vscode-coldfusion

Visual Studio Code CFML (ColdFusion) Language Support
MIT License
40 stars 15 forks source link

Emmet Support Requires Word Pattern #21

Open timknight opened 7 years ago

timknight commented 7 years ago

VS Code's Emmet support uses the word pattern settings for a language and when no word pattern is set it falls back to a alpha only word pattern, so numbers are picked up.

So if you have Emmet enabled for lang-cfml and use an emmet selector like .row>.col-md-5 the -5 will cause Emmet to fail. You can see details as to what's happening at https://github.com/Microsoft/vscode/issues/32438#issuecomment-322242789 and you can see how I fixed it for Twig at https://github.com/whatwedo/vscode-twig/pull/14/commits/f14f6f668600933ec49e3daa66da449c695dc5f4. I would have posted a Pull Request, but didn't necessarily want to take a different route by adding a .js setup file you might not want when supposedly you can add this word pattern within the cfscript.configuration.json as well.

KamasamaK commented 7 years ago

It looks like this is only an issue with auto-completion suggestions. You can still press Ctrl+Space to force the suggestion or just run the Emmet: Expand Abbreviation command. This is again an issue with mixing languages. It would not be correct to change the CFML "wordPattern" because of this.

One way to address this would be to have *.cfm files default to the HTML language and delegate to the appropriate embedded languages. For example, it should mark CFML as the embedded language when within <cf tags or within ## within <cfoutput>. I'm just not sure how you would go about doing that.

timknight commented 7 years ago

That's right, you can manually expand the support Ramya mentioned in her comments, this is really all about detection based on how VSCode sees the language. Last I heard though there wasn't a way to just delegate to a inherited language which is why even Microsoft's language definition for HTML has duplication with the handlebars wordPattern syntax, but I could be wrong.

timknight commented 7 years ago

The VS Code PHP syntax too doesn't delegate to HTML either and they have set their wordPattern there as well. See: https://github.com/Microsoft/vscode/blob/master/extensions/php/src/phpMain.ts

KamasamaK commented 7 years ago

I wasn't saying to not have a wordPattern, but to not have it change to accommodate Emmet autocompletion. The PHP one you linked also fails autocomplete on your example. It appears to correctly consider - as a word separator.

The issue with the PHP extension and HTML is well documented and a number of developers have chosen to not use VS Code because of it -- see Issue 670 and more generally Issue 1751.

That said, if you look at the their html extension (specifically the server part) they do have a homegrown solution that involves embedding languages.

timknight commented 7 years ago

Hmm, interesting. I see what you mean. But you're right, I don't think we should just be doing anything to accommodate just Emmet compatibility. And it's strange as you point out that PHP uses a different wordPattern than HTML which seems incredibly strange.

KamasamaK commented 7 years ago

PHP and HTML are completely separate languages so it's not that strange that there would be syntactic differences. For example, in HTML5 there is an attribute aria-labelledby which would make sense to be considered one word. In PHP, - is an operator that separates words instead of adjoining them (e.g. in the statement $z = $x-$y;).

lhoess commented 4 years ago

I think you can simply add this to your user settings in VSCode: "emmet.includeLanguages": { "cfml": "html" }