Documentation
¶
Index ¶
- Variables
- type ActionExportResult
- type ConfigDetectOptions
- type EditorSupportOnlyOneKeybindingPerActionError
- type EditorType
- type ExportSkipAction
- type ExportSkipReport
- type ExportedReport
- type ImportSkipAction
- type ImportSkipReport
- type Plugin
- type PluginExportOption
- type PluginExportReport
- type PluginExporter
- type PluginImportOption
- type PluginImportReport
- type PluginImportResult
- type PluginImporter
- type UnsupportedExportActionError
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotSupported is returned when a plugin does not support a requested operation, like import or export. ErrNotSupported = errors.New("not supported") // ErrActionNotSupported is returned when a plugin does not support a requested action. ErrActionNotSupported = errors.New("action not supported") )
Functions ¶
This section is empty.
Types ¶
type ActionExportResult ¶ added in v0.8.0
type ActionExportResult struct {
// Action name, e.g. "actions.clipboard.copy"
Action string
// Requested keybindings that were requested to be exported
Requested []keybinding.Keybinding
// Exported keybindings that were actually exported (may be fewer due to editor limitations)
Exported []keybinding.Keybinding
// Reason explains why some keybindings were not exported (optional)
Reason string
}
ActionExportResult describes the export outcome for a single action.
type ConfigDetectOptions ¶
type ConfigDetectOptions struct {
// Whether to in sandbox mode, in sandbox mode, shell command lookup is not effective, like `code` command for vscode can not be found
Sandbox bool
}
ConfigDetectOptions provides configuration for a config detect operation.
type EditorSupportOnlyOneKeybindingPerActionError ¶
type EditorSupportOnlyOneKeybindingPerActionError struct {
SkipKeybinding *keybinding.Keybinding
}
EditorSupportOnlyOneKeybindingPerActionError is returned when an editor does not support assigning multiple keybindings to a single action.
func (*EditorSupportOnlyOneKeybindingPerActionError) Error ¶
func (e *EditorSupportOnlyOneKeybindingPerActionError) Error() string
type EditorType ¶
type EditorType string
const ( EditorTypeUnknown EditorType = "unknown" // EditorTypeVSCode represents Visual Studio Code editor. EditorTypeVSCode EditorType = "vscode" EditorTypeWindsurf EditorType = "vscode.windsurf" EditorTypeWindsurfNext EditorType = "vscode.windsurf-next" EditorTypeCursor EditorType = "vscode.cursor" // EditorTypeIntelliJ represents IntelliJ IDEA Ultimate editor. EditorTypeIntelliJ EditorType = "intellij" EditorTypeIntelliJCommunity EditorType = "intellij.intellij-community" EditorTypePyCharm EditorType = "intellij.pycharm" EditorTypeWebStorm EditorType = "intellij.webstorm" EditorTypeClion EditorType = "intellij.clion" EditorTypePhpStorm EditorType = "intellij.phpstorm" EditorTypeRubyMine EditorType = "intellij.rubymine" EditorTypeGoLand EditorType = "intellij.goland" EditorTypeRustRover EditorType = "intellij.rustrover" EditorTypeZed EditorType = "zed" EditorTypeVim EditorType = "vim" EditorTypeHelix EditorType = "helix" EditorTypeXcode EditorType = "xcode" // EditorTypeBasekeymap is used to import base intellij/vscode/zed keymap EditorTypeBasekeymap EditorType = "basekeymap" )
func (EditorType) AppName ¶
func (e EditorType) AppName() string
AppName returns the human-readable display name for the editor type.
type ExportSkipAction ¶
type ExportSkipReport ¶
type ExportSkipReport struct {
SkipActions []ExportSkipAction
}
type ExportedReport ¶ added in v0.8.0
type ExportedReport struct {
Actions []ActionExportResult
}
ExportedReport contains detailed export results for each action. This is used by the exporter service to compute ExportCoverage.
type ImportSkipAction ¶
type ImportSkipReport ¶
type ImportSkipReport struct {
SkipActions []ImportSkipAction
}
type Plugin ¶
type Plugin interface {
// EditorType returns the unique identifier for the plugin (e.g., "vscode", "zed").
EditorType() EditorType
// ConfigDetect returns the default path to the editor's configuration file based on the platform.
// Return multiple paths if the editor has multiple configuration files.
ConfigDetect(opts ConfigDetectOptions) (paths []string, installed bool, err error)
// Importer returns an instance of PluginImporter for the plugin.
// Return ErrNotSupported if the plugin does not support importing.
Importer() (PluginImporter, error)
// Exporter returns an instance of PluginExporter for the plugin.
// Return ErrNotSupported if the plugin does not support exporting.
Exporter() (PluginExporter, error)
}
Plugin is the core interface that all editor plugins must implement. It defines the contract for importing and exporting keymaps.
type PluginExportOption ¶
type PluginExportOption struct {
// ExistingConfig provides a reader for the editor's current keymap
// configuration. If provided, the exporter will merge the settings
// instead of overwriting the entire file, preserving any keybindings
// not managed by onekeymap. If nil, the export will be destructive,
// creating a new file from scratch.
ExistingConfig io.Reader
// TargetPlatform specifies the target platform for the exported keybindings.
// This affects how modifier keys are formatted (e.g., "cmd" for macOS, "win" for Windows).
// If empty, defaults to the current runtime platform.
TargetPlatform platform.Platform
}
PluginExportOption provides configuration for an export operation.
type PluginExportReport ¶
type PluginExportReport struct {
// The diff between the base and the exported keymap.
// If base is nil or diff is not supported, this field will be nil.
Diff *string
// If BaseEditorConfig and ExportEditorConfig set, and Diff is not set, export exportService will calculate diff for plugin by using json diff
// BaseEditorConfig contains the original editor-specific configuration before export.
BaseEditorConfig any
// ExportEditorConfig contains the editor-specific configuration after export.
ExportEditorConfig any
// SkipReport reports actions that were not exported and why.
SkipReport ExportSkipReport
ExportedReport ExportedReport
}
PluginExportReport details issues encountered during an export operation.
type PluginExporter ¶
type PluginExporter interface {
// Export takes a universal KeymapSetting and writes it to an editor-specific
// configuration destination.
Export(
ctx context.Context,
destination io.Writer,
setting keymap.Keymap,
opts PluginExportOption,
) (*PluginExportReport, error)
}
type PluginImportOption ¶
type PluginImportReport ¶
type PluginImportReport struct {
// SkipReport contains details about actions that were skipped during the import operation.
SkipReport ImportSkipReport
}
PluginImportReport contains details about the import operation.
type PluginImportResult ¶
type PluginImportResult struct {
Keymap keymap.Keymap
Report PluginImportReport
}
PluginImportResult contains the result of an import operation.
type PluginImporter ¶
type PluginImporter interface {
// Import reads the editor's configuration source and converts it into the
// universal onekeymap KeymapSetting format.
Import(ctx context.Context, source io.Reader, opts PluginImportOption) (PluginImportResult, error)
}
type UnsupportedExportActionError ¶
type UnsupportedExportActionError struct {
Note string
}
UnsupportedExportActionError is returned when a plugin does not support a requested action when exporting
func (*UnsupportedExportActionError) Error ¶
func (e *UnsupportedExportActionError) Error() string