julia-vscode
julia-vscode copied to clipboard
Code Completion in Notebooks for Julia
Existing Julia language server should work in most cases., However Notebooks is a whole new document model. One can have a variable initialized in cell 1 and used in cell 2. Based on existing semantics, language servers will treat cell 2 as a whole new text document, hence the variable could be treated as being undefined/un-initialized.
There are at least two solutions:
- Modify julia language server to understand notebook documents.
- Modify the extension to create a dummy text document that concatenates all cells into a single text document, and send this to the language server. This way language server will see a single text document and code completion and most other functionality will work without any changes to julia language server.
This however is not an ideal scenario, refactoring and a few other features will not work, however this is a great approach to get stuff going while the language server is being updated separately. I.e. easy stop gap solution for supporting notebooks. We can hack something easily.
This is what we do to enable Python code completion for Jupyter Notebooks.
It doesn't seem particularly hard to teach the LS to handle implicitly connected documents, I think.
Last time I played around with the proposed notebook API it felt very natural to have on text document for the whole notebook, but I was using a plain text format for that instead of ipynbs.
rticularly hard to teach the LS to handle implicitly connected documents, I think.
Awesoem, sounds like we do'nt need a work around, we can just update the language server. Thanks I suppose we use this issue to track changes to the Langauge Server to support notebooks then.
Has this issue been fixed? I have this problem as well. I'd like to have the notebook be treated as one document so that I can get intellisense on the whole notebook.
Just stumbled upon this, after I just started using a notebook for some data analysis: Julia intellisense does not work across cells in VSCode/Jupyter? Do I have this right? is this what this issue is about?
i.e. code completion works here:
but not here:
I'm not doing something wrong here, am I? This is quite the deal breaker for notebooks (especially as I need to do some exploration of packages I'm using for the first time).
Do I have this right? is this what this issue is about?
Yes.
Do I have this right? is this what this issue is about?
Yes.
Oh, thanks. This is very unfortunate. May I ask, do you have any idea if this is likely to be resolved any time soon...ish?
Do I have this right? is this what this issue is about?
Yes.
Oh, thanks. This is very unfortunate. May I ask, do you have any idea if this is likely to be resolved any time soon...ish?
Seconded
Any updates on this issue?
Obviously not. You would see an update here otherwise.
Just to let you know: I was thinking about using Julia notebooks in VS Code for my upcoming Julia course but because of this I'm very likely to fall back to regular Jupyter in the browser instead. :(
I don't expect this to be resolved anytime soon. The strategy is to support the new notebook features in the LSP, but that will require some work...
Anything new on this issue? This issue is mighty annoying. At this point I kinda live with it because its been an issue for so long but I would really like to have code feedback in other cells and not have to re-import my dependencies every cell, because its slow and kinda trashy.
any way one could help move this along?
As a not-great-but-better-than-nothing workaround, is it possible to attach an external REPL (or a REPL within VS Code) to the Julia kernel process so that at least the REPL's autocomplete could be used? If so I think that it would be useful in other cases too. For instance when making one-off changes to the project it seems weird to be doing using Pkg; Pkg.add("SomePackage")
in a notebook cell that only is really needed the one time.
This maybe is implied by earlier comments and/or already know to the maintainers but I stumbled on this interesting wrinkle: While it seems necessary to add the using
(or import
) directive in the cell in which you hope to have "suggestions" (the VS Code term for this feature in case you are looking for the keyboard shortcuts as I was..), you don't have to actually execute the cell before the suggestions will appear. Of course, this limited to names brought in via using
/import
, not your own locals, but as suggestions are often useful when using packages you've imported that you're not familiar with it might still be useful.
In fact the using
doesn't even need to be above the point where you want to do the completion:
.. unfortunately this seems only to work for export
ed names.
These suggest an ergonomically kind of awful workaround, using copy & paste and/or snippets and splitting cells which I suppose one could get pretty fast with on the keyboard..
Edit: It actually turns out that you never need to have previously used/imported a module to do the above. As far as I can tell it just needs to be available in the current project's manifest.