Open Maelcom opened 10 months ago
Very interesting, thanks for filing this issue.
I've tried to reproduce this on my side (VS Code 1.81.1 on macOS), but I've hit an obstacle along the way... At moment, I don't see a way to choose Racket as a notebook cell language.
When I create a new notebook, the cells start out as Python by default. I can click the "Python" marker in the bottom right of the cell to get a menu of languages, but it seems to be a subset of the languages that VS Code and my extensions are aware of, as only a few of them appear there, and Racket is not one of them.
I wonder how this list of "notebook ready" languages is determined...
I can click the "Python" marker in the bottom right of the cell to get a menu of languages, but it seems to be a subset of the languages that VS Code and my extensions are aware of, as only a few of them appear there, and Racket is not one of them.
Just to make sure, did you run the second command during IRacket installation?
raco pkg install iracket
raco iracket install
https://docs.racket-lang.org/iracket/index.html
On my system that was enough for Jupyter to start seeing the new language.
Ah thanks, that helped. I am now able to select Racket as a language in notebook cells.
Okay, it looks like this issue is similar to https://github.com/Eugleo/magic-racket/issues/113: this extension currently only registers itself for file
documents. Notebook cells use the special vscode-notebook-cell
scheme.
Just removing the filter and registered for all schemes is not enough, as presumably we need to do a bit of translation to get the content for notebook cells. Perhaps other extensions have found a good way to do that...
Perhaps other extensions have found a good way to do that
Well, racket-fmt uses a vscode.languages.registerDocumentFormattingEditProvider
inside of which it just manually takes document.getText()
, passes through CLI and gets the resulting text.
Don't know if this could be applicable to LSP.
Well, racket-fmt uses a
vscode.languages.registerDocumentFormattingEditProvider
inside of which it just manually takesdocument.getText()
, passes through CLI and gets the resulting text.
Thanks, I noticed that as well. 🙂
In this case, it's a little different in that the language server currently assumes the document URI has a path-like shape to it. I believe the main options are either:
I need to review the language a bit more to make sure it does not actually use the file path to e.g. read content, and then from there I think a decent approach to move forward should become clear.
At the moment, there are a few places where the language server assumes a filesystem. I have filed https://github.com/jeapostrophe/racket-langserver/issues/122 to discuss this with others working on the language server.
We've had a bit of progress on this front!
https://github.com/jeapostrophe/racket-langserver/issues/122 has been resolved on the langserver side, which means it is now compatible with non-file documents.
The main issue that remains is that the langserver really wants #lang
to be present, while IRacket wants the opposite, so it's challenging to use both for a given cell. (If you have any suggestions on what to do about this, please pass them along!)
To test out the current state:
racket-langserver
to https://github.com/jeapostrophe/racket-langserver/commit/3f23f437eac0206a45abe79e0edc2d1a3ed48161 or beyond
Environment
Steps to reproduce
Expected
Magic Racket formats the cell.
Actual
VS Code error message: Extension 'Magic Racket' is configured as formatter but it cannot format 'Racket'-files
Additional context
"Format Document With..." command inside .ipynb files reveals that Magic Racket is NOT present in the list of possible formatters. Same command inside .rkt files correctly displays Magic Racket.
Same scenario with
racket-fmt
works correctly out of the box, so probably not complicated.Recording:
https://github.com/Eugleo/magic-racket/assets/1520199/ef27cfd2-bae8-4394-aab6-93d3a150b3c2