Try to identify vim variants
Fixes
RELEASE_NOTES=[BUGFIX] Only pass vim options to vim
@@ -10,6 +10,7 @@ import (
"os/exec"
"path/filepath"
"runtime"
+ "strings"
"github.com/fatih/color"
"github.com/gopasspw/gopass/pkg/ctxutil"
@@ -108,7 +109,9 @@ func vimOptions(editor string) []string {
fmt.Sprintf("autocmd BufNewFile,BufRead %s setlocal noswapfile nobackup noundofile %s", path, viminfo),
}
- if editor == "nvi" {
+ if !isVim(editor) {
+ debug.Log("Editor %s is not known to be vim compatible", editor)
+
return args
}
@@ -118,6 +121,21 @@ func vimOptions(editor string) []string {
return args
}
+// isVim tries to identify the vi variant as vim compatible or not.
+func isVim(editor string) bool {
+ if editor == "neovim" {
+ return true
+ }
+
+ cmd := exec.Command(editor, "--version")
+ out, err := cmd.CombinedOutput()
+ if err != nil {
+ return false
+ }
+
+ return strings.Contains(string(out), "VIM - Vi IMproved")
+}
+
// resolveEditor tries to resolve the final link destination of the editor name given
// and then extract the binary file name from the path. In practice the actual editor
// is often hidden behing several layers of indirection and we want to get an idea
