Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make vscode understand p5js

I recently started P5JS, and I use VSCode as an editor.

VSCode doesn't know P5JS, because it's a library I guess, and makes all the wrong autocompletes.

Is there a way to import the P5JS languagefiles into VSCode, because it's a real pain.

Thank you in advance for your help.

like image 256
JohnnyAwesome Avatar asked Feb 07 '19 20:02

JohnnyAwesome


People also ask

What programming language does p5js use?

p5.js is a JavaScript library for creative coding, with a focus on making coding accessible and inclusive for artists, designers, educators, beginners, and anyone else! p5.js is free and open-source because we believe software, and the tools to learn it, should be accessible to everyone.

How do I make my VS Code smoother?

Here's how to do it: Simply disable your extensions one at a time, and check to see if it made a difference. If your performance issues are obvious (E.g. files take 2 sec to open) than this should be quite easy. Disable → test → enable → disable the next one → test → etc.


2 Answers

As far as Intellisense for P5.js in Visual Studio Code is concerned, there is currently no official build of p5.js typescript definition files, hence it cannot be done with npm install. I have attached a link to a zip file (as stack overflow doesn't support file attachment):

https://www.filehosting.org/file/details/795689/p5.d.zip

After download, put them in your project directory somewhere and add a reference to them in your sketch.js file.

E.g:

< reference path="./p5.global-mode.d.ts" / >

After that you will be able to get autocomplete & docs:

enter image description here

like image 101
Zobia Kanwal Avatar answered Sep 22 '22 05:09

Zobia Kanwal


I used a P5.js Extension on it and It seems to have done the trick you will need to download the live server extension in the description enter image description here

you will also need to create a folder and then need to type this into the command pallette

"create p5.js project"

then you select your folder and then you should see this

enter image description here

you then select sketch.js for JavaScript and you may also edit the html code if you would like

like image 25
Michael Rusu Avatar answered Sep 22 '22 05:09

Michael Rusu