Motoko: Why vscode?

For code highlighting and completion it seems the only native plugin to date is for Visual Studio Code. Is this the main IDE that the internal team is using currently, and if so why?

(sell me on it)

I will say the interactive playground that it suggests on install has taught me things I didn’t even know I was missing (like Emmet Abbreviation)

I’m sure vscode isn’t the only IDE it’s in, but it’s the only IDE that made it a point to show me in an interactive way.

I think I can get used to it, just wondering if this is the primary IDE being used internally and by most Internet Computer / Motoko developers and if so, why.

… also just hit me that Microsoft also maintains TypeScript which has similar type checking syntax and functionality, so maybe it’s a good fit for Motoko as well on that note.

If I remember correctly, VS Code is the most popular editor so it makes sense to target that first.

I haven’t tried it myself recently but Motoko provides a language server that is compatible with editors that support the Language Server Protocol. isn’t the official site but I think it does a great job of explaining why LSP makes sense. It also lists language server implementations for different languages, and LSP clients for different editors.

It should be possible to find your editor near the bottom of that page and get it to talk to the Motoko language server.

@kritzcreek 's VS plugin is mostly a wrapper around the mo-ide tool he wrote, which is a Language Server Protocol (LSP) server for Motoko. This means that it should be relatively easy to add that support to other editors. That would make a great community project!

Does anyone have candid syntax highlighting for vscode? I know the highlightjs definition exists.

For Webstorm/Jetbrains users, go for an upvote :point_right:

Any suggestions for kicking the language server to actually do error highlighting in VS Code. Sometimes i work and then sometimes the red lines just disappear. I’m using Motoko language support v 0.3.9 in vs code.

This working reliably would save a ton of time where I’m dfx build’ing and waiting for everything to build.

I’ve tried manually pointing to my test canister(which should at least ref every other canister) and disabling and enabling the extension.

Any tips would be appreciated.

There’s a restart Motoko language server command, pressing Ctrl Shift P and typing Motoko should find it.

When will be able to do “Go to Definition” and “Find References” in Motoko with VSCode? That would be a game changer.

1 Like

This worked for a bit…but then sometimes it just stops…I tried turning on the trace in settings…any idea where to view that so I can see if it is erroring out somewhere?

And now it seems to be really mad about my import myCanister “canister:myCanister”; statements when the canisters are clearly defined in my dfx.json file and dfx build works just fine.:man_shrugging:t2:

Happy to help debug, but I need to know where to look.

Unfortunately our LSP man has joined another team to predominantly work on Internet Identity.

is probably the place to look.

IIRC, Go To Definition (but not References) should actually work on references to library members (but not on local definitions).

1 Like

For me, Go To Definition works going from main to a library, but not across libraries.

1 Like