Vim
neovim

Neovimと闇の力を手に入れる

More than 1 year has passed since last update.


経緯

今使っているvimプラグインの開発が止まったのでさすがに引っ越したい(そして闇:zap:の力を手に入れたい)

https://github.com/Shougo/neocomplete.vim

https://github.com/Shougo/neobundle.vim


やりたいこと


  • あまり時間をかけずに最低限使える状態でNeovimに移行

  • 雑な状態でもRailsの開発はできるようにしたい

  • 最低限、denite(ファイラ)、deoplete(補完)は使いたい


環境

$ sw_vers

ProductName: Mac OS X
ProductVersion: 10.12.6
BuildVersion: 16G29


設定方法

.zshrc に ↓を追加

$ export XDG_CONFIG_HOME="$HOME/.config"


Neovimをinstall

$ brew install neovim


python3をinstall

$ brew install python3

$ pip3 install --upgrade neovim


dein.nvimをinstall

$ curl https://raw.githubusercontent.com/Shougo/dein.vim/master/bin/installer.sh > installer.sh

$ sh ./installer.sh {任意のディレクトリ}


設定を追加

~/.config/nvim/init.vim は Neovim版の .vimrc


~/.config/nvim/init.vim

" reset augroup

augroup MyAutoCmd
autocmd!
augroup END

let $CACHE = empty($XDG_CACHE_HOME) ? expand('$HOME/.cache') : $XDG_CACHE_HOME
let $CONFIG = empty($XDG_CONFIG_HOME) ? expand('$HOME/.config') : $XDG_CONFIG_HOME
let $DATA = empty($XDG_DATA_HOME) ? expand('$HOME/.local/share') : $XDG_DATA_HOME

" {{{ dein
let s:dein_dir = expand('$DATA/dein')

if &runtimepath !~# '/dein.vim'
let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim'

" Auto Download
if !isdirectory(s:dein_repo_dir)
call system('git clone https://github.com/Shougo/dein.vim ' . shellescape(s:dein_repo_dir))
endif

execute 'set runtimepath^=' . s:dein_repo_dir
endif

" dein.vim settings

if dein#load_state(s:dein_dir)
call dein#begin(s:dein_dir)

let s:toml_dir = expand('$CONFIG/dein')

call dein#load_toml(s:toml_dir . '/plugins.toml', {'lazy': 0})
call dein#load_toml(s:toml_dir . '/lazy.toml', {'lazy': 1})

call dein#end()
call dein#save_state()
endif

if has('vim_starting') && dein#check_install()
call dein#install()
endif
" }}}
nmap <silent> <C-e> :NERDTreeToggle<CR>

" denite
let g:denite_enable_start_insert=1
let g:denite_source_history_yank_enable =1
let g:denite_source_file_mru_limit = 200
nnoremap <C-t> :<C-u>Denite buffer<CR>
nnoremap <silent> ,ur :<C-u>Denite file_rec<CR>
nnoremap <silent> ,um :<C-u>Denite file_mru <CR>
nnoremap <silent> ,urc :<C-u>Denite file_rec:app/controllers/<CR><Space>
nnoremap <silent> ,urm :<C-u>Denite file_rec:app/models/ <CR><Space>
nnoremap <silent> ,urv :<C-u>Denite file_rec:app/views/ <CR><Space>
nnoremap <silent> ,urs :<C-u>Denite file_rec:app/assets/stylesheets/ <CR>
nnoremap <silent> ,urj :<C-u>Denite file_rec:app/assets/javascripts/ <CR>



~/.config/dein/plugins.toml

[[plugins]]

repo = 'Shougo/dein.vim'

[[plugins]]
repo = 'w0ng/vim-hybrid'

[[plugins]]
repo = 'itchyny/lightline.vim'
hook_add = '''
let g:lightline = {'colorscheme': 'wombat'}
'''
[[plugins]]
repo = 'cespare/vim-toml'

[[plugins]]
repo = 'fatih/vim-go'

[[plugins]]
repo = 'scrooloose/nerdtree'

[[plugins]]
repo = 'Shougo/neosnippet-snippets'



dotfiles/.config/dein/lazy.toml

[[plugins]]

repo = 'Shougo/denite.nvim'
on_cmd = 'Denite'
on_i = 1
hook_source = '''
call denite#custom#map('insert', '<c-n>', '<denite:move_to_next_line>', 'noremap')
call denite#custom#map('insert', '<c-p>', '<denite:move_to_previous_line>', 'noremap')
'''

[[plugins]] # Plugin to easily access Most Recently Used (MRU) files
repo = 'Shougo/neomru.vim'
on_source = 'denite.nvim'
on_path = '.*'

[[plugins]] # Yank
repo = 'Shougo/neoyank.vim'
on_source = 'denite.nvim'
on_event = 'TextYankPost'

[[plugins]]
repo = 'Shougo/deoplete.nvim'
hook_source = '''
let g:deoplete#enable_at_startup = 1
inoremap <expr><tab> pumvisible() ? "\<C-n>" :
\ neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<tab>"
'''
on_i = 1

[[plugins]]
repo = 'Shougo/neosnippet'
hook_source = '''
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
if has('conceal')
set conceallevel=2 concealcursor=niv
endif
'''
on_i = 1
on_ft = ['snippet']
depends = ['neosnippet-snippets']



参考URL

https://github.com/Shougo/dein.vim

https://qiita.com/takezo/items/809d53ecd37c438bac9e


おわりに

とりあえず動く状態まで持って行きたかったので書き方とかおかしい場合はこっそり教えてもらえると助かります

年末あたりに開発環境をもっと改善したい