もともと deoplete.nvimを使っていたけれど、私の環境(Windows10 Vim8)だと補完候補が表示されるまで一秒程度時間がかかるため asyncomplete.vimに移りました。
そこそこ快適に使えるようになるまで試行錯誤が必要だったので、そこらへんをコメントしてみます。
全体のコードは末尾へ。
前提
- denite を使って toml で設定を書いています。
asyncomplete.vim 関連の依存関係
- asyncomplete.vim
- asyncomplete-buffer.vim
- asyncomplete-file.vim
- asyncomplete-necosyntax.vim
- Shougo/neco-syntax
- asyncomplete-necovim.vim
- Shougo/neco-vim
- prabirshrestha/asyncomplete-gocode.vim
- prabirshrestha/asyncomplete-neosnippet.vim
- Shougo/neosnippet.vim
- Shougo/neosnippet-snippets
- honza/vim-snippets
- Shougo/neosnippet.vim
vimrc で augroup vimrc を定義している。
augroup vimrc
autocmd!
augroup END
コメント
- 数メガのテキストファイルを扱うことがあり、そのファイルに対して補完候補の収集がされないように、指定した filetype だけで補完が動くようにしています。
letg:asyncomplete_enable_for_all=0
autocmd vimrc FileType autohotkey,autoit,cfg,git,go,groovy,java,javascript,python,snippet,toml,vim,vb,xsl call asyncomplete#enable_for_buffer()
'whitelist': ['*']
:whitelist
は書いていなければ['*']
相当になると思ったけれど、そうならないこともあるようなのでそれぞれ書いています。
全体コード
[[plugins]]
repo = 'prabirshrestha/asyncomplete.vim'
on_ft = ['autohotkey', 'autoit', 'cfg', 'git', 'go', 'groovy', 'java', 'javascript', 'python', 'snippet', 'toml', 'vim', 'vb', 'xsl']
hook_add = '''
" let g:asyncomplete_log_file = expand('~/_vim/.asyncomplete/log.log')
let g:asyncomplete_enable_for_all = 0
autocmd vimrc FileType autohotkey,autoit,cfg,git,go,groovy,java,javascript,python,snippet,toml,vim,vb,xsl call asyncomplete#enable_for_buffer()
'''
[[plugins]]
repo = 'prabirshrestha/asyncomplete-buffer.vim'
on_ft = ['autohotkey', 'autoit', 'cfg', 'git', 'go', 'groovy', 'java', 'javascript', 'python', 'snippet', 'toml', 'vim', 'vb', 'xsl']
hook_source = '''
autocmd vimrc User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#buffer#get_source_options({
\ 'name': 'buffer',
\ 'priority': 5,
\ 'whitelist': ['*'],
\ 'completor': function('asyncomplete#sources#buffer#completor'),
\ }))
'''
[[plugins]]
repo = 'prabirshrestha/asyncomplete-file.vim'
on_ft = ['autohotkey', 'autoit', 'cfg', 'git', 'go', 'groovy', 'java', 'javascript', 'python', 'snippet', 'toml', 'vim', 'vb', 'xsl']
hook_source = '''
autocmd vimrc User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#file#get_source_options({
\ 'name': 'file',
\ 'priority': 3,
\ 'whitelist': ['*'],
\ 'completor': function('asyncomplete#sources#file#completor'),
\ }))
'''
[[plugins]]
repo = 'prabirshrestha/asyncomplete-necosyntax.vim'
on_ft = ['autohotkey', 'autoit', 'cfg', 'git', 'go', 'groovy', 'java', 'javascript', 'python', 'snippet', 'toml', 'vim', 'vb', 'xsl']
depends = ['neco-syntax']
hook_source = '''
autocmd vimrc User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#necosyntax#get_source_options({
\ 'name': 'necosyntax',
\ 'priority': 7,
\ 'whitelist': ['*'],
\ 'completor': function('asyncomplete#sources#necosyntax#completor'),
\ }))
'''
[[plugins]]
repo = 'Shougo/neco-syntax'
lazy = 1
[[plugins]]
repo = 'prabirshrestha/asyncomplete-necovim.vim'
on_ft = ['vim']
depends = ['neco-vim']
hook_source = '''
autocmd vimrc User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#necovim#get_source_options({
\ 'name': 'necovim',
\ 'whitelist': ['vim'],
\ 'priority': 10,
\ 'completor': function('asyncomplete#sources#necovim#completor'),
\ }))
'''
[[plugins]]
repo = 'Shougo/neco-vim'
lazy = 1
[[plugins]]
repo = 'prabirshrestha/asyncomplete-gocode.vim'
on_ft = 'go'
hook_source = '''
call asyncomplete#register_source(asyncomplete#sources#gocode#get_source_options({
\ 'name': 'gocode',
\ 'whitelist': ['go'],
\ 'priority': 10,
\ 'completor': function('asyncomplete#sources#gocode#completor'),
\ 'config': {
\ 'gocode_path': expand('~/bin/gocode')
\ },
\ }))
[[plugins]]
repo = 'prabirshrestha/asyncomplete-neosnippet.vim'
on_ft = ['autohotkey', 'autoit', 'cfg', 'git', 'go', 'groovy', 'java', 'javascript', 'python', 'snippet', 'toml', 'vim', 'vb', 'xsl']
depends = ['neosnippet.vim']
hook_source = '''
autocmd vimrc User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#neosnippet#get_source_options({
\ 'name': 'neosnippet',
\ 'whitelist': ['*'],
\ 'priority': 9,
\ 'completor': function('asyncomplete#sources#neosnippet#completor'),
\ }))
'''
[[plugins]]
repo = 'Shougo/neosnippet.vim'
depends = 'neosnippet-snippets'
hook_source = '''
" <TAB>: completion.
inoremap <expr> <S-TAB> pumvisible() ? '<C-p>' : '<S-TAB>'
" Plugin key-mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
" SuperTab like snippets behavior.
imap <expr> <TAB> neosnippet#jumpable() ? '<Plug>(neosnippet_expand_or_jump)' : pumvisible() ? '<C-n>' : '<TAB>'
smap <expr> <TAB> neosnippet#jumpable() ? '<Plug>(neosnippet_expand_or_jump)' : '<TAB>'
let g:neosnippet#data_directory = expand('~/_vim/.neosnippet')
" Tell Neosnippet about the other snippets
" gosnippets は vim-go がうまいことやってくれるはずだけど、なんかうまくいかないので直接追加。
let g:neosnippet#snippets_directory = [
\ '~/vimfiles/snippets',
\ '~/_vim/dein/repos/github.com/honza/vim-snippets/snippets/',
\ '~/_vim/dein/repos/github.com/fatih/vim-go/gosnippets/snippets/',
\ ]
'''
[[plugins]]
repo = 'Shougo/neosnippet-snippets'
[[plugins]]
repo = 'honza/vim-snippets'
# snippets ファイルだけを使うので runtimepath へ追加しない
rtp = ''
'''