jesseduffield / lazygit

simple terminal UI for git commands
MIT License
52.66k stars 1.84k forks source link

custom EDITOR issue #3584

Closed peteringram0 closed 5 months ago

peteringram0 commented 5 months ago

Describe the bug Lazygit is not honouring custom set $EDITOR value. ZSH shell.

To Reproduce Steps to reproduce the behavior:

  1. Add the following to .zshrc
    # Helix compiled from src
    export HELIX_RUNTIME="$HOME/code/helix/runtime"
    export HELIX_SRC="$HOME/code/helix/target/release/hx"
    alias hx=$HELIX_SRC
    export EDITOR=$HELIX_SRC
  2. Confirm it works by running $EDITOR. It will open up the helix instance from source as expected
  3. Open lazygit, find a file and press character "e"

Expected behavior Lazygit should send the file specified to $EDITOR however it opens up in a default text based reader (some kind of fallback).

Version info: commit=, build date=, build source=homebrew, version=0.41.0, os=darwin, arch=arm64, git version=2.45.1 git version 2.45.1

Note Using the config below fixes the issue however this should not be needed if EDITOR within shell is set.

os:
  edit: '$EDITOR {{filename}}'
stefanhaller commented 5 months ago

It's a bit unusual to set the EDITOR variable to an absolute path, lazygit doesn't support that. My recommendation would be to do something like this instead:

export PATH="$HOME/code/helix/target/release:$PATH"
export EDITOR=hx

This should work.

peteringram0 commented 5 months ago

@stefanhaller This does work but only works if i remove helix from homebrew. Should the EDITOR variable not support both relative and local pathings?

stefanhaller commented 5 months ago

@stefanhaller This does work but only works if i remove helix from homebrew.

I don't understand, can you explain more?

Should the EDITOR variable not support both relative and local pathings?

It is only possible to support arbitrary paths for the edit command, but not for editAtLine (which is used when you press e in the staging view), because different editors have different command-line options for specifying the line number. That's why we decided to go with the editPreset approach that we are using now, which either defines all edit commands or none of them, since it would be confusing if pressing e in the files panel would open helix, but in the staging view it would open vim.

peteringram0 commented 5 months ago

@stefanhaller

I currently have helix installed via homebrew as well as having the source and a custom compiled version which i added to PATH as an ALIAS. This ALIAS seems to take pirority rather then items in PATH.

I didnt realise Lazygit does this, but after checking it only works for me using the lazygit config EDITOR override as per your comment suggests.

I think using this config is the best approach for me here and agree this is most likley unusual configuration from my side.