dfinity / vscode-motoko

Motoko language support for VS Code.
Apache License 2.0
42 stars 15 forks source link

Continuous "Reference not found from AST node:" errors #247

Open ottodevs opened 10 months ago

ottodevs commented 10 months ago

Hello, I am facing some issues with the extension.

I have latest vscode, with prettier and motoko extension installed.

I installed latest dfx 0.14.4 following the official guide (curl)

I created a simple project with dfx new sample_project

The vscode extension does not seem to work, no formatting, no inputs, no syntax highligting, intellisense or import actions...

The extension output looks like this after hovering some part of the motoko file: image

Any idea?

Do I need to install or configure mops for the extension to work? (I don't have it installed)

ottodevs commented 10 months ago

I also tried to install prettier-plugin-motoko separately and configure it in a .prettierrc file, without success, but I understand from the extension documentation that shouldn't be needed, am I right?

rvanasa commented 10 months ago

Happy to help debug. Is this your first time downloading the extension? Also, what operating system are you using?

The extension output looks like this after hovering some part of the motoko file:

The "Reference not found from AST node" messages are actually just debug information, so you can safely ignore them.

I also tried to install prettier-plugin-motoko separately and configure it in a .prettierrc file, without success, but I understand from the extension documentation that shouldn't be needed, am I right?

Yep that's correct; the formatter is built into the extension, so it should work out of the box without installing anything. You should also be okay without installing Mops for the dfx new starter project, so hopefully that helps narrow down the possible causes.

ottodevs commented 9 months ago

Happy to help debug. Is this your first time downloading the extension? Also, what operating system are you using?

The extension output looks like this after hovering some part of the motoko file:

The "Reference not found from AST node" messages are actually just debug information, so you can safely ignore them.

I also tried to install prettier-plugin-motoko separately and configure it in a .prettierrc file, without success, but I understand from the extension documentation that shouldn't be needed, am I right?

Yep that's correct; the formatter is built into the extension, so it should work out of the box without installing anything. You should also be okay without installing Mops for the dfx new starter project, so hopefully that helps narrow down the possible causes.

Hi again! I am using macOS Ventura, up to date.

After spending some time testing things, now I think I made it working.

It seems some syntax error in the motoko code prevented the auto-formatting to work, I expected to have vscode messages for these kind of issues, like eslint or similar, but I think we are not there yet (not complaining, tho, I appreciate how hard is to build a tool like this).

It is weird because some issues like typos on keywords or wrong imports, show up as problems on vscode, but things like missing semicolon after a expression are not raising an issue apparently (but they prevent auto-formatting to work properly)

The inputs (intellisense) also seem to work.

Another missing part is with imports from the extension, by calling "Motoko: Import Mops Package", the import shows up as not found, but I guess there is already an open issue for that.

I will keep debugging and try to be more specific or helpful reporting issues as I learn and better understand the scope of the extension.

Thank so much for the support and patience.

rvanasa commented 9 months ago

It seems some syntax error in the motoko code prevented the auto-formatting to work, I expected to have vscode messages for these kind of issues, like eslint or similar, but I think we are not there yet (not complaining, tho, I appreciate how hard is to build a tool like this).

This is very unusual; syntax errors should be showing up in the editor. Thank you for reporting this so we can try and find a solution in case anyone else is also running into this. Did you happen to change anything in the extension settings?

Another missing part is with imports from the extension, by calling "Motoko: Import Mops Package", the import shows up as not found, but I guess there is already an open issue for that.

This feature was contributed very recently by the author of Mops. Pinging @ZenVoich in case he has any suggestions.

ZenVoich commented 9 months ago

Another missing part is with imports from the extension, by calling "Motoko: Import Mops Package", the import shows up as not found, but I guess there is already an open issue for that.

Do you have a mops.toml file in the project root directory?

Does the error appear on the import line or somewhere else?

If you could provide a full error message, that would be helpful.