Helix as my Golang IDE: powering up with WezTerm and CLI tools
2024-10-10
Categories: Development Environment
It’s has been one year from my last post. Today I would like to show you how I use Helix as my Golang IDE.
Regarding the file explorer workaround in the last post, I show you how to use nnn or broot to open a file tree in the sidebar but actually I’m using the PR #5768. The reason is I would like to have a bottom pane for the terminal, and there is no way to just hide it and keep the sidebar (file explorer) and the main pane (helix).
Originated from the markstos’s ideas, I’ve updated my helix-wezterm.sh to make it configurable. You can see the whole script [here]().
- File explorer
To be hornest, once I familiar myself with the codebase, I don’t use the file explorer too much. However, as a side effect, the file explorer in the sidebar move my code to the center view instead of the left side.
I like the floating pane feature from Zellij a lot. Actually I attempted to implement a file explorer using this feature. However, due to the key binding and one more nested layer, I decided using WezTerm from the beginning.
With a PR recently to create a floating pane in WezTerm, I want to give it a try. Here’s my config:
actions:
explorer:
position: floating
command: HX_PANE_ID=$WEZTERM_PANE YAZI_CONFIG_HOME=~/.config/yazi/filetree yazi
Basically, with version 2 of my helix-wezterm.sh script, you can just define and action, the position (left, bottom, floating, …) and the command to run.
I “steal” the idea to setup file tree using yazi from here.
My Helix config:
[keys.normal.";"]
e = ":sh helix-wezterm.sh explorer"
keymap.toml:
[[manager.prepend_keymap]]
on = ["l"]
run = 'plugin --sync smart-enter'
desc = 'Enter the child directory, or open the file'
~/.config/yazi/filetree/plugins/smart-enter.yazi/init.lua:
return {
entry = function()
local h = cx.active.current.hovered
if h.cha.is_dir then
ya.manager_emit('enter' or 'open', { hovered = true })
else
local file_path = tostring(h.url)
local hx_pane_id = os.getenv("HX_PANE_ID")
-- Send ":" to start command input in Helix
os.execute('wezterm cli send-text --pane-id ' .. hx_pane_id .. ' --no-paste ":"')
-- Send the "open" command with file path(s) to the pane
os.execute('wezterm cli send-text --pane-id ' .. hx_pane_id .. ' "open ' .. file_path .. '"')
-- Simulate 'Enter' key to execute the command
os.execute('printf "\r" | wezterm cli send-text --pane-id ' .. hx_pane_id .. ' --no-paste')
os.execute('wezterm cli activate-pane --pane-id ' .. hx_pane_id)
end
end,
}
So, ; - e will open a file tree using yazi in the floating pane. Then navigating to the selected file, and press l will open it in the Helix pane.
- WezTerm floating pane
- yazi
- debug go: restful, debug test
- WezTerm Input Selector
- mockery
- gotests
- quicktype
- hurl
- go-enum
- open in gitlab
- golangci-lint
- lazysql
- extract function
- gorm/gen/tools
- mermaid, graph-easy, slides, presenterm
- select json -> pipe to jq
- slumber
Tags: helix lazygit tig wezterm yazi
Quan Tong