dotnet / interactive Public
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
add stubs for lsp over http #236
Conversation
The main concern I have is with your rename from requirejs to require that caused few issues in jupyterlab (where that code is executed) and the removal of process+port cache buster in the require scope
| @@ -167,6 +168,11 @@ command switch | |||
|
|
|||
| public abstract bool TryGetVariable(string name, out object value); | |||
|
|
|||
| public virtual Task<JObject> LspMethod(string methodName, JObject request) | |||
are we expecting the api to be opt in or otp out? @jonsequitur should this be abstract?
Ultimately I don't care either way. I made the method virtual simply so F#/pwsh don't have to implement this method simply to return null if they don't support LSP.
JObject isn't an ideal return type. We should use made-for-purpose types here and let serialization happen higher up.
I just added a commit titled strongly type LSP responses that does just this; take a look.
|
Re-did this PR to take in recent changes. In short:
This was done so that the LSP methods have an easy way to look up the tree in the DOM to know what end point to issue the LSP commands to.
|


This adds all of the stubs necessary to invoke the
textDocument/hoverLSP function, which is analogous to QuickInfo in Visual Studio. Currently only the C# kernel responds to this and it's responding with a hard-coded string. The work to produce the real content is forthcoming, but I needed the plumbing, first.The LSP work is mostly split between two files. The first is
lsp.jswhich handles the LSP-over-HTTP business. Not much to look at here.The next part is specific to CodeMirror and how it's exposed through
jupyter notebook. I've limited this PR to that case because it's simpler because any given web page has only one notebook open. That works by detecting the global JavaScript variablesCodeMirrorandJupyter(not set injupyter lab). Since CodeMirror doesn't natively understand a text hover operation, I've tied into CodeMirror cell creation and hook intomousemoveandmouseleaveto register timer-based callbacks that ultimately result intextDocument/hoverbeing called if the mouse is in the same position for 500ms.CodeMirror also doesn't have the ability to get the line/column of the character under the mouse cursor, so I've had to get creative. I do that by first iterating over the DOM elements that represent the lines of the editor. If one of those lines' bounding rectangles contains the mouse cursor, then I start to look for the column. Finding the column is much harder because the DOM elements don't represent anything useful, so I simply check each one in order, again checking the bounding rectangle. The end result is that the column that I detect is really the column of the first character of an arbitrary text span, but since CodeMirror is splitting the text on reasonable word boundaries, this will always yield the start position of what any programmer would call an identifier.
In the example below, the following markdown is returned as a hard-coded string from the C# LSP provider:
textDocument/hover at position (0, 9) with `markdown`@colombod I re-worked the
requirejs.config()call inHttpApiBootstrapper.csso that the prefixdotnet-interactivepoints tohttp://localhost:<port>/resources. This makes it so that I can later call the following nicely:The text was updated successfully, but these errors were encountered: