From 0cfba17d3d432d92cd0ced2db516b3561cb5d709 Mon Sep 17 00:00:00 2001 From: Hadi <112569860+anotherhadi@users.noreply.github.com> Date: Tue, 19 May 2026 10:13:36 +0200 Subject: [PATCH] Edit the config "external_editor" to overwrite $EDITOR Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com> --- internal/config/config.go | 15 ++++++++------- internal/config/default_config.yaml | 1 + internal/util/editor.go | 7 ++++++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index dcab186..82a7b24 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -18,13 +18,14 @@ type Config struct { Version string `mapstructure:"-"` App struct { - Host string `mapstructure:"host"` - Port int `mapstructure:"port"` - CertDir string `mapstructure:"cert_dir"` - ProjectDir string `mapstructure:"project_dir"` - PluginsDir string `mapstructure:"plugins_dir"` - UpstreamProxy string `mapstructure:"upstream_proxy"` - MaxBodySizeMB int `mapstructure:"max_body_size_mb"` + Host string `mapstructure:"host"` + Port int `mapstructure:"port"` + CertDir string `mapstructure:"cert_dir"` + ProjectDir string `mapstructure:"project_dir"` + PluginsDir string `mapstructure:"plugins_dir"` + UpstreamProxy string `mapstructure:"upstream_proxy"` + MaxBodySizeMB int `mapstructure:"max_body_size_mb"` + ExternalEditor string `mapstructure:"external_editor"` } `mapstructure:"app"` TUI struct { diff --git a/internal/config/default_config.yaml b/internal/config/default_config.yaml index dceabce..1b001ca 100644 --- a/internal/config/default_config.yaml +++ b/internal/config/default_config.yaml @@ -6,6 +6,7 @@ app: plugins_dir: ~/.config/spilltea/plugins upstream_proxy: "" # e.g. http://corporate-proxy:8888 or http://user:pass@host:8888 max_body_size_mb: 50 # max response body size read into memory for large streamed responses (MB) + external_editor: "" # override $EDITOR for external editing (e.g. nvim, code --wait) intercept: default_intercept_enabled: true diff --git a/internal/util/editor.go b/internal/util/editor.go index 152cca8..3313ce1 100644 --- a/internal/util/editor.go +++ b/internal/util/editor.go @@ -5,6 +5,8 @@ import ( "os/exec" tea "charm.land/bubbletea/v2" + + "github.com/anotherhadi/spilltea/internal/config" ) type EditorFinishedMsg struct { @@ -13,7 +15,10 @@ type EditorFinishedMsg struct { } func OpenExternalEditor(content string) tea.Cmd { - editor := os.Getenv("EDITOR") + editor := config.Global.App.ExternalEditor + if editor == "" { + editor = os.Getenv("EDITOR") + } if editor == "" { editor = "vi" }