2023-01-28 15:11:37 +08:00
|
|
|
local G, im = require("G"), "keyboard-us"
|
|
|
|
|
|
|
|
function InsertLeave()
|
|
|
|
local t = io.popen("fcitx5-remote -n")
|
|
|
|
im = t:read()
|
2023-01-28 18:15:05 +08:00
|
|
|
G.cmd(":silent !fcitx5-remote -c,cr")
|
2023-01-28 15:11:37 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function InsertEnter()
|
|
|
|
if im == 'pinyin'
|
|
|
|
then
|
|
|
|
print(im)
|
2023-01-28 18:15:05 +08:00
|
|
|
G.cmd("!fcitx5-remote -s pinyin<cr>")
|
2023-01-28 15:11:37 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
G.api.nvim_create_autocmd(
|
|
|
|
{"InsertLeave"}, {
|
|
|
|
pattern = "*",
|
|
|
|
callback = InsertLeave
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
G.api.nvim_create_autocmd(
|
|
|
|
{"InsertEnter"}, {
|
|
|
|
pattern = "*",
|
|
|
|
callback = InsertEnter
|
|
|
|
}
|
|
|
|
)
|