Last active
July 30, 2025 16:42
-
-
Save delVhariant/d3d814b4ed837a1e584d7c0f6a274fab to your computer and use it in GitHub Desktop.
Helix as external editor for Godot (using Zellij)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| Setup using zellij with helix and lazygit to develop for Godot. | |
| The hx.fish script is specific to my setup and will require alteration unless you already happen to be using i3, fish shell and xfce4-terminal | |
| Since Helix doesn't support a client/server model that would allow us to open buffers in an existing session, zellij is used. | |
| This also lets me use lazygit from within zellij as a floating pane, and have terminals. | |
| Download and alter the hx.fish script to fit your setup (this may be somewhat difficult depending on what tools you use. | |
| Most of the script exists to ensure that everything opens within the same terminal/zellij session, and that files are opened as buffers in the same helix process. | |
| The allows me to open files from the godot editor directly without creating a new window each time. | |
| In Godot, set the external editor path as: | |
| /path/to/hx.fish | |
| And the exec flags to: | |
| {file}:{line}:{col} {project} | |
| The provided zellix.kdl file is my default layout for zellij + helix. It has a main panel for helix, and two terminal windows. | |
| It will also open lazygit in a floating panel when ALT+G is pressed, even when zellix itself is locked. | |
| The Godot LSP setup is as per https://github.com/helix-editor/helix/wiki/Language-Server-Configurations#gdscript, but I also use "simple-completion-language-server" https://github.com/estin/simple-completion-language-server to support snippets and work completion. | |
| My languages.toml is included as well. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env fish | |
| set session helix | |
| set tab Helix | |
| set window_name zellix | |
| # Get the existing window of our session | |
| set window (i3-msg -t get_tree | jq 'recurse(.nodes[]) | select(.window != null and .window_properties.title == "$window_name")') | |
| function new_term_session -d "Creates a new terminal instance running zellij" | |
| xfce4-terminal -T "$window_name" -x zellij -s "$session" | |
| end | |
| function get_helix_info -d "Checks if a zellij session is running helix" | |
| echo (for p in (pgrep -x helix); pstree -s $p | grep zellij; end) | |
| end | |
| if test -z "$argv[1]" | |
| echo "No file provided" | |
| exit 1 | |
| end | |
| # Move into our target directory | |
| if not test -z "$argv[2]" | |
| echo "Switching to $argv[2]" | |
| cd "$argv[2]" | |
| # zellij -s "$session" run -- cd "$argv[2]" | |
| end | |
| # Open Zellij in a new terminal session | |
| if test -z (zellij ls | grep "$session") | |
| echo "Starting session $session" | |
| new_term_session | |
| else if not test -z (zellij ls | grep "$session" | grep "DEAD") | |
| echo "Attaching to existing (dead) session" | |
| new_term_session | |
| else if not test -z (zellij ls | grep "$session" | grep "EXITED") | |
| echo "Killing and starting new session" | |
| zellij d "$session" | |
| sleep 0.5 | |
| new_term_session | |
| else if test -z "$window" | |
| echo "Attaching to existing (windowless) session" | |
| new_term_session | |
| else | |
| echo "Session exists, opening file $argv[1]" | |
| end | |
| # Go to the helix tab, creating it if needed. | |
| zellij -s "$session" action go-to-tab-name "$tab" --create | |
| sleep 0.5 | |
| # Open helix if not already running | |
| if test -z (for p in (pgrep -x helix); pstree -s $p | grep zellij; end) | |
| echo "Opening helix" | |
| zellij -s "$session" action write-chars "helix $argv[1]" # Do this instead of 'zellij run' so we stay in the helix pane | |
| zellij -s "$session" action write 13 # ENTER | |
| else # Otherwise open the file | |
| echo "Using existing helix" | |
| zellij -s "$session" action write 27 # ESC | |
| zellij -s "$session" action write-chars ":open $argv[1]" | |
| zellij -s "$session" action write 13 # ENTER | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # introduce new language server | |
| [language-server.scls] | |
| command = "simple-completion-language-server" | |
| [language-server.scls.config] | |
| max_completion_items = 20 # set max completion results len for each group: words, snippets, unicode-input | |
| snippets_first = true # completions will return before snippets by default | |
| snippets_inline_by_word_tail = false # suggest snippets by WORD tail, for example text `xsq|` become `x^2|` when snippet `sq` has body `^2` | |
| feature_words = true # enable completion by word | |
| feature_snippets = true # enable snippets | |
| feature_unicode_input = true # enable "unicode input" | |
| feature_paths = true # enable path completion | |
| feature_citations = false # enable citation completion (only on `citation` feature enabled) | |
| # write logs to /tmp/completion.log | |
| [language-server.scls.environment] | |
| RUST_LOG = "info,simple-completion-language-server=info" | |
| LOG_FILE = "/tmp/completion.log" | |
| [language-server.godot] | |
| command = "nc" # or nc | |
| args = [ "127.0.0.1", "6005"] | |
| [[language]] | |
| name = "gdscript" | |
| language-servers = ["godot", "scls"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| layout { | |
| tab name="Helix" { | |
| pane size=1 borderless=true { | |
| plugin location="zellij:tab-bar" | |
| } | |
| pane { | |
| name "helix" | |
| command "helix" | |
| args "." | |
| } | |
| pane split_direction="vertical" size="20%" { | |
| pane { | |
| name "terminal" | |
| } | |
| pane { | |
| name "terminal2" | |
| } | |
| } | |
| pane size=2 borderless=true { | |
| plugin location="zellij:status-bar" | |
| } | |
| } | |
| } | |
| keybinds { | |
| shared { | |
| bind "Alt g" { | |
| Run "lazygit" { | |
| x: "12%"; | |
| y: "12%"; | |
| width "75%"; | |
| height "75%"; | |
| close_on_exit true; | |
| }; | |
| TogglePaneEmbedOrFloating; | |
| } | |
| } | |
| } | |
| ui { | |
| pane_frames { | |
| rounded_corners true | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment