brglng / vim-im-select

Improve Vim/Neovim experience with input methods.
108 stars 18 forks source link

fcitx5 support #4

Closed yuexiahu closed 4 years ago

yuexiahu commented 4 years ago
diff --git a/plugin/im_select.vim b/plugin/im_select.vim
index 0b8c522..baa46bc 100644
--- a/plugin/im_select.vim
+++ b/plugin/im_select.vim
@@ -59,6 +59,17 @@ if !exists('g:im_select_get_im_cmd') || !exists('g:ImSelectSetImCmd')
             if !exists('g:im_select_default')
                 let g:im_select_default = '1'
             endif
+        elseif $GTK_IM_MODULE == 'fcitx5' || $QT_IM_MODULE == 'fcitx5'
+            let g:im_select_get_im_cmd = ['fcitx5-remote']
+            let g:ImSelectSetImCmd = {
+              \ key ->
+              \ key == 1 ? ['fcitx5-remote', '-c'] :
+              \ key == 2 ? ['fcitx5-remote', '-o'] :
+              \ execute("throw 'invalid im key'")
+              \ }
+            if !exists('g:im_select_default')
+                let g:im_select_default = '1'
+            endif
         elseif match($XDG_CURRENT_DESKTOP, '\cgnome') >= 0
             if $GTK_IM_MODULE == 'ibus'
                 let g:im_select_get_im_cmd = [
@@ -98,6 +109,17 @@ if !exists('g:im_select_get_im_cmd') || !exists('g:ImSelectSetImCmd')
                 if !exists('g:im_select_default')
                     let g:im_select_default = '1'
                 endif
+            elseif $GTK_IM_MODULE == 'fcitx5' || $QT_IM_MODULE == 'fcitx5'
+                let g:im_select_get_im_cmd = ['fcitx5-remote']
+                let g:ImSelectSetImCmd = {
+                            \ key ->
+                            \ key == 1 ? ['fcitx5-remote', '-c'] :
+                            \ key == 2 ? ['fcitx5-remote', '-o'] :
+                            \ execute("throw 'invalid im key'")
+                            \ }
+                if !exists('g:im_select_default')
+                    let g:im_select_default = '1'
+                endif
             endif
         endif
     endif
brglng commented 4 years ago

@yuexiahu Thank you. Merged in 544dde0.