mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
fix: make xkbswitch work on mac M1 CPU
For the details, see https://jdhao.github.io/2021/02/25/nvim_ime_mode_auto_switch/.
This commit is contained in:
parent
baa8f26bc2
commit
075326ee2e
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user