2023-02-24 22:16:06 +08:00
|
|
|
if package.config:sub(1,1) == "\\" then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
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:50:00 +08:00
|
|
|
G.cmd(":silent !fcitx5-remote -c")
|
2023-01-28 15:11:37 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function InsertEnter()
|
|
|
|
if im == 'pinyin'
|
|
|
|
then
|
2023-01-28 18:50:00 +08:00
|
|
|
G.cmd(":silent !fcitx5-remote -s pinyin")
|
2023-01-28 15:11:37 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-02-24 22:16:06 +08:00
|
|
|
function Is_fcitx5_installed()
|
|
|
|
local cmd = "fcitx5 -v"
|
|
|
|
local status = os.execute(cmd)
|
|
|
|
return (status == 0)
|
|
|
|
end
|
|
|
|
|
|
|
|
if Is_fcitx5_installed() then
|
2023-01-28 15:11:37 +08:00
|
|
|
G.api.nvim_create_autocmd(
|
|
|
|
{"InsertLeave"}, {
|
|
|
|
pattern = "*",
|
|
|
|
callback = InsertLeave
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
G.api.nvim_create_autocmd(
|
|
|
|
{"InsertEnter"}, {
|
|
|
|
pattern = "*",
|
|
|
|
callback = InsertEnter
|
|
|
|
}
|
|
|
|
)
|
2023-02-24 22:16:06 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|