Jump to content

Visual Studio Code for ProcessWire Developers


kongondo

Recommended Posts

Visual Studio Code for PW Devs

This thread is a place for ProcessWire developers who use Visual Studio Code (aka VSC or Code)  to share their experience, tips, frustrations , solutions, code snippets and generally discuss all things VSC.

From Wikipedia:

Quote

Visual Studio Code is a source code editor developed by Microsoft for Windows, Linux and macOS. It includes support for debugging, embedded Git control, syntax highlighting, intelligent code completion, snippets, and code refactoring.

 

  • Like 8
Link to comment
Share on other sites

@adrian,

Yes, the PHP IntelliSense is not the best. What extension are you using? This PHP IntelliSense one? That's the one I use. I have never had any luck with auto-completion for PW. Seems you are doing better than me. I suppose the reason is that I don't have the wire folder included as a source in my projects. Are you including wire? Maybe with the new-ish Multi-root workspace implementation I should be able to add wire in my projects in order to get to at least where you are. I'll have a play with this and post back.

Whenever I get the time, I will also post tips and tricks I've gathered so far.

 

Edited by kongondo
  • Like 1
Link to comment
Share on other sites

2 hours ago, FrancisChung said:

If it's any consolation, it's not that great in PHPStorm either. I think I will setup a similar forum topic for PHPStorm users to vent their frustrations and workarounds.

You PHP Intellisense for PW isn't great or PHP Intellisense in General because I use it for Symfony and Yii2 and it's superb but a memory hogger. Netbeans still tops it all in terms of speed for me. 

  • Like 1
Link to comment
Share on other sites

2 hours ago, Ivan Gretsky said:

This issue is what primarily stops me from using VS Code for php development (and that means "at all").

Ivan, what exactly? HTML IntelliSense? The extensions I use provide HTML auto-completion, tag matching (and changing) and CSS IntelliSense. I'll post my list of extensions later.

  • Like 1
Link to comment
Share on other sites

27 minutes ago, kongondo said:

Ivan, what exactly? HTML IntelliSense? The extensions I use provide HTML auto-completion, tag matching (and changing) and CSS IntelliSense. I'll post my list of extensions later.

It is html, css and js in php files. IntelliSense (at least out of the box) just does not recognize that it is html context embedded in php PW template, so no autocompletion and stuff. Felix Becker (the creator of php language server, used in VS Code as the base for php IntelliSense) writes about it in the mentioned issue.

I did not find a workaround.

Edit: Actually the main problem is the other way around. PHP includes in html templates/views.

  • Like 1
Link to comment
Share on other sites

This topic made me check the progress on Atom IDE project. The 1.21 version of atom is finally out of beta, so now one can install it without switching to beta channel. Atom IDE uses the same Felix Becker's language server, and has language contexts figured out, as far as I know. While at it upgraded my Windows Atom to x64 version (startup appeared to be a little faster, but maybe I'm just dreaming). Jump to class definition works. Auto-completion works, Outline view is present.

Somehow I consider Atom to be more open source and open in general than VS Code. So will try stick to it for now. VS Code starts up a bit faster, but they have near feature parity now. Good competition is good!

Link to comment
Share on other sites

2 hours ago, Ivan Gretsky said:

Felix Becker (the creator of php language server, used in VS Code as the base for php IntelliSense) writes about it in the mentioned issue.

Hmm. Felix is the author and maintainer of the PHP IntelliSense extension I referred to. I do not use the VSC code in-built one.

 

52 minutes ago, Ivan Gretsky said:

Jump to class definition works. Auto-completion works

Works for me too in VSC.

IntelliSense

I have noticed that if I do this:

$animals = new Animals();
$traits = $animals->getTraits();

PHP IntelliSense works fine. However, if I do this...

public $animals
$this->animals = new Animals();
$traits = $this->animals->getTraits();

It doesn't work...I have been meaning to file a 'bug' report.

I've tried the other IntelliSense but they don't work as well as Felix's. 

Edited by kongondo
  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...
1 hour ago, elabx said:

Does anyone know if you can edit a remote location ftp/ssh, and navigate it as a file system??

In my emacs setup this is so straightforward but I never found a way to do this in VS Code. 

https://codepen.io/ginfuru/post/remote-editing-files-with-ssh

https://marketplace.visualstudio.com/items?itemName=rafaelmaiolla.remote-vscode

Nothing here in the Marketplace?

Link to comment
Share on other sites

That just feels a bit too impractical, because they  involve ssh tunneling and open a single file, out of the vscode interface. I think I found what I'm looking for but it's not released yet: 

https://code.visualstudio.com/updates/v1_17#_preview-remote-file-system-api

This let's you navigate the remote server as if it was local. 

 

 

  • Like 1
Link to comment
Share on other sites

I'm using this one: https://marketplace.visualstudio.com/items?itemName=lukasz-wronski.ftp-sync

I'm not 100% happy but it works most of the time. Searching through all files only works when you have all files on your computer. This ftp sync sucks for that part. I always zip everything and download it... much faster most of the time. Maybe the new duplicator module could help here...

Another thing that I do is browsing the server over ssh via winscp and then just doubleclick the file. This opens the file on VSCode and on save uploads the new version.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
1 hour ago, bernhard said:

ps: i don't want to abuse this thread for interesting stuff about vscode that is not related to processwire if that is not wanted...?

This is dev talk, so why not....? You are good.

Quote

Dev Talk

A place for general development and coding discussions.

 

Link to comment
Share on other sites

  • 3 weeks later...
×
×
  • Create New...