-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
ZFVimIM_autoDisable.vim
146 lines (134 loc) · 4.56 KB
/
ZFVimIM_autoDisable.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
" ['enableCallback', 'disableCallback']
let s:callback = []
augroup ZFVimIM_autoDisable_augroup
autocmd!
autocmd User ZFVimIM_event_OnEnable for cb in s:callback | let Fn = function(cb[1]) | silent! call Fn() | endfor
autocmd User ZFVimIM_event_OnDisable for cb in s:callback | let Fn = function(cb[0]) | silent! call Fn() | endfor
augroup END
" ============================================================
" asyncomplete : https://github.com/prabirshrestha/asyncomplete.vim
function! s:asyncomplete_enable()
if get(g:, 'ZFVimIM_autoDisable_asyncomplete', 1) && exists('*asyncomplete#enable_for_buffer')
call asyncomplete#enable_for_buffer()
endif
endfunction
function! s:asyncomplete_disable()
if get(g:, 'ZFVimIM_autoDisable_asyncomplete', 1) && exists('*asyncomplete#enable_for_buffer')
call asyncomplete#disable_for_buffer()
endif
endfunction
call add(s:callback, ['s:asyncomplete_enable', 's:asyncomplete_disable'])
" coc : https://github.com/neoclide/coc.nvim
function! s:coc_enable()
if get(g:, 'ZFVimIM_autoDisable_coc', 1) && exists(':CocEnable')
call coc#config('suggest.autoTrigger', 'always')
CocEnable
endif
endfunction
function! s:coc_disable()
if get(g:, 'ZFVimIM_autoDisable_coc', 1) && exists(':CocEnable')
call coc#config('suggest.autoTrigger', 'none')
CocDisable
endif
endfunction
call add(s:callback, ['s:coc_enable', 's:coc_disable'])
" deoplete : https://github.com/Shougo/deoplete.nvim
function! s:deoplete_enable()
if get(g:, 'ZFVimIM_autoDisable_deoplete', 1) && exists('*deoplete#enable')
call deoplete#enable()
endif
endfunction
function! s:deoplete_disable()
if get(g:, 'ZFVimIM_autoDisable_deoplete', 1) && exists('*deoplete#enable')
call deoplete#disable()
endif
endfunction
call add(s:callback, ['s:deoplete_enable', 's:deoplete_disable'])
" ncm2 : https://github.com/ncm2/ncm2
function! s:ncm2_enable()
if get(g:, 'ZFVimIM_autoDisable_ncm2', 1) && exists('*ncm2#enable_for_buffer')
call ncm2#enable_for_buffer()
endif
endfunction
function! s:ncm2_disable()
if get(g:, 'ZFVimIM_autoDisable_ncm2', 1) && exists('*ncm2#enable_for_buffer')
call ncm2#disable_for_buffer()
endif
endfunction
call add(s:callback, ['s:ncm2_enable', 's:ncm2_disable'])
" nvim-cmp : https://github.com/hrsh7th/nvim-cmp
function! s:nvim_cmp_enable()
if get(g:, 'loaded_cmp', 0)
try
lua << EOF
local cmp = require('cmp')
local config = require('cmp.config')
if config.global.enabled_ZFVimIM ~= nil then
cmp.setup({
enabled = config.global.enabled_ZFVimIM,
})
config.global.enabled_ZFVimIM = nil
end
EOF
catch
endtry
endif
endfunction
function! s:nvim_cmp_disable()
if get(g:, 'loaded_cmp', 0)
try
lua << EOF
local cmp = require('cmp')
local config = require('cmp.config')
config.global.enabled_ZFVimIM = config.global.enabled
cmp.setup({
enabled = false,
})
EOF
catch
endtry
endif
endfunction
call add(s:callback, ['s:nvim_cmp_enable', 's:nvim_cmp_disable'])
" vim-auto-popup : https://github.com/skywind3000/vim-auto-popmenu
function! s:vimautopopup_enable()
if get(g:, 'ZFVimIM_autoDisable_vimautopopup', 1) && exists(':ApcEnable') != 0
ApcEnable
endif
endfunction
function! s:vimautopopup_disable()
if get(g:, 'ZFVimIM_autoDisable_vimautopopup', 1) && exists(':ApcDisable') != 0
ApcDisable
endif
endfunction
call add(s:callback, ['s:vimautopopup_enable', 's:vimautopopup_disable'])
" vim-lsp : https://github.com/prabirshrestha/vim-lsp
function! s:vimlsp_enable()
if get(g:, 'ZFVimIM_autoDisable_vimlsp', 1) && get(g:, 'lsp_loaded', 0)
try
call lsp#enable()
catch
endtry
endif
endfunction
function! s:vimlsp_disable()
if get(g:, 'ZFVimIM_autoDisable_vimlsp', 1) && get(g:, 'lsp_loaded', 0)
try
call lsp#disable()
catch
endtry
endif
endfunction
call add(s:callback, ['s:vimlsp_enable', 's:vimlsp_disable'])
" ycm : https://github.com/ycm-core/YouCompleteMe
function! s:ycm_enable()
if get(g:, 'ZFVimIM_autoDisable_ycm', 1) && exists(':YcmCompleter')
let g:ycm_auto_trigger = 1
endif
endfunction
function! s:ycm_disable()
if get(g:, 'ZFVimIM_autoDisable_ycm', 1) && exists(':YcmCompleter')
let g:ycm_auto_trigger = 0
endif
endfunction
call add(s:callback, ['s:ycm_enable', 's:ycm_disable'])