zed icon indicating copy to clipboard operation
zed copied to clipboard

please support imap

Open diucicd opened this issue 1 year ago • 1 comments

Check for existing issues

  • [X] Completed

Describe the feature

there are lot of sementic unit in programming language, e.g. -> / <- / := / => .... I don't type two chars , just a shortcut for inputing those unit, vim and emacs can do this with ease.

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

No response

diucicd avatar May 13 '24 22:05 diucicd

@diucicd You should be able to configure these with workspace::SendKeystrokes:

If you're using vim mode:

  {
    "context": "Editor && vim_mode == insert",
    "bindings": {
      ":": ["workspace::SendKeystrokes", ":="]
    }
  },

Is this kind of what you want?

ConradIrwin avatar May 15 '24 19:05 ConradIrwin

  {
    "context": "Editor && vim_mode == insert",
    "bindings": {
      ":": ["workspace::SendKeystrokes", ":="]
    }
  }

this works, can not work with ->

  {
    "context": "Editor && vim_mode == insert",
    "bindings": {
      ":": ["workspace::SendKeystrokes", "->"]
    }
  }

diucicd avatar May 16 '24 02:05 diucicd

Ugh! This is what I get for trying to be clever. You can make it work by adding a space between the two:

  {
    "context": "Editor && vim_mode == insert",
    "bindings": {
      ":": ["workspace::SendKeystrokes", "- >"]
    }
  }

For the := case you cannot have a space because if you do then the : hits the SendKeystrokes call again and you get no output. For the -> case, we parse that as "IME syntax" (https://github.com/zed-industries/zed/blob/cd73a434ec517f648b321dca113fc84df9201c7c/crates/gpui/src/platform/keystroke.rs#L61) so it maps to nothing. Adding the space causes it to be treated as two separate key presses.

I'll continue thinking about how to make this less terrible (maybe a good place to start would be making it so that this acts more like inoremap by default so that : = works and - > works).

ConradIrwin avatar May 16 '24 02:05 ConradIrwin

@ConradIrwin thank you very much, now I have =>/:=/<-/-> in my config just like neovim

diucicd avatar May 21 '24 06:05 diucicd