Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No autocompletion showing up for Nim vscode extension #2676

Open
vitreo12 opened this issue Nov 5, 2020 · 10 comments
Open

No autocompletion showing up for Nim vscode extension #2676

vitreo12 opened this issue Nov 5, 2020 · 10 comments
Labels
A-extension Area: Extension/plugin integration, vscode or VimL bug Something isn't working L-nim Language: Nim

Comments

@vitreo12
Copy link

vitreo12 commented Nov 5, 2020

Hello,

I have been trying to get Oni2 to work nicely with the Nim programming language VSCode extension (https://github.com/pragmagic/vscode-nim) with no luck.
The syntax highlighting works correctly, but that's pretty much it: no autocompletion is presented while typing, no functions introspection, no goto, etc...

I am wondering, does this have to do with something missing in Oni2's VSCode plugin integration? Is this VSCode plugin doing something specific that wouldn't work in Oni2?

@bryphe bryphe added bug Something isn't working A-extension Area: Extension/plugin integration, vscode or VimL L-nim Language: Nim labels Nov 6, 2020
@bryphe
Copy link
Member

bryphe commented Nov 6, 2020

Thanks for reporting the issue, @vitreo12 !

Just tried this out - I see this callstack popping up:

nimSuggest failed:  [TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
	at validateString (internal/validators.js:120:11)
	at Object.join (path.js:1039:7)
	at getDirtyFile_11885258 (/home/bryphe/.config/oni2/extensions/nimsaem.nimvscode-0.1.8/out/nimvscode.js:7208:76)
	at HEX3Aanonymous_12381151 (/home/bryphe/.config/oni2/extensions/nimsaem.nimvscode-0.1.8/out/nimvscode.js:7735:103)
	at new Promise (<anonymous>)
	at Object.provideCompletionItems_12381131 [as provideCompletionItems] (/home/bryphe/.config/oni2/extensions/nimsaem.nimvscode-0.1.8/out/nimvscode.js:7761:23)
	at /home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/workbench/api/common/extHostLanguageFeatures.js:709:78
	at /home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/base/common/async.js:62:26
	at new Promise (<anonymous>)
	at Object.asPromise (/home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/base/common/async.js:61:16)
	at SuggestAdapter.provideCompletionItems (/home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/workbench/api/common/extHostLanguageFeatures.js:709:47)
	at /home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/workbench/api/common/extHostLanguageFeatures.js:1374:81
	at ExtHostLanguageFeatures._withAdapter (/home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/workbench/api/common/extHostLanguageFeatures.js:1135:27)
	at ExtHostLanguageFeatures.$provideCompletionItems (/home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/workbench/api/common/extHostLanguageFeatures.js:1374:25)
	at RPCProtocol._doInvokeHandler (/home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/workbench/services/extensions/common/rpcProtocol.js:335:27)
	at RPCProtocol._invokeHandler (/home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/workbench/services/extensions/common/rpcProtocol.js:320:45)
	at RPCProtocol._receiveRequest (/home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/workbench/services/extensions/common/rpcProtocol.js:242:32)
	at RPCProtocol._receiveOneMessage (/home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/workbench/services/extensions/common/rpcProtocol.js:175:26)
	at /home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/workbench/services/extensions/common/rpcProtocol.js:65:52
	at Emitter.fire (/home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/base/common/event.js:456:38)
	at BufferedEmitter.fire (/home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/base/parts/ipc/common/ipc.net.js:362:35)
	at /home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/workbench/services/extensions/node/extensionHostProcessSetup.js:145:41
	at Emitter.fire (/home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/base/common/event.js:456:38)
	at BufferedEmitter.fire (/home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/base/parts/ipc/common/ipc.net.js:362:35)
	at PersistentProtocol._receiveMessage (/home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/base/parts/ipc/common/ipc.net.js:581:37)
	at /home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/base/parts/ipc/common/ipc.net.js:455:83
	at Emitter.fire (/home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/base/common/event.js:456:38)
	at ProtocolReader.acceptChunk (/home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/base/parts/ipc/common/ipc.net.js:188:37)
	at /home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/base/parts/ipc/common/ipc.net.js:157:61
	at Socket.listener (/home/bryphe/oni2/node/node_modules/@onivim/vscode-exthost/out/vs/base/parts/ipc/node/ipc.net.js:17:40)
	at Socket.emit (events.js:315:20)
	at addChunk (_stream_readable.js:295:12)
	at readableAddChunk (_stream_readable.js:271:9)
	at Socket.Readable.push (_stream_readable.js:212:10)
	at Pipe.onStreamRead (internal/stream_base_commons.js:186:23)] {
  code: 'ERR_INVALID_ARG_TYPE'

I need to investigate a bit more - but seems like we're not providing a proper value here: https://github.com/saem/vscode-nim/blob/49dfbc033691509ac80ecf67b71aa75c786f32e6/src/nimvscode/nimUtils.nim#L173 for the extensionContext.storagePath. Will check out what we're missing and see if that unblocks the completion.

It looks like this code path is common to some of the other language features (hover, goto, etc).

Just curious - did you install the extension inside Onivim? Or another way? It looks like the extension in the Open-VSX repo is this one: https://open-vsx.org/extension/nimsaem/nimvscode - so actually different from the https://github.com/pragmagic/vscode-nim one you linked - want to make sure I'm looking at the right one 😄

@vitreo12
Copy link
Author

vitreo12 commented Nov 6, 2020

I am using the one I linked: I installed it by downloading the .vsix and using the oni2 --install-extension command to install it.

I have also just tried the one you linked from Open-VSX, but it still wouldn't work.

@bryphe
Copy link
Member

bryphe commented Jan 16, 2021

Tested again today - it looks like the extension depends on ms-vscode.cpptools and was erroring when trying to activate (and Onivim was not showing an error message in this case - so it was failing silently).

Installing the ms-vscode.cpptools extension from here: https://github.com/microsoft/vscode-cpptools/releases/tag/1.1.3 along with https://github.com/pragmagic/vscode-nim/releases/tag/v0.6.6 (both had to be download and installed manually, unfortunately, as neither is on open-vsx).

Once I had both extensions - I was able to use completion / hover / goto-definition:

image

I'm looking to see why we didn't show an error message in this case - we should have a clear error saying something to the effect of "vscode-nim depends on ms-vscode.cpptools, which is not installed"

@vitreo12
Copy link
Author

vitreo12 commented Jan 17, 2021

Thanks for the help! Unfortunately, it's still not working here, I'm receiving a bunch of Signature help errors:

image

I'm on version 0.5.2

@Clonkk
Copy link

Clonkk commented Jan 18, 2021

I tried doing the same thing (using Nim in Onivim2) except I used a different Nim extension : https://open-vsx.org/extension/nimsaem/nimvscode and I can see the following error : Error: Activating extention 'nimsaem.nimvscode' failed: Cannot read property 'length' of undefined.

The auto-completion seems to be working, but I'm not sure what this error message is supposed to mean. Is there an error somehow that I've not seen yet ?

Onivim2 0.5.9-nightly | ae21cb9 running on windows.

@zetashift
Copy link

I'm getting the same error of "Error: Activating extention 'nimsaem.nimvscode' failed: Cannot read property 'length' of undefined." as @Clonkk, but my autocompletion seems to be not working. I'm running on Linux x64 with cpptools manually installed.

bryphe added a commit that referenced this issue Jan 19, 2021
…on dependency (#3007)

__Issue:__ When an extension has a required dependency that is not installed, Onivim would fail to activate the extension silently.

__Defect:__ Onivim was not properly handling the extension activation error - usually, it's a `string`, but in the case of a missing dependency, it is a JSON object - the parser was only handling the string case.

__Fix:__ Implement a decoder to handle either case. Bubble up the activation error to the user.

Related #2676 
Related #1058
@bryphe
Copy link
Member

bryphe commented Jan 22, 2021

@zetashift @Clonkk - Looks like the crash for https://open-vsx.org/extension/nimsaem/nimvscode is here:
https://github.com/saem/vscode-nim/blob/ff481b13e854801054f1dcb23eef38903f326281/src/nimvscode/vscodeExt.nim#L389

It's expecting workspace storage to be available, but ctx.storagePath is null - Onivim doesn't have that yet - looking at adding it in #3030

@vitreo12 - thanks for posting those extra details! It looks like the buffer is out-of-sync somehow - the signature help is asking for line 9 here (actually line 10, it's zero-based): https://github.com/pragmagic/vscode-nim/blob/0272a0544ddf147fde98f8a8f2b624b7dcb19eb3/src/nimSignature.ts#L23 - but obviously from your screenshot there are only 4 lines. Does this reproduce consistently for you? If so - I'd be interested in the steps. I'm aware of a few cases the extension host gets out of sync, but any consistent reproduction would be helpful.

@vitreo12
Copy link
Author

@bryphe

Yes, it does happen consistently. I simply open up the test.nim file and I start seeing all the errors popping up.

Actually, it happears that now some of the auto complete features work (briefly - 1 minute - then they stop, probably crashing), but I'm getting a Cannot read property 'split' list of errors.

bryphe added a commit that referenced this issue Jan 27, 2021
__Issue:__ The [`https://open-vsx.org/extension/nimsaem/nimvscode`](https://open-vsx.org/extension/nimsaem/nimvscode) extension was failing to activate

__Defect:__ The extension was logging out `ctx.storagePath`, which was undefined, because workspace storage was not implemented

__Fix:__ Implement workspace storage - add `.config/oni2/workspace` 

With workspace storage implemented, I get language features via the `nimsaem/nimvscode` extension:

![image](https://user-images.githubusercontent.com/13532591/105923636-83ec7180-5ff1-11eb-9c92-0c30e7e1b1e9.png)

Related #1058 
Related #2676 

__TODO:__
- [x] Check default / no workspace case 
- [x] Add test to verify `ctx.storagePath` is populated now
@zetashift
Copy link

With the latest nighty saem/vscode-nim works fine for me, thus far.

@bryphe
Copy link
Member

bryphe commented Feb 3, 2021

Excellent! Thanks for the update @zetashift

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-extension Area: Extension/plugin integration, vscode or VimL bug Something isn't working L-nim Language: Nim
Projects
None yet
Development

No branches or pull requests

4 participants