Closed ghost closed 6 years ago
Sounds reasonable. The HTML tag intellisense providers are located here, it might just be a matter of hooking that module up to the PHP code. Also insuring they are only available when outside <?php
tags, if I remember how PHP works correctly.
@Tyriar outside <?php
tags means what? Are they availabe when outside <?php ?>
tags in PHP files?
Outside <?php ?>
is HTML, inside is PHP. So the HTML auto complete should only be available outside the <?php ?>
tags.
@Tyriar But now they are not available outside the <?php ?>
tags in .php
files, maybe they are only available in .html
files.
Please add this feature quickly, I think it's a basic feature, thank you guys.
@osjn thanks for helping us with the prioritization by commenting. An even better way to help us would be a Pull Request with an implementation.
Maybe it is just me, but I think it would be cool if intellisense was available inside of php strings as well.
An upvote from me too. This feature is needed, please.
Almost every PHP developer will need this feature in order to pick VSCode as their primary editor.
We need this issue to be fixed in order to target more developers.
Yesterday I tried bumping my head against this problem but unfortunately my lack of TypeScript skills are holding me back to help you on this issue.
I need this!
Same. Simply +1000
I'm unable to help, but another +1000 from me. HTML/CSS/JS in PHP is common as a mixed file. I've tried full Visual Studio + VS.php - also not supported. I keep wondering why is this overlooked in every Microsoft development tool that supposedly supports PHP. Yes, PHP support is there, but is useless if we don't have IntelliSense (code completition & code suggestions) for HTML/CSS/JS as well.
Same goes for JS blocks & inline CSS in HTML.
If I define in settings.json:
"files.associations": {"*.php": "html"},
... than PHP IntelliSense (obviously) does not work, and HTML kicks in. But inline-CSS by using style=" ...something... ";
does not offer any CSS properties when writing in between quotes of style attribute.
Likewise, if I start a <script>
block, you won't get IntelliSense for JS, while opening .js file reacts normally.
I do support suggestion that (if it's easier):
<?php ... ?>
should start the PHP IntelliSense<?php ... ?>
should start HTML IntelliSense
but also<style> ... </style>
and style=" .... "
should start CSS IntelliSense<script ... >
and <script> ... </script>
should start JS IntelliSenseAlso, if possible, a suggestion by @TheColorRed should be considered, meaning if you are inside
<?php ... ?>
but are writing a string eg $string="..."
than it should consider turning HTML IntelliSense as well. Thing is, PHP devs often use something like:
<?php
$something="test";
echo "<div><a href="http://sample.com">This is a ".$something."</a></div>";
$continue = "coding here ... etc";
?>
.. to avoid doing blocks with opening/closing php tags all the time, like:
<?php
$something="test"; ?>
<div>
<a href="http://sample.com">This is a <?php echo $something; ?></a>
</div>
<?php
$continue = "coding here ... etc";
?>
Also @egamma , while we don't mean to sound ungrateful or lazy, smug comments don't do much help either, if one of us was competent and knowledgeable enough to code it ourselves - I'm sure we'd do it. Unfortunately - I am not :-/ But if I can help in any other way I'd be glad to (not just by commenting with suggestions, but testing, or whatever).
I hope that there IS a consensus that this feature should exist, and that current PHP support without it is only a partial support for the most PHP devs.
P.S. And again, not to sound as a critic - I really like VS Code so far, and am most thankful to everyone that contributed and keep contributing to this wonderful project!
EDIT: Would simply including/referencing one .ts file to another work? E.g. in /languages/php/common/php.ts include: /languages/html/common/html.ts include: /languages/css/common/css.ts include: ...
While there could be some overlap with the tag/attribute/function names nothing comes to my mind at the moment... And for IntelliSense it's non-issue I think as each would have different icon, only color coding could be messed in such cases... Am I missing something else?
if this is not getting added, then i have to switch editor, right now i use 2 editors...
Please, how can I deactivate de HTML IntelliSense when I'm working with a PHP?
This option is a nightmare, because I can't tab in a variable because automatically create a XML/HTML tag.
I don't mix my PHP code with the HTML, and I will not make this error ever, please, at least add the option to deactivate it in PHP "mode".
For PHP you should try crane intellisense https://marketplace.visualstudio.com/items?itemName=HvyIndustries.crane
@TheColorRed Crane Intellisense has the problem. It's by far the most popular VS Code PHP extension, so I guess this is what most people are reporting their problem with.
I've just tried vscode but lacking of this feature just stop me using this IDE. Please provide this feature as it a must have feature for every IDE. Thank you in advanced.
This is very needed. It's incredibly annoying not getting proper intellisense when putting either php code inside a html file, or putting html in a php file.
One big feature i'm missing and its preventing me and colleagues to use vsCode as out main editor.
This is a deal killer for me without this very common feature. Shame though...I REALLY, REALLY, REALLY love this IDE. If this is added, I will be so happy.
@egamma I'll get right on submitting a PR, after I spend an unnecessary amount of time trying to find the code to modify because you decided to be passive aggressive and sarcastic instead of offering the slightest bit of direction to those who might be able to help.
@TechnikEmpire please do not read too much into a comment I made in December 2015, while we were recovering from the big November VS Code release. Apologies if this comment came over as sarcastic.
There is some good progress with regard to Intellisense for PHP. If you want to contribute, then I suggest to look into contributing to the php-language-server
project that @felixfbecker is working on. Felix is also the author of the php-debugger. These are the related repositories:
More information about the language server approach and the language server protocol can be found here.
@egamma But is there any way the PHP language server can "delegate" to VS Code's HTML language server? Seems like https://github.com/Microsoft/vscode/issues/1751 would cover this
@felixfbecker now that we have extracted the HTML language server, the first scenario we want to investigate is how to integrate it with CSS language server so that we can provide Intellisense in CSS sections. This corresponds to the first scenario you mention in #1751 and that was also requested in #8928.
This work didn't make it for September and it is now planned for October.
Thanks! CSS support inside HTML work is planned to October, what about JS aka <script>
support?
@egamma are there any changes or improvements? Mid October passed, so just wanted to re-check. so far, after 5 months I'm still not using VS Code as my primary editor because of the issue, and i'm sure there are hundreds of silent souls out there. i'm glad that there's some work with HTML/CSS mixing, but we really do need a complete HTML+CSS+JS+PHP support...
@luxzg HTML+CSS progress according the October plan, HTML+CSS+JS is a stretch. Follow our progress here: https://github.com/Microsoft/vscode/projects/2
For me powershell inliners in some kind of devops files editing this feature also help a lot. May be someone have an extension that's particularly automatically changed syntax when a cursor located in some of code block?
FWIW the "HTML Snippets" plug-in allong side PHP Intellisense is working well for me.
@matthewringer the plugin not working for me
This is an issue for me too.. has there been no movement on this yet ?
Let's hope this will be added soon. Without this I doubt any php developer will use it.
Sublime is itching me bad to revert back(TM). VSCode if you Love me than save my soul and add the HTML CSS & JS support please.
Well over a year and STILL no support for this? Really? ...and here I thought MS finally made a product that wasn't garbage.
This is the one feature alone, that for me, makes PHPStorm, so much better then anything else I've tried. If they can finally implement proper intellisense/syntax highlighting support for PHP with HTML, CSS, Javascript, then we could finally have a really good lightweight PHP editor.
It's way to annoying right now to be typing in HTML or CSS or Javascript and getting PHP completions everywhere. You might as well be using another editor without autocomplete.
It can't be that hard to just classify .php files as HTML and then parse only what's inside of <?php ?>
tags as PHP code, can it?
+1 from me, please mix them up :)
I just started using VScode while learning programming and it's super great - loving the speed, polish and useability - magical stuff. Just today realised that it's not picking up HTML within PHP files (wither within or without PHP tags) which is making matching HTML tags quite difficult. I'm having to switch out to another editor which isn't ideal.
Sorry I'm not experienced enough to remotely attempt to add this/fix this myself but would really appreciate if someone at Microsoft could add it in. I routinely embed HTML, Javascript, CSS, and SQL code within my PHP files. Would be great if it could all be detected like in other editors, although I'm sure it's not trivial to add this functionality. Would really hate to have to leave VScode all together as it's making the learning experience enjoyable.
@egamma @aeschli this has been laying around for quite a while - you mentioned you wanted to solve this problem with the HTML and CSS language servers, is that finished? I think what this comes down to is the ability for a language server to define certain ranges in the document where all language features should be handled by a different language server. So a PHP LS can after parsing a document declare which ranges are HTML, an HTML LS can declare which parts are JS or CSS, a TS/JS LS can declare which parts are SQL or GraphQL.
@felixfbecker yes this support is available since a couple of milestones, pls see
The html language server can be found here https://github.com/Microsoft/vscode-html-languageservice.
The approach has been mimiked for the vue language support https://github.com/octref/vetur
// fyi @aeschli
@egamma So how does it hand off completion to a different language server? Is there any documentation on this? I assumed this would have taken an LSP extension
leaving this here
@felixfbecker We currently have no other documentation except the code, sorry. I suggest that you connect with @aeschli for a deep dive when you want to get started to add this support for php.
@felixfbecker
Seems there is no generalized way to do language injection yet, but html extension's implementation is pretty straightforward.
I think now it hits a good middle-ground: VSCode offers html/css LS packages to alleviate implementing embedded language support. Meanwhile it keeps flexibility so each LS can react differently based on its context.
By context I mean, html extension could download jquery.d.ts when a script tag with jquery is included (wouldn't apply to vue), or vue extension mark each .vue file as a component to do module resolution (wouldn't apply to html).
To quote @aeschli: https://github.com/Microsoft/vscode/issues/12354#issuecomment-257242426
There are some bugs that want us to come up with a general solution for embedded content, but I think that we won't succeed in that. There are subtle differences in every case where we think it's better to have specific implementation of every host language for the best user experience.
But I do agree doc for implementing embedded language support is lacking. Guess I'll do some writeup once I finish all major features for my vue extension.
This is very unfortunate. Can't we add this capability to LSP? The language server is what parses the documents into an AST, so only the language server has knowledge about what part of the document are written in a different language and should be handed off. So now the extension also needs to parse the document? That is in most cases not even possible because the parser depends on a different runtime than Node (PHP, Java, ...).
I don't imagine adding this to LSP would be that hard, for example the server could just send a notification for a URI with an array of a range + a language mode. Than any editor (not just VS Code) could use a different language server for that range.
@egamma I couldn't find the code in the repository that hands off the language, could you give a more specific pointer? Sorry if I overlooked this.
@felixfbecker Erich meant: embedding of different language services is done inside the server. You can e.g. see that in the dependencies of the html server. That way the server is selfcontained and has full control configuring the context of the embedded language (the JavaScript libraries are available in the embedded content, version of the language (ES5, ES6..)).
That's where the solution you outline (communication between language servers) starts getting in trouble. It likely leads to language server specific APIs and dependencies between servers. We'd like to keep the coupling low and language extensions replaceable.
That said, every language server is free to choose its approach. You can use custom LS messages to do this. That's how we implemented it the November release. The server sends the request back the client the client asks other extensions based on a virtual documents that just contain the embedded language content.
I'd suggest we continue the discussion is a separate issue. Maybe file a new issue with the suggestions you have on how to extend the LSP?
Chiming in here, too. Loving VS Code so far, however the absence of HTML tag competition inside of PHP is a real deal breaker. Temporarily I'm switching to the HTML language mode for PHP files, but don't know how this will work out in the end.
Fell in love with VSCode until I discovered it was lacking this rather basic feature. Gone back to sublime for now.
This one feature is keeping me from switching to VSCode.
This is a badly needed feature. +99999
Such a basic feature which exists in all other editors :|
In PHP files there is no html tags auto completion, please add.
EDIT 9/13/2018 @egamma: VS Code provides only basic support for PHP, but there are powerful PHP extensions available in the market place:
This feature should be provided by these extensions (Intelephence actually already does support it). Please give these extensions a try and help to make them better by filing issues and pull requests.
This issue has lost focus and turned into a discussion whether VS Code should provide PHP support out of box. However, as with many other language like C#, C++, Go, Python, Rust we do not want to bundle PHP with VS Code but rather rely on our great extension ecosystem. I´m therefore closing this issue.