Skip to content
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

IntelliJ plugin #747

Closed
userbradley opened this issue Feb 2, 2023 · 16 comments
Closed

IntelliJ plugin #747

userbradley opened this issue Feb 2, 2023 · 16 comments

Comments

@userbradley
Copy link

Hey,

Fond of this project, was wondering if you have in your project road map to develop a plugin for IntelliJ?

-b

@ghost
Copy link

ghost commented Feb 4, 2023

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?

@alixander
Copy link
Collaborator

alixander commented Feb 4, 2023

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.

@ghost
Copy link

ghost commented Feb 4, 2023

  1. 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?
  2. Where would you like the plugin code to live? separate repo or this one?

@alixander
Copy link
Collaborator

  1. Do you mean like a hosted, online API endpoint for that?
  2. Separate, e.g. https://github.com/terrastruct/d2-vscode

@ghost
Copy link

ghost commented Feb 4, 2023

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).

@alixander
Copy link
Collaborator

alixander commented Feb 4, 2023

yeah we have a long-standing task to kick off that project (#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

@ghost
Copy link

ghost commented Feb 4, 2023

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?

@alixander
Copy link
Collaborator

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.

@userbradley
Copy link
Author

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 :(

@1chz
Copy link

1chz commented Oct 18, 2023

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.

@alixander
Copy link
Collaborator

alixander commented Oct 18, 2023

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.

@develar
Copy link

develar commented Dec 23, 2023

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.

D2 Diagram

@develar
Copy link

develar commented Dec 27, 2023

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.

@alixander
Copy link
Collaborator

Oh good point will put up a page for design assets. Ty.

in the meantime:
d2-logo

@bo-ku-ra
Copy link
Contributor

@develar
Copy link

develar commented Dec 31, 2023

The D2 plugin for IntelliJ is available in the marketplace.

Light

Screenshot 2023-12-31 at 13 13 42

Dark (yes, we should instruct D2 to use a dark theme :)

Screenshot 2023-12-31 at 13 13 59

Known issues:

  • smart completion for shapes is not implemented (resolve and navigation works).
  • FQN for shapes is not considered (if you have two shapes foo in 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

5 participants