Skip to content

Introduce TOML configuration support and deprecate JSON config (#68)#303

Open
Guria wants to merge 1 commit intomikker:mainfrom
Guria:codex-toml-config
Open

Introduce TOML configuration support and deprecate JSON config (#68)#303
Guria wants to merge 1 commit intomikker:mainfrom
Guria:codex-toml-config

Conversation

@Guria
Copy link

@Guria Guria commented Jan 15, 2026

  • Added support for TOML configuration format alongside JSON.
  • Created a new ConfigFormat enum to manage file extensions and names.
  • Implemented encoding and decoding methods for TOML in UserConfig.
  • Updated file handling to prefer TOML format and added detection logic.
  • Refactored existing JSON handling to accommodate the new format.
  • Added conversion method to convert existing JSON configs to TOML.
  • Introduced comprehensive unit tests for TOML parsing and serialization.
  • Updated README and sample configuration file to reflect new TOML format.

Prepared in collaboration with Claude and Codex

Image

Sample from wiki converted reduced 328 to 73 LOC:

@miiraheart's config

# Leader Key Configuration

t = "Ghostty"
1 = "raycast://extensions/krzysztoff1/yabai/focus-space?arguments=%7B%22spaceIndex%22%3A%221%22%7D"
2 = "raycast://extensions/krzysztoff1/yabai/focus-space?arguments=%7B%22spaceIndex%22%3A%222%22%7D"
3 = "raycast://extensions/krzysztoff1/yabai/focus-space?arguments=%7B%22spaceIndex%22%3A%223%22%7D"
4 = "raycast://extensions/krzysztoff1/yabai/focus-space?arguments=%7B%22spaceIndex%22%3A%224%22%7D"
5 = "raycast://extensions/krzysztoff1/yabai/focus-space?arguments=%7B%22spaceIndex%22%3A%225%22%7D"
6 = "raycast://extensions/krzysztoff1/yabai/focus-space?arguments=%7B%22spaceIndex%22%3A%226%22%7D"
l = "raycast://extensions/krzysztoff1/yabai/windows-list-current-space"
c = "raycast://extensions/krzysztoff1/yabai/create-space-and-focus"
d = "raycast://extensions/krzysztoff1/yabai/destroy-space"
x = "raycast://script-commands/show-leaderkey-settings"

[b]
b = "/Applications/Brave Browser.app"
n = "raycast://extensions/ron-myers/brave/new-tab"
t = "raycast://extensions/ron-myers/brave/search-tab"
h = "raycast://extensions/ron-myers/brave/search-history"

[v]
o = "/Applications/Oryx.app"
k = "/Applications/keymapp.app"

[a]
f = "Finder"
a = "App Store"
b = "Bitwarden"
c = "/Applications/Setapp/Calendars.app"
u = "/Applications/ClickUp.app"
d = "/Applications/Discord.app"
i = "Messages"
n = "/Applications/Notion.app"
m = "/Applications/Proton Mail.app"
v = "/Applications/ProtonVPN.app"
t = "/Applications/Setapp/TypingMind.app"
r = "Raycast"
k = "/Applications/Keyboard Maestro.app"
x = "Visual Studio Code"

[a.s]
a = "/Applications/Setapp.app"
s = "/Applications/Spotify.app"
t = "/Applications/Setapp/Session.app"

[s]
w = "raycast://extensions/raycast/navigation/switch-windows"
q = "raycast://extensions/mackopes/quit-applications/index"
a = "raycast://extensions/raycast/system/toggle-system-appearance"
m = "Mission Control"
x = "System Settings"
d = "open x-apple.systempreferences:com.apple.Displays-Settings.extension"
e = "raycast://script-commands/toggle-ipad-screen"
k = "open \"x-apple.systempreferences:com.apple.preference.keyboard?Shortcuts\""
s = "open \"x-apple.systempreferences:com.apple.Displays-Settings.extension?arrangementSection\""

[w]
l = "raycast://extensions/HelloImSteven/keyboard-shortcut-sequences/run-shortcut-sequence?arguments=%7B%22sequenceName%22%3A%221piece%20-%20Window%20List%22%7D"
d = "raycast://extensions/HelloImSteven/keyboard-shortcut-sequences/run-shortcut-sequence?arguments=%7B%22sequenceName%22%3A%221piece%20-%20Desktop%20Windows%20list%22%7D"
m = "raycast://extensions/HelloImSteven/keyboard-shortcut-sequences/run-shortcut-sequence?arguments=%7B%22sequenceName%22%3A%221piece%20-%20Window%20Manager%20Menu%22%7D"
p = "raycast://extensions/HelloImSteven/keyboard-shortcut-sequences/run-shortcut-sequence?arguments=%7B%22sequenceName%22%3A%221piece%20-%20Switch%20to%20Prev%20Window%22%7D"

[o]
d = "/Users/miira/Documents"
w = "/Users/miira/Downloads"
k = "/Users/miira/Desktop"
a = "/Applications"
c = "/Users/miira/.config"
h = "/Users/miira"
s = "raycast://extensions/asubbotin/shell/index?arguments=%7B%22command%22%3A%22vim%20%7E%2F.config%2Fskhd%2Fskhdrc%22%7D"

[y]
s = "raycast://extensions/HelloImSteven/keyboard-shortcut-sequences/run-shortcut-sequence?arguments=%7B%22sequenceName%22%3A%22Enable%20Stackline%22%7D"

closes #68

…r#68)

- Added support for TOML configuration format alongside JSON.
- Created a new `ConfigFormat` enum to manage file extensions and names.
- Implemented encoding and decoding methods for TOML in `UserConfig`.
- Updated file handling to prefer TOML format and added detection logic.
- Refactored existing JSON handling to accommodate the new format.
- Added conversion method to convert existing JSON configs to TOML.
- Introduced comprehensive unit tests for TOML parsing and serialization.
- Updated README and sample configuration file to reflect new TOML format.
Copilot AI review requested due to automatic review settings January 15, 2026 07:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces TOML configuration format support to Leader Key while maintaining backward compatibility with the existing JSON format. The TOML format is now preferred for new installations, with JSON being deprecated but still supported for existing users.

Changes:

  • Added TOML parsing and serialization using the TOMLKit library
  • Implemented automatic format detection that prefers TOML over JSON
  • Created a conversion tool to migrate JSON configs to TOML with automatic backup
  • Updated documentation and sample configuration to reflect the new format

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
config.sample.toml New sample configuration file demonstrating TOML syntax
README.md Updated documentation to reference TOML format and config path
AGENTS.md Updated coding agent guidance to reflect TOML-first approach
Leader Key/TOMLConfig.swift New file implementing TOML parsing and serialization logic
Leader Key/UserConfig.swift Added ConfigFormat enum, TOML support, and conversion functionality
Leader Key/Settings/AdvancedPane.swift Added UI for JSON-to-TOML conversion in settings
Leader KeyTests/TOMLConfigTests.swift Comprehensive test suite for TOML parsing and serialization
Leader KeyTests/UserConfigTests.swift Updated tests to use TOML format

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -0,0 +1,40 @@
# Leader Key Configuration (sample)
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says '(sample)' but this appears to be an actual sample file. Consider changing to 'Leader Key Configuration Sample' for clarity.

Suggested change
# Leader Key Configuration (sample)
# Leader Key Configuration Sample

Copilot uses AI. Check for mistakes.
- `AppDelegate`: Application lifecycle, global shortcuts registration, update management
- `Controller`: Central event handling, manages key sequences and window display
- `UserConfig`: JSON configuration management with validation
- `UserConfig`: TOML-first (JSON legacy) configuration management with validation
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description uses parentheses for 'JSON legacy' which could be clearer. Consider revising to 'Configuration management with TOML format (JSON deprecated) and validation' for better clarity.

Suggested change
- `UserConfig`: TOML-first (JSON legacy) configuration management with validation
- `UserConfig`: Configuration management with TOML format (JSON deprecated) and validation

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: Switch from JSON to YAML for Config Files

1 participant

Comments