Coder Social home page Coder Social logo

vim-im-select's Introduction

vim-im-select

Improve Vim/Neovim experience with input methods.

Basically, this plugin does these things:

  • Switch to the default IM of your choice on InsertLeave
  • Switch back to your previous IM on InsertEnter
  • Switch to the default IM of your choice on FocusGained if you are in normal mode, or do nothing if not
  • Switch back to your previous IM on FocusLost if you are in normal mode, or do nothing if not
  • If you are using a GUI (e.g., GVim), switch back to your previous IM before exiting Vim if you are in normal mode, or do nothing if you are in insert mode. If you are under a terminal, switch to the default IM of your choice before exiting Vim.

Requirements

Neovim or Vim with +job is required.

This plugin works out of the box on Linux with iBus or Fcitx.

On macOS or Windows, im-select must be installed.

Tmux

tmux-plugins/vim-tmux-focus-events is recommended if you are using Tmux. This plugin provides FocusGained and FocusLost events for (Neo)Vim under Tmux. (NOTE: It is reported that this plugin does not work well with Vim/Vim cannot recognize the terminal code from this plugin, however it works well with Neovim.)

Commands

ImSelectEnable

Enable this plugin if not enabled.

ImSelectDisable

Disable this plugin.

Options

g:im_select_get_im_cmd

This variable can be set to a list or a string of the command for getting the current IM key.

e.g.

let g:im_select_get_im_cmd = ['im-select']

g:ImSelectSetImCmd

This variable must be a Funcref who takes the key as argument and returns the whole command line.

e.g.

let g:ImSelectSetImCmd = {key -> ['im-select', key]}

g:ImSelectGetImCallback

This variable must be a Funcref, which is called after the get_im command is exited, returning the current IM key.

e.g.

function! GetImCallback(exit_code, stdout, stderr) abort
    return a:stdout
endfunction
let g:ImSelectGetImCallback = function('GetImCallback')

g:im_select_default

This variable can be set to your own default IM key.

e.g.

let g:im_select_default = 'com.apple.keylayout.ABC'   " The default value on macOS
let g:im_select_default = '1033'                      " The default value on Windows

You can get your current IM key by im-select.

$ im-select
com.apple.keylayout.ABC

You are likely to get com.apple.keylayout.Dvorak if you use Dvorak keyboard layout on macOS.

g:im_select_command

This variable can be set to the im-select program path of your own (only useful on macOS and Windows).

g:im_select_switch_timeout

The timeout during which events are not responded, in milliseconds.

Some IM switching commands steals focus, e.g., the gdbus program on GNOME desktop. This will trigger FocusLost and FocusGained events, which causes problems. This option setups the timeout after the IM is switched. During the timeout, events are not responded. The default value is 50.

g:im_select_enable_focus_events

Whether or not to enable FocusLost and FocusGained events. If your desktop already switches input methods among different windows/applications (e.g., this is the default setting on KDE), you may want to set this option to 0. The default value is 1.

g:im_select_enable_for_gvim

The plugin is disabled on GVim for Windows or MacVim, as GVim for Windows and MacVim already supports IM auto-switching. Set this variable to 1 if you want to enable anyway.

vim-im-select's People

Contributors

brglng avatar fuujihi avatar ytyubox avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.