71 / dance

Make your cursors dance with Kakoune-like modal editing in VS Code.
https://marketplace.visualstudio.com/items?itemName=gregoire.dance
ISC License
429 stars 55 forks source link

Feature request: get keymaping from xresources #225

Open sucrecacao opened 2 years ago

sucrecacao commented 2 years ago

Problem

Solution

Get the mapping from Xressource, so it need to be defined once in Xressource files and will apply to both kakoune and dance.

Design

seting up Xressource

Install Xressources then write in ~/.xres

*.move_cursor_left    h

finally in a terminal xrdb ~/.xres

In dance

I'll just sketch it rapidly as pseudo code:

Instead of using

{ 
 "key" : "h",
  ....
}

Use:

const normal_cursor_left = getXRessource("move_cursor_left");
{ 
 "key" : normal_cursor_left ,
  ....
}

getXRessource should be easy to implement:

function getXRessource(ressource_name: string) -> string {
  return open("xrdb -query -all | grep {ressource_name} | cut -f2")
}

( I don't know what is the equivalent of popen in vscode API)

Other use case

71 commented 2 years ago

I have plans to improve the way key bindings are defined. However, key bindings in VS Code cannot simply be added by an extension (dynamically); the user has to modify keybindings.json themselves.

Your best bet is to make (or find) an extension that modifies the key bindings according to some logic (I think this is too niche / complex to be a Dance feature). You could take a look at https://github.com/71/autoscripts for a way to have dynamic configuration and key bindings.

sucrecacao commented 2 years ago

As I understand keybindings.json represent all vscode keybinding.

Couldn't find on internet if there is a way to import multiple keybinding file in vscode.

If so, then keybindings.json can stay the same and another file dance_keybindings.json could be externally updated with: create_dance_kb_from_xressource.sh > path/to/dance_keybindings.json