mappings

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: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionMappingConfig

type ActionMappingConfig struct {
	ID          string `yaml:"id"`
	Description string `yaml:"description"`
	Name        string `yaml:"name"`
	// Featured means that this action is implemented within one or few editors and is not portable
	Featured bool `yaml:"featured"`
	// FeaturedReason: Why this action is not common across editors, or recommand users to use another portable actioin of similar utility.
	FeaturedReason string                `yaml:"featuredReason"`
	Category       string                `yaml:"category"`
	VSCode         VscodeConfigs         `yaml:"vscode"`
	Windsurf       VscodeConfigs         `yaml:"windsurf"`
	Cursor         VscodeConfigs         `yaml:"cursor"`
	Zed            ZedConfigs            `yaml:"zed"`
	IntelliJ       IntelliJMappingConfig `yaml:"intellij"`
	Vim            VimMappingConfig      `yaml:"vim"`
	Helix          HelixConfig           `yaml:"helix"`
	Xcode          XcodeConfigs          `yaml:"xcode"`
	// Children is a list of child action IDs for UI hierarchical grouping only.
	// This field has no effect on export/import logic.
	Children []string `yaml:"children,omitempty"`
	// Fallbacks is a list of action IDs used for export fallback.
	// When this action is not supported by a target editor, the system will try each fallback in order.
	Fallbacks []string `yaml:"fallbacks,omitempty"`
}

ActionMappingConfig holds the complete mapping information for a single action ID.

func (*ActionMappingConfig) GetVSCodeConfigs added in v0.7.2

func (am *ActionMappingConfig) GetVSCodeConfigs(editorType pluginapi.EditorType) VscodeConfigs

GetVSCodeConfigs returns the VSCode configs for the given editor type. Priority: variant-specific config > vscode config (fallback).

func (*ActionMappingConfig) IsSupported

func (am *ActionMappingConfig) IsSupported(editorType pluginapi.EditorType) (bool, string)

IsSupported checks if the action is supported by the given editor type. Returns (supported, note).

type DuplicateActionMappingError

type DuplicateActionMappingError struct {
	Editor string
	// editor action name -> all involved universal action ids
	Duplicates map[string][]string
}

func (*DuplicateActionMappingError) Error

type EditorActionMapping

type EditorActionMapping struct {
	// when true, this config is only used for export, otherwise it is used for both import and export
	DisableImport bool `yaml:"disableImport,omitempty"`

	// explicitly set to true if this config is not supported by the editor
	NotSupported bool `yaml:"notSupported,omitempty"`
	// reason why this config is not supported by the editor
	Note string `yaml:"note,omitempty"`
}

EditorActionMapping provides extra flags for editor-specific configurations.

type HelixConfig

type HelixConfig []HelixMappingConfig

func (*HelixConfig) UnmarshalYAML

func (h *HelixConfig) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements the yaml.Unmarshaler interface for HelixConfigs. It supports both a single mapping object and a sequence of objects.

type HelixMappingConfig

type HelixMappingConfig struct {
	EditorActionMapping `yaml:",inline"`

	Command string `yaml:"command"`
	Mode    string `yaml:"mode"`
}

type IntelliJMappingConfig

type IntelliJMappingConfig struct {
	EditorActionMapping `yaml:",inline"`

	Action string `yaml:"action"`
}

type MappingConfig

type MappingConfig struct {
	// Mappings is a map where the key is the one_keymap_id (e.g., "actions.editor.copy")
	// and the value is the detailed mapping information for that action.
	Mappings map[string]ActionMappingConfig
}

MappingConfig holds the final, merged mapping config, indexed by action ID. It serves as a `Anemic Domain Model` because I want the editor specific config query to be implemented in plugin.

func NewMappingConfig

func NewMappingConfig() (*MappingConfig, error)

func NewTestMappingConfig

func NewTestMappingConfig() (*MappingConfig, error)

func (*MappingConfig) Get

func (mc *MappingConfig) Get(actionID string) *ActionMappingConfig

Get searches for a mapping by universal action ID.

func (*MappingConfig) GetExportAction added in v0.7.2

func (mc *MappingConfig) GetExportAction(
	actionID string,
	editorType pluginapi.EditorType,
) (*ActionMappingConfig, bool)

