Motoko extension for VSCode!

I hacked this little extension together to get code completion and compiler warnings with the dfx _language-service command.

This has been only tested on 0.5.2 and assumes your dfx binary lives in /usr/local/bin/dfx (this should be easy to fix). If you need to change the directory, use

  • which dfx to get the correct path
  • open ~/.vscode/extensions/motoko-lsp-client.motoko-lsp-client-{the-current-version-of-the-extension}/client/out/extension.js
  • modify the path in line 12 to the output of which dfx
  • safe the file and exit
  • restart vscode

It also only works for projects with only one canister specified in dfx.json (but this shouldn’t be to hard to fix). If you want realtime feedback from the server, not only when you manually save your file, go to

  • vscode settings
  • Files:AutoSave
  • set to afterDelay
  • Tweak the Files: Auto Save Delay to your preferences.

The code is open source, feel free to jump in! It is very heavily inspired from this.

Note: the dfx _language-service is not (afaik) officially supported yet. There will very likely be a way better client provided by dfinity itself which will render this obsolete. This is for people that don’t want to wait :slight_smile: !

It would be great if anyone wants to collaborate on the two issues mentioned above! Enjoy


Nicely done Moritz, you have been busy!


The path to dfx isnt hardcoded anymore! No need for ugly hacks :slight_smile:
Make sure you download the newest version, there has also been a namechange to “motoko” instead of “motoko-lsp-client” (which was a bit long and hard to understand).


Hello @cryptoschindler!

Thank you for this extension!

I keep having the Failed to locate dfx at dfx check that dfx is installed or try changing motoko.dfx in settings error message even when I have only one canister.

I am currently working on the tutorials from the developer center, which are really great by the way. :heart_eyes:

For example, for this tutorial so that everyone can have a simple context to look, the same error message shows up.

I tried to change the path as explained in your post, but I keep facing this issue.

Just for you to know, I am working with the Windows Subsystem for Linux to run dfx etc.

Have you faced this issue before?

Hi @atom
There’s actually an official extension now, so Moritz ceased work on that one, you’ll find the official one here instead:

When you open your projects in VScode, it’ll prompt you to choose a canister, make sure you select the canister containing your Motoko code, not the assets one, and you should be all set.


Hello @Ori !

Sorry for the inconvenience, I found out that the issue was because I didn’t have the “Remote - WSL” extension installed in my Visual Studio Code IDE.

I should have following properly the instructions. :man_facepalming:

Thank you for your time!


No problem at all! Happy to help.