pluginapi

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2025 License: MIT Imports: 4 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 added in v0.7.0

type EditorSupportOnlyOneKeybindingPerActionError struct {
	SkipKeybinding *keymapv1.Keybinding
}

EditorSupportOnlyOneKeybindingPerActionError is returned when an editor does not support assigning multiple keybindings to a single action.

func (*EditorSupportOnlyOneKeybindingPerActionError) Error added in v0.7.0

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 NewEditorTypeFromAPI added in v0.2.1

func NewEditorTypeFromAPI(e keymapv1.EditorType) EditorType

func (EditorType) AppName added in v0.2.0

func (e EditorType) AppName() string

AppName returns the human-readable display name for the editor type.

func (EditorType) ToAPI added in v0.3.1

func (e EditorType) ToAPI() keymapv1.EditorType

ToAPI converts EditorType to proto EditorType.

type NotSupportedError added in v0.7.0

type NotSupportedError struct {
	Note string
}

func (*NotSupportedError) Error added in v0.7.0

func (e *NotSupportedError) Error() string

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
}

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 SkipReport
}

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 *keymapv1.Keymap,
		opts PluginExportOption,
	) (*PluginExportReport, error)
}

type PluginImportOption

type PluginImportOption struct {
}

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) (*keymapv1.Keymap, error)
}

type SkipAction added in v0.7.0

type SkipAction struct {
	Action string
	// Error description about why this action is skipped
	Error error
}

type SkipReport added in v0.7.0

type SkipReport struct {
	SkipActions []SkipAction
}

Jump to

Keyboard shortcuts

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