Help us shape the future of Go! Take the 2026 Go Developer Survey

pluginapi

package
v0.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 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

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 ExportSkipAction struct {
	// Action name, e.g. "actions.clipboard.copy"
	Action string
	// Error description about why this action is skipped
	Error error
}

type ExportSkipReport

type ExportSkipReport struct {
	SkipActions []ExportSkipAction
}

type ImportSkipAction

type ImportSkipAction struct {
	// EditorSpecificAction is the action name in the editor-specific format
	EditorSpecificAction string
	Error                error
}

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
}

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 PluginImportOption struct {
	// SourcePlatform specifies the platform of the source keybindings being imported.
	// This affects how modifier keys are parsed (e.g., "cmd" for macOS, "win" for Windows).
	// If empty, defaults to the current runtime platform.
	SourcePlatform platform.Platform
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL