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