summaryrefslogtreecommitdiffstats
path: root/pkg/config
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/config')
-rw-r--r--pkg/config/editor_presets.go16
-rw-r--r--pkg/config/user_config.go3
2 files changed, 19 insertions, 0 deletions
diff --git a/pkg/config/editor_presets.go b/pkg/config/editor_presets.go
index d489c9283..78a490cc0 100644
--- a/pkg/config/editor_presets.go
+++ b/pkg/config/editor_presets.go
@@ -28,10 +28,20 @@ func GetEditAtLineAndWaitTemplate(osConfig *OSConfig, guessDefaultEditor func()
return template
}
+func GetOpenDirInEditorTemplate(osConfig *OSConfig, guessDefaultEditor func() string) string {
+ preset := getPreset(osConfig, guessDefaultEditor)
+ template := osConfig.OpenDirInEditor
+ if template == "" {
+ template = preset.openDirInEditorTemplate
+ }
+ return template
+}
+
type editPreset struct {
editTemplate string
editAtLineTemplate string
editAtLineAndWaitTemplate string
+ openDirInEditorTemplate string
editInTerminal bool
}
@@ -48,30 +58,35 @@ func getPreset(osConfig *OSConfig, guessDefaultEditor func() string) *editPreset
editTemplate: "hx -- {{filename}}",
editAtLineTemplate: "hx -- {{filename}}:{{line}}",
editAtLineAndWaitTemplate: "hx -- {{filename}}:{{line}}",
+ openDirInEditorTemplate: "hx {{dir}}",
editInTerminal: true,
},
"vscode": {
editTemplate: "code --reuse-window -- {{filename}}",
editAtLineTemplate: "code --reuse-window --goto -- {{filename}}:{{line}}",
editAtLineAndWaitTemplate: "code --reuse-window --goto --wait -- {{filename}}:{{line}}",
+ openDirInEditorTemplate: "code {{dir}}",
editInTerminal: false,
},
"sublime": {
editTemplate: "subl -- {{filename}}",
editAtLineTemplate: "subl -- {{filename}}:{{line}}",
editAtLineAndWaitTemplate: "subl --wait -- {{filename}}:{{line}}",
+ openDirInEditorTemplate: "subl {{dir}}",
editInTerminal: false,
},
"bbedit": {
editTemplate: "bbedit -- {{filename}}",
editAtLineTemplate: "bbedit +{{line}} -- {{filename}}",
editAtLineAndWaitTemplate: "bbedit +{{line}} --wait -- {{filename}}",
+ openDirInEditorTemplate: "bbedit {{dir}}",
editInTerminal: false,
},
"xcode": {
editTemplate: "xed -- {{filename}}",
editAtLineTemplate: "xed --line {{line}} -- {{filename}}",
editAtLineAndWaitTemplate: "xed --line {{line}} --wait -- {{filename}}",
+ openDirInEditorTemplate: "xed {{dir}}",
editInTerminal: false,
},
}
@@ -107,6 +122,7 @@ func standardTerminalEditorPreset(editor string) *editPreset {
editTemplate: editor + " -- {{filename}}",
editAtLineTemplate: editor + " +{{line}} -- {{filename}}",
editAtLineAndWaitTemplate: editor + " +{{line}} -- {{filename}}",
+ openDirInEditorTemplate: editor + " {{dir}}",
editInTerminal: true,
}
}
diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go
index efff609fe..6ac64b2b5 100644
--- a/pkg/config/user_config.go
+++ b/pkg/config/user_config.go
@@ -318,6 +318,9 @@ type OSConfig struct {
// Pointer to bool so that we can distinguish unset (nil) from false.
EditInTerminal *bool `yaml:"editInTerminal,omitempty"`
+ // For opening a directory in an editor
+ OpenDirInEditor string `yaml:"openDirInEditor,omitempty"`
+
// A built-in preset that sets all of the above settings. Supported presets
// are defined in the getPreset function in editor_presets.go.
EditPreset string `yaml:"editPreset,omitempty"`