Vim icon indicating copy to clipboard operation
Vim copied to clipboard

[Bug/Feature][plugin][im-select] Allow define layout for each mode on settings

Open SkyaTura opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe.

Currently, the im-plugin only allows to define one layout, and the other is auto infered, but this confuses layouts very often.

Describe the solution you'd like

The proposal is very straight forward, the extension should allow one to set specific layout settings for each available mode (or fallback to default behavior if none).

Also, I don't know if it's possible on VSCode, but it would be nice to have:

  • being able to trigger autoSwitch on any input-like field, like search/command/filename.
  • autoSwitch on window focus or blur

Describe alternatives you've considered I found none at the current moment.

Additional context

  • Currently using latest version on MacOS Monterey
  • There are many other issues somewhat related to the lack of this setting, like:
    • #4982
    • #4536
    • #4535
    • #3930

SkyaTura avatar Sep 17 '22 18:09 SkyaTura

In fact, as I want to get some experience with VSCode Extensions, I intend to contribute on this topic by implementing some changes myself.

My thoughts on this are:

  • implement a better IM resolver
  • make sure it won't have negative impact on perfomance (maybe even make it lighter)
  • add new configuration keys:
export interface IAutoSwitchInputMethod {
  enable: boolean;
  /**
   * Layout that will be applied to non insert-like modes not specified by `modeIM` options
   */
  defaultIM: string;
  /**
   * Layout that will be applied to insert-like modes not specified by `modeIM` option.
   * If omitted, the plugin will try to infer the layout from the last state different from de `defaultIM` before switching modes
   */
  insertIM: string;
  /**
   * A map of layouts that will be applied for each mode
   */
  modeIM: Partial<Record<ModeString, string>>;
  /**
   * The command to obtain the current mode to try automatic layout inference
   * If omitted, either an `insertIM` or fully specified `modeIM` should be defined
   *
   * Note: automatic IM inference may switch to an incorrect mode
   */
  obtainIMCmd: string;
  /**
   * The command to switch between layouts.
   * `{im}` can be used to pass the expected layout as parameter
   * `{vm}` can be used to pass the current vim mode as parameter
   *
   * Note:
   * - if `{vm}` is used, then the command will be executed whenever the mode changes. This behavior may cause slowness on
   * low spec environments.
   * - if `{vm}` is omitted, the command will only be executed when the `{im}` is changed.
   * - both `{vm}` and `{im}` are optional, but at least one of them must be used
   */
  switchIMCmd: string;
  /**
   * PS.: I'm not yet entirely sure if this one will be needed.
   *
   * If greater than zero, it will wait for the specified timeout before running the `switchIMCmd`.
   *
   * This may be useful for reducing performance overhead, but high values may cause bad usage experience.
   */
  switchIMCmdDebounce: number;
}

SkyaTura avatar Sep 17 '22 22:09 SkyaTura