d2
d2 copied to clipboard
IntelliJ plugin
Hey,
Fond of this project, was wondering if you have in your project road map to develop a plugin for IntelliJ?
-b
I'd like to take a look at this. But from what I understand, IntelliJ plugins have to be developed in Java? What's the preferred way of interacting with d2lang from a different language?
It'll have to be calling the executable, I'm pretty sure. Google shows some results for calling Go from Java, but I suspect it'll be a lot of work.
- What about using a REST/gRPC interface for talking to d2? That would allow all languages to easily communicate with d2. Or are there any downsides to this approach?
- Where would you like the plugin code to live? separate repo or this one?
- Do you mean like a hosted, online API endpoint for that?
- Separate, e.g. https://github.com/terrastruct/d2-vscode
I meant something like implementing the language server protocol (LSP): https://microsoft.github.io/language-server-protocol/. From what I understand it uses JSON-RPC for communicating locally between a language server (d2) and a client (e.g. VSCode, IntelliJ, Confluence or whatever).
yeah we have a long-standing task to kick off that project (https://github.com/terrastruct/d2/issues/104). Not prioritized currently though. From what I understand (and it's not much, regarding this topic), an LSP is just adding additional features though right? Being able to syntax highlight, autoformat, display compiler errors on line numbers, these would compose a very usable plugin and don't benefit from an LSP
Ah my bad, I've never done anything with LSP myself.
But the possibility still stands, some sort of diagram server protocol that uses a similar protocol to compile diagrams maybe? Too complicated?
i think the one place structured data would be helpful is for compilation errors: which line is the error at? Currently, https://play.d2lang.com just parses the strings: https://github.com/terrastruct/d2-playground/blob/master/src/js/modules/editor.js#L302
It'd be annoying to implement for all languages that want to integrate with it for sure, but, not too bad as you can see from the code, so I'd say it's acceptable for now until LSP project is underway.
I'm really late to this but yes, Java annoyingly.
A few plugins eg: tfsec and trivy just use the command line operator to render it.
Easiest way imo is to make use of the inbuilt intellij browser and just render what ever there.
Happy to test and provide feedback, sadly I know no programming languages :(
Is there a roadmap or progress update available for this issue? While Visual Studio Code has a D2 extension, there doesn't seem to be a plugin for D2 in the JetBrains plugin market.
There is not. Just limited bandwidth and so much to do still for D2. The VSCode extension took a lot of effort, and even then, it would've fallen behind in maintenance if it weren't for someone in the community helping out.
The D2 for IntelliJ Platform based IDEs will be available in 1-2 weeks.
The D2 IntelliJ plugin will primarily focus on the editor features, and not on the preview (that is handled by D2 studio). However, a preview is provided through an embedded browser (JBCEF) for a server created by D2 --watch.
Disclaimer: I am acting as an open-source developer, not on behalf of JetBrains :)
The preview support for D2 files, as part of the Writerside plugin, is already completed. A new version of the Writerside plugin will be released around January 15th.
Could you please assist me in finding the official and free-to-use D2 logo assets? In particular, I need a plugin logo icon that like the one available here: https://github.com/terrastruct/d2-vscode/blob/master/d2-icon.png but in SVG format instead of PNG.
https://d2lang.com/img/d2_graphic.svg
The D2 plugin for IntelliJ is available in the marketplace.
Light
Dark (yes, we should instruct D2 to use a dark theme :)
Known issues:
- smart completion for shapes is not implemented (resolve and navigation works).
- FQN for shapes is not considered (if you have two shapes
fooin different containers, resolve and navigation will use the first defined one). - editor color style settings are not finished (well, in most cases, default generic is enough, so it will be not finished anytime soon without request)
- Formatting is file-level only — we delegate the work to D2 (to avoid reinventing the wheel). Still, basic spacing is respected according to the official D2 code style to avoid tedious space coding (for example, "Enter" after
{is handled correctly).