zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
49.28k stars 2.99k forks source link

Conditional / per-machine settings / profiles? #16392

Open haasn opened 2 months ago

haasn commented 2 months ago

Check for existing issues

Describe the feature

I am using a git repository to synchronize my settings (and keymap) across machines. However, my two devices have radically different input methods (ergonomic keyboard vs standard laptop slab), and as such, want some slightly different keybindings. Complicating things is the fact that I sometimes attach the input device from my desktop to my laptop instead.

It would be fantastic if there was some way to solve this, and let me use both input devices interchangeably, with my keybindings adjusting to compensate.

If applicable, add mockups / screenshots to help present your vision of the feature

Some ideas I can come up with:

A) Multiple settings files

If I could split my settings into e.g. settings.json and settings.local.json (ditto keymap), then I could add the settings.local.json to my keymap for the laptop. This wouldn't fully solve the problem, but it would be an interesting idea nonetheless.

B) Ability to include settings files

If I could somehow #include other files from settings/keymap.json, I could switch between the two profiles by just commenting out one line. This would also be a strict superset of the previous proposal.

C) Multiple settings profiles / layers

Like the former approach, but with inbuilt support for enumerating / switching between settings profiles. Most flexible approach, I think. Or we could treat profiles like toggleable "layers", which can overwrite settings from the previous "layer". (The "default" keybindings forming the base layer)

D) More keymap conditions (e.g. conditional on hostname)

This would let me make keybindings that only apply on my laptop. Though, it's not an ideal solution, as I really want to conditionalize by the input device in use, not the hostname. It also wouldn't allow for conditional global settings.

haasn commented 2 months ago

Possibly connected with

notpeter commented 2 months ago

I think #16294 would certainly help you, but the best workaround I can suggest for the moment is to maintain two distinct keybinds (laptop.json and ergonomic.json) and then have command line aliases that toggles a ~/.config/zed/keymap.json symlink. Untested, but something like:

alias zedlap="ln -sf ~/.config/zed/laptop.json ~/.config/zed/keymap.json"
alias zederg="ln -sf ~/.config/zed/ergonomic.json ~/.config/zed/keymap.json"