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

Allow setting the default layout engine #7

Open
eiswind opened this issue Jan 8, 2024 · 6 comments
Open

Allow setting the default layout engine #7

eiswind opened this issue Jan 8, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@eiswind
Copy link

eiswind commented Jan 8, 2024

Thanks for creating this!

It would be great if I could set the default layout engine somehow!

Maybe other defaults are intersting too:

d2 -w --sketch --layout=elk --pad=20

@eiswind
Copy link
Author

eiswind commented Jan 8, 2024

Sorry, it was hidden in the preview UI . It's working for me.

@eiswind eiswind closed this as completed Jan 8, 2024
@develar
Copy link
Owner

develar commented Jan 8, 2024

How do you set the default layout for CLI?

Here, there are two directions on how we can fix the issue —

  1. rely on D2_LAYOUT env — it should already work. We do not get or set D2_LAYOUT env on the plugin side, but the d2 process inherits the IDE app env, so it should already work (as we do not pass default --layout if no custom layout is specified).
  2. introduce the D2 settings page, where you can configure some defaults.

I am not against the second solution about settings. I want to avoid reinventing the wheel. Also, as it is an open-source project, I want to understand better the motivation to avoid introducing unneeded functionality :)

Sorry, it was hidden in the preview UI . It's working for me.

This state is preserved per each file. Not for all, meaning you will be forced to set the wanted layout for each new file (not a desired behavior :)).

Screenshot 2024-01-08 at 10 32 29

@develar develar reopened this Jan 8, 2024
@eiswind
Copy link
Author

eiswind commented Jan 8, 2024

D2_LAYOUT is at least a workaround. I usually render my diagrams with

d2 -w --sketch --layout=elk --pad=20

I read somewhere (didn't find it right now) that there are plans to allow setting these values in the d2 file (?)

@develar
Copy link
Owner

develar commented Jan 8, 2024

I read somewhere (didn't find it right now) that there are plans to allow setting these values in the d2 file (?)

It is already available in 0.6.3, please see https://d2lang.com/tour/vars/#configuration-variables (support for this syntax in upcoming plugin 1.2.0+)

@eiswind
Copy link
Author

eiswind commented Jan 8, 2024

Thx. I'll try that tomorrow!

@develar develar added the enhancement New feature or request label Jan 8, 2024
@eiswind
Copy link
Author

eiswind commented Jan 9, 2024

Works like a charm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants