diff options
| author | Dax Raad <[email protected]> | 2025-06-18 22:59:42 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-06-18 23:01:19 -0400 |
| commit | bd8c3cd0f1e30f5ed1cbf222415cef136edd14a9 (patch) | |
| tree | 1e630283bb595c6e1f8ce21d83ae8ba99f24e51a /packages/tui/internal/commands | |
| parent | e5e9b3e3c04df00db57d573d3cc0a029736184b1 (diff) | |
| download | opencode-bd8c3cd0f1e30f5ed1cbf222415cef136edd14a9.tar.gz opencode-bd8c3cd0f1e30f5ed1cbf222415cef136edd14a9.zip | |
BREAKING CONFIG CHANGE
We have changed the config format yet again - but this should be the
final time. You can see the readme for more details but the summary is
- got rid of global providers config
- got rid of global toml
- global config is now in `~/.config/opencode/config.json`
- it will be merged with any project level config
Diffstat (limited to 'packages/tui/internal/commands')
| -rw-r--r-- | packages/tui/internal/commands/command.go | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/packages/tui/internal/commands/command.go b/packages/tui/internal/commands/command.go index 6f628ae31..12378c0b2 100644 --- a/packages/tui/internal/commands/command.go +++ b/packages/tui/internal/commands/command.go @@ -1,6 +1,7 @@ package commands import ( + "encoding/json" "slices" "strings" @@ -106,17 +107,6 @@ func (k Command) Matches(msg tea.KeyPressMsg, leader bool) bool { return false } -func (k Command) FromConfig(config *client.ConfigInfo) Command { - if config.Keybinds == nil { - return k - } - keybinds := *config.Keybinds - if keybind, ok := keybinds[string(k.Name)]; ok { - k.Keybindings = parseBindings(keybind) - } - return k -} - func parseBindings(bindings ...string) []Keybinding { var parsedBindings []Keybinding for _, binding := range bindings { @@ -278,8 +268,14 @@ func LoadFromConfig(config *client.ConfigInfo) CommandRegistry { }, } registry := make(CommandRegistry) + keybinds := map[string]string{} + marshalled, _ := json.Marshal(*config.Keybinds) + json.Unmarshal(marshalled, &keybinds) for _, command := range defaults { - registry[command.Name] = command.FromConfig(config) + if keybind, ok := keybinds[string(command.Name)]; ok { + command.Keybindings = parseBindings(keybind) + } + registry[command.Name] = command } return registry } |
