d2-vscode LanguageServerChanges - #1534
Conversation
These changes are for the language server in d2-vscode. When the D2_LSP_MODE environment variable is set, the d2 cli will read the d2 file, produce the ast (and possible errors), convert it to JSON, print it out to stdout, then terminate. This was done this way to keep the changes to the d2 cli code to a minimum. PR for d2-vscode to come after this is accepted
|
AFAIK, LSPs should be daemon processes, otherwise it'd have to reindex each call or load an index from disk, both of which seem too slow for autocomplete. I haven't looked too much into LSPs, is this just for testing or the beginning of a true LSP effort? @BarryNolte |
|
I should have made this clearer. This is the only change needed in the d2 cli code. I wasn't going to duplicate the language parsing in typescript, I'm too old for that, so I'm leveraging the de facto parser to get the AST for the language server. I have a working and 99% complete language server (yes, it runs as a deamon) in the d2-vscode/LanguageServer branch, I'm taking the weekend to squash the last couple bugs, and I wanted this in first. As far as speed, it appears to be good. Running d2 to get the AST on my machine (which is slow) takes ~50ms, and my analysis of the resultant JSON version of the AST is ~1ms. |
Co-authored-by: gavin-ts <85081687+gavin-ts@users.noreply.github.com>
gavin-ts
left a comment
There was a problem hiding this comment.
I can update where this code is in a follow up
|
Sounds good. Thanks! |
a815dc5 to
37416d8
Compare
37416d8 to
9c578b0
Compare
These changes are for the language server in d2-vscode.
When the D2_LSP_MODE environment variable is set, the d2 cli will read the d2 file, produce the ast (and possible errors), convert it to JSON, print it out to stdout, then terminate. This was done this way to keep the changes to the d2 cli code to a minimum.
PR for d2-vscode to come after this is accepted
@gavin-ts @alixander