diff --git a/docs/Config.md b/docs/Config.md index 75a89be49fb..e48d4d10960 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -324,10 +324,13 @@ os: editPreset: 'vscode' ``` -Supported presets are `vim`, `nvim`, `emacs`, `nano`, `vscode`, `sublime`, `bbedit`, +Supported presets are `vim`, `nvim`, `nvim-remote`, `emacs`, `nano`, `vscode`, `sublime`, `bbedit`, `kakoune`, `helix`, and `xcode`. In many cases lazygit will be able to guess the right preset from your $(git config core.editor), or an environment variable such as $VISUAL or $EDITOR. +`nvim-remote` is an experimental preset for when you have invoked lazygit from within a neovim +process, allowing lazygit to open the file from within the parent process rather than spawning a new one. + If for some reason you are not happy with the default commands from a preset, or there simply is no preset for your editor, you can customize the commands by setting the `edit`, `editAtLine`, and `editAtLineAndWait` options, e.g.: diff --git a/pkg/config/editor_presets.go b/pkg/config/editor_presets.go index 92374280bb7..586f1b15b57 100644 --- a/pkg/config/editor_presets.go +++ b/pkg/config/editor_presets.go @@ -48,9 +48,17 @@ type editPreset struct { // IF YOU ADD A PRESET TO THIS FUNCTION YOU MUST UPDATE THE `Supported presets` SECTION OF docs/Config.md func getPreset(osConfig *OSConfig, guessDefaultEditor func() string) *editPreset { presets := map[string]*editPreset{ - "vi": standardTerminalEditorPreset("vi"), - "vim": standardTerminalEditorPreset("vim"), - "nvim": standardTerminalEditorPreset("nvim"), + "vi": standardTerminalEditorPreset("vi"), + "vim": standardTerminalEditorPreset("vim"), + "nvim": standardTerminalEditorPreset("nvim"), + "nvim-remote": { + editTemplate: `nvim --server "$NVIM" --remote-tab {{filename}}`, + editAtLineTemplate: `nvim --server "$NVIM" --remote-tab {{filename}}; [ -z "$NVIM" ] || nvim --server "$NVIM" --remote-send ":{{line}}"`, + // No remote-wait support yet. See https://github.com/neovim/neovim/pull/17856 + editAtLineAndWaitTemplate: `nvim +{{line}} {{filename}}`, + openDirInEditorTemplate: `nvim --server "$NVIM" --remote-tab {{dir}}`, + editInTerminal: false, + }, "emacs": standardTerminalEditorPreset("emacs"), "nano": standardTerminalEditorPreset("nano"), "kakoune": standardTerminalEditorPreset("kak"),