GetExportAction returns the action config to use for export. If the action is supported by the editor, it returns the action itself. If not supported, it falls back to the first supported fallback action. Returns nil if no suitable action is found. The second return value is true if a fallback was used.

func (*MappingConfig) IsActionMapped

func (mc *MappingConfig) IsActionMapped(action string) bool

IsActionMapped checks if a universal action ID is defined in the mapping configuration.

type StringOrSlice

type StringOrSlice struct {
	Items []string
}

StringOrSlice supports unmarshalling a YAML field that may be a single string or a sequence of strings.

func (*StringOrSlice) UnmarshalYAML

func (s *StringOrSlice) UnmarshalYAML(node *yaml.Node) error

type VimMappingConfig

type VimMappingConfig struct {
	EditorActionMapping `yaml:",inline"`

	Command string `yaml:"command"`
	Mode    string `yaml:"mode"`
}

type VscodeConfigs

type VscodeConfigs []VscodeMappingConfig

VscodeConfigs is a slice of VscodeMappingConfig that can be unmarshalled from either a single YAML object or a sequence of objects.

func (*VscodeConfigs) UnmarshalYAML

func (v *VscodeConfigs) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type VscodeMappingConfig

type VscodeMappingConfig struct {
	EditorActionMapping `yaml:",inline"`

	Command string                 `yaml:"command"`
	When    string                 `yaml:"when"`
	Args    map[string]interface{} `yaml:"args,omitempty"`
}

VscodeMappingConfig defines the structure for VSCode's mapping, including the command and its context.

type XcodeConfigs

type XcodeConfigs []XcodeMappingConfig

XcodeConfigs is a slice of XcodeMappingConfig that can be unmarshalled from either a single YAML object or a sequence of objects.

func (*XcodeConfigs) UnmarshalYAML

func (x *XcodeConfigs) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type XcodeMappingConfig

type XcodeMappingConfig struct {
	EditorActionMapping `yaml:",inline"`

	// The Xcode text action name(s) for Text Key Bindings. Accepts a string or array in YAML.
	TextAction XcodeTextAction `yaml:",inline"`

	// The Xcode menu action name for Menu Key Bindings (e.g., "moveWordLeft:", "selectWord:")
	MenuAction XcodeMenuAction `yaml:",inline"`
}

XcodeMappingConfig defines the structure for Xcode's mapping, including the action and optional command context.

type XcodeMenuAction

type XcodeMenuAction struct {
	// The Xcode action name (e.g., "moveWordLeft:", "selectWord:")
	Action string `yaml:"action"`
	// The command group ID
	CommandGroupID string `yaml:"commandGroupID,omitempty"`
	// The Xcode command ID for menu bindings (optional)
	CommandID string `yaml:"commandID,omitempty"`
	// Whether this is an alternate key binding
	Alternate string `yaml:"alternate,omitempty"`
	// The menu group this action belongs to
	Group string `yaml:"group,omitempty"`
	// The menu group ID
	GroupID string `yaml:"groupID,omitempty"`
	// Whether this is a grouped alternate key binding
	GroupedAlternate string `yaml:"groupedAlternate,omitempty"`
	// Whether this is a navigation action
	Navigation string `yaml:"navigation,omitempty"`
	// The parent title for nested menu items
	ParentTitle string `yaml:"parentTitle,omitempty"`
	// The title of the action
	Title string `yaml:"title,omitempty"`
}

type XcodeTextAction

type XcodeTextAction struct {
	TextAction StringOrSlice `yaml:"textAction,omitempty"`
}

type ZedConfigs

type ZedConfigs []ZedMappingConfig

func (*ZedConfigs) UnmarshalYAML

func (z *ZedConfigs) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements the yaml.Unmarshaler interface for ZedConfigs. It supports both a single mapping object and a sequence of objects.

type ZedMappingConfig

type ZedMappingConfig struct {
	EditorActionMapping `yaml:",inline"`

	Action  string                 `yaml:"action"`
	Context string                 `yaml:"context"`
	Args    map[string]interface{} `yaml:"args,omitempty"`
}

Jump to

Keyboard shortcuts

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