ericglau / cairo-ls

Cairo Language Server

Home Page:https://marketplace.visualstudio.com/items?itemName=ericglau.cairo-ls

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to use vscode version with WSL

microbecode opened this issue · comments

I'm unable to get the vscode version working with WSL (I'm on a Windows machine).

What I've done:

  • Install the Cairo plugin: https://www.cairo-lang.org/docs/quickstart.html#visual-studio-code-setup
  • Install this plugin
  • Configure venv path in plugin settings
  • Configure contracts folder in plugin settings
  • Open the VS code from a WSL terminal running the venv with code (note that I'm unable to open it directly in WSL mode like this, so I have to execute from vscode "Re-open folder in WSL")

When trying to format a Cairo file, I get an error from the Cairo extension:
Formatting failed: No terminal matches ' ' in the current parser context, at line 1 col 15 %lang starknet ^ Expected one of: * IDENTIFIER * RPAR * INT * _DBL_PLUS * _NEWLINE * "+=" * EQUAL * STRING * _ARROW * LANG * DOT * RBRACE * BUILTINS * AMPERSAND * SHORT_STRING * RSQB * SEMICOLON * LPAR * LSQB * _AT * HINT * _DBL_EQ * COMMA * COMMENT * COLON * HEXINT * PLUS * SLASH * LBRACE * _NEQ * _DBL_STAR * STAR * MINUS Previous tokens: Token('IDENTIFIER', 'starknet')

Ideas?

Cairo formatting is part of StarkWare's VS Code extension and is not a feature of this Cairo LS.

Perhaps ensure your cairo-lang version matches with the other tools that you are using.

Is compile error highlighting working for you, i.e. do you see any red underlines in your Cairo code?

All the versions should be newest, since I just installed them from scratch.
Error highlighting doesn't work either.
And thanks for the clarification - I clearly don't understand which piece does which part.

Can you go to the Output tab at the bottom of VS Code, choose Cairo LS from the dropdown, and provide the output? That may help give an indication of what error(s) are being encountered.

e.g.
cairolsoutput

Hmm, apologies. I now tried all from scratch again and the underlining and language server error displaying seems to work. Just the formatting doesn't (with the above error). So I should report to StarkWare in some repo?

Great to hear that the language server is working for you.

That error is indeed coming from StarkWare's VS Code extension so perhaps report in https://github.com/starkware-libs/cairo-lang/issues. You can try running cairo-format <path_to_a_cairo_file> as an alternative to see if that works.