d2-vscode
d2-vscode copied to clipboard
support autocompletion/hinting
Like the title says. I don't know how that is done best for extensions, but I've seen it done via published openapi definitions.
i'm not sure either but i always thought we'd need an LSP for it (which we'll definitely want to do). like when the editor is trying to autocomplete a "shapes" value, i don't think it'd be able to know to pull from list of shape values for autocomplete with just openapi definitions.
Yeah, nested structures could not be mapped with openapi alone I guess. But I guess it is not rocket science to set up a language server. Probably tedious work.
yeup, i'll leave this open as it eventually will be vscode task, but we have one for LSP in d2: https://github.com/terrastruct/d2/issues/104
When I have time, I'll setup a branch that has the framework for an LSP on the client side. The hard part is going to be the "error tolerant parser" on the server side :)
https://code.visualstudio.com/api/language-extensions/language-server-extension-guide
@alixander and @gavin-ts
I have branches in both D2 and D2-VSCODE called LanguageServer that have a working language server. Please check them out. Have the following working:
- Errors shown without a preview being created
- Import links can be opened, "foo: @BarryNolte " will underline "barrynolte" and allow for a ctrl+click to open "barrynolte.d2".
- Rename works, so if you have multiple "x: ...", "x.style...", etc, you can rename "x" and and have it change everywhere.
- Find All References works.
Check it out.
I'll try to work on autocomplete for styles if I can figure out what to trigger it on.
So these would be the 2 PRs right? We can create these to review/work on
https://github.com/terrastruct/d2/compare/master...BarryNolte:d2:LanguageServer
https://github.com/terrastruct/d2-vscode/compare/master...BarryNolte:d2-vscode:LanguageServer