saem / vscode-nim

Other
180 stars 23 forks source link

Nimpretty does not work? #100

Closed laker31 closed 1 year ago

laker31 commented 1 year ago

I have just installed the extension. I added this to Settings.json:

"nim.nimprettyMaxLineLen": 80,

I then wrote a line of valid code that is much longer than 80 characters. Upon saving the file, nothing happens. Nimpretty is installed in my Nim's installation folder (together with Nimsuggest which, for example, works with the extension).

Am I missing something obvious?

Thanks!

saem commented 1 year ago

Yes, afraid so.

The extension registers a document formatter for the language. That enables the usual vs code features of document formatting.

Check the menu for format document and the general setting of format on save etc.

laker31 commented 1 year ago

Yes, afraid so.

The extension registers a document formatter for the language. That enables the usual vs code features of document formatting.

Check the menu for format document and the general setting of format on save etc.

Oh sorry for that, I didn't know these settings had to be enabled in VSC. Thank you for your help! :)

laker31 commented 1 year ago

@saem Another question not strictly related to nimpretty. Is it normal that for modules from the standard library, there is no auto-suggest (I am using nimsuggest)? Also when CMD + clicking on the names of these modules, I am not taken to the files? (If I click on a process from these modules however, I am taken to the files, see video).

https://user-images.githubusercontent.com/95769511/178587406-9b180b13-f092-4226-95c5-1bef7893438f.mov

saem commented 1 year ago

It's been way too long since I've looked at that code but I do remember there was some weirdness about imports because of how nimsuggest returns data, IIRC.

If you want you can use the development instructions in the readme, it's pretty much: clone repo, npm install, open in vs code, hit F5 and you're running a debug build. The slowest steps are clone and npm. 😁

Anyhow at that point console log and you can see what's happening, could be an issue with local setup. If you're on windows things can get funky. At that point it's not the extension typically which is little more than a shim.

laker31 commented 1 year ago

Thank you!

I managed to get the development extension running. To be honest I don't understand most of what is shown in the console but there is nothing that suggests nimsuggest is not set up correctly (I'm on MacOS by the way).

Every time I start typing a library (e.g. import struti) or every time I want to open a library's file (basically the actions I showed in the video above), I see an execNimSuggest call in the debug console. I then see an "onData received" and "onData handling" message and no errors (it does mention making use of a dirtyFile though).

Does that mean it is something to do with how the extension handles the data returned by nimsuggest? If so, no big issue - I just wanted to make sure my nimsuggest was correctly set up and recognized, it is not a big deal if there is no autocompletion for the libraries when importing them.

saem commented 1 year ago

Awesome, glad you were able to poke into it.

Yeah, sounds like either it was broken in the extension side or nothing is coming back from nimsuggest or the returned output broke.

laker31 commented 1 year ago

@saem Thanks a lot for your help!