zellij-org / zellij

A terminal workspace with batteries included
https://zellij.dev
MIT License
20.57k stars 637 forks source link

[Feature Request] layout Template "imports" #2696

Open gozes opened 1 year ago

gozes commented 1 year ago

It would be great if I could create a layout template under zellij/layouts and be able to import/reference them in a layout so that I can construct a layout for a given project using does template instead of having to either redeclare the temple on each project or copy a layout from another project.

The use case I'm thinking of is that at the moment I have a number of go projects I work on every day but they all share very similar commands that I want to run in the project. For example for running the test it will always be make test even when each may have a different command that gets run by make. It would be awesome if I could declare pane_template for the go test command that I can reference in the layout.kdl in the project so that is one less pane I have to make for each go project.

This is a simplistic example that just runs a make command but you can imagine how you can have many of this small pane_template for whatever tech stack you are working with that will allow you to construct a layout for a given project using this "building blocks" + whatever other "custom" panes you need for the specific project

noirbizarre commented 8 months ago

May I add that with plugin system, it becomes more important because you can configure them.

As an example, I use https://github.com/dj95/zjstatus/ and now that I have a status bar configured, I need to copy-paste it into each layout. Each time I change a setting, I need to manually propagate it by copy-pasting into all existing layout. This is both error-prone and time-consuming.

Having an import would allow writing layout like this:

layout {
  import location="panes/basic.kdl"
  pane {
    import location="panes/editor.kdl"
    pane
  }
  import location="statusbar.kdl"

  floating_panes {
    import location="overlay.kdl"
  }
}

The same mechanism for templates would be just perfect:

layout {
  pane_template name="status-bar location="statusbar.kdl"
  tab {
    pane
    status-bar
  }
  tab {
    pane
    status-bar
  }
}
dev-vinicius-andrade commented 1 month ago

Any news regarding this?

mpasa commented 3 weeks ago

I have a similar use case with zjstatus. It would be nice to either have remote configuration for plugins or being able to reference templates in external files. My zjstatus bar is around 60 lines, and I want it in each of my layouts.

cristiand391 commented 3 weeks ago

I have a similar use case with zjstatus. It would be nice to either have remote configuration for plugins or being able to reference templates in external files. My zjstatus bar is around 60 lines, and I want it in each of my layouts.

Have you tried using plugin aliases? You can set zjstatus configured there and then use the alias in all your layouts.

https://zellij.dev/documentation/plugin-aliases

mpasa commented 3 weeks ago

@cristiand391 That's actually what I was looking for, thank you! So, a layout would be defined as this...

layout {
  pane size=1 borderless=true {
    plugin location="zjstatus"
  }
  pane
}

with all the config in the alias...

plugins {
    zjstatus location="https://github.com/dj95/zjstatus/releases/latest/download/zjstatus.wasm" {
      format_left   "{session} {tabs}"
      ...
    }
}