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
This commit is contained in:
Dax Raad
2025-06-18 22:59:42 -04:00
parent e5e9b3e3c0
commit bd8c3cd0f1
8 changed files with 273 additions and 123 deletions

View File

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