diff options
| author | jdhao <jdhao@hotmail.com> | 2022-11-07 00:41:59 +0800 |
|---|---|---|
| committer | jdhao <jdhao@hotmail.com> | 2022-11-07 00:47:04 +0800 |
| commit | 075326ee2e457b70aa9e2b50da7a87767d340e41 (patch) | |
| tree | fc2df1941c5cc286c31f6486f313c042d49bf2b3 /lua/config | |
| parent | baa8f26bc20f5191dcca56b02c2599dccec8d006 (diff) | |
fix: make xkbswitch work on mac M1 CPU
For the details, see https://jdhao.github.io/2021/02/25/nvim_ime_mode_auto_switch/.
Diffstat (limited to 'lua/config')
| -rw-r--r-- | lua/config/statusline.lua | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lua/config/statusline.lua b/lua/config/statusline.lua index 846d561..1655e15 100644 --- a/lua/config/statusline.lua +++ b/lua/config/statusline.lua @@ -8,11 +8,17 @@ local function spell() return "" end +--- show indicator for Chinese IME local function ime_state() if vim.g.is_mac then -- ref: https://github.com/vim-airline/vim-airline/blob/master/autoload/airline/extensions/xkblayout.vim#L11 local layout = fn.libcall(vim.g.XkbSwitchLib, "Xkb_Switch_getXkbLayout", "") - if layout == "0" then + + -- We can use `xkbswitch -g` on the command line to get current mode. + -- mode for macOS builtin pinyin IME: com.apple.inputmethod.SCIM.ITABC + -- mode for Rime: im.rime.inputmethod.Squirrel.Rime + local res = fn.match(layout, [[\v(Squirrel\.Rime|SCIM.ITABC)]]) + if res ~= -1 then return "[CN]" end end |
