From 7a7f77fb1334f4a2d653d2e3bdbea01f5fce7b76 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 15 Jan 2023 16:59:42 +0100 Subject: toggle fcitx5 off in normal mode in vim --- .config/nvim/init.vim | 12 ++++++------ .local/share/bin/fcitx5-temp-off | 8 ++++++++ .local/share/bin/fcitx5-temp-restore | 7 +++++++ 3 files changed, 21 insertions(+), 6 deletions(-) create mode 100755 .local/share/bin/fcitx5-temp-off create mode 100755 .local/share/bin/fcitx5-temp-restore diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 569e220..4f46e2d 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -350,12 +350,7 @@ else set signcolumn=yes endif -if has('patch8.1.1068') - " Use `complete_info` if your (Neo)Vim version supports it. - inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" -else - imap pumvisible() ? "\" : "\u\" -endif +inoremap coc#pum#visible() ? coc#pum#confirm() : "\u\\=coc#on_enter()\" " coc code navigation map cd (coc-definition) @@ -421,3 +416,8 @@ augroup END " sneak let g:sneak#use_ic_scs = 0 + +" fcitx5 +autocmd InsertEnter * call system("fcitx5-temp-restore &") +autocmd InsertLeave * call system("fcitx5-temp-off &") + diff --git a/.local/share/bin/fcitx5-temp-off b/.local/share/bin/fcitx5-temp-off new file mode 100755 index 0000000..b2f8ea9 --- /dev/null +++ b/.local/share/bin/fcitx5-temp-off @@ -0,0 +1,8 @@ +#!/bin/sh +mkdir -p "$XDG_DATA_HOME/fcitx5" +fcitx5-remote > "$XDG_DATA_HOME/fcitx5/state" +fcitx5-remote -n > "$XDG_DATA_HOME/fcitx5/ime_name" + +fcitx5-remote -c +fcitx5-remote -s 'keyboard-us' + diff --git a/.local/share/bin/fcitx5-temp-restore b/.local/share/bin/fcitx5-temp-restore new file mode 100755 index 0000000..d00b11c --- /dev/null +++ b/.local/share/bin/fcitx5-temp-restore @@ -0,0 +1,7 @@ +#!/bin/sh +[ ! -e "$XDG_DATA_HOME/fcitx5/state" ] && exit +[ ! -e "$XDG_DATA_HOME/fcitx5/ime_name" ] && exit + +[ `cat "$XDG_DATA_HOME/fcitx5/state"` = "1" ] && fcitx5-remote -c +[ `cat "$XDG_DATA_HOME/fcitx5/state"` = "2" ] && fcitx5-remote -o +cat "$XDG_DATA_HOME/fcitx5/ime_name" | xargs fcitx5-remote -s -- cgit v1.2.3