ubuntuでneovimを使う

ubuntu18.04におけるneovimのインストールと初期設定について

インストール

パッケージをインストールする

sudo add-apt-repository ppa:neovim-ppa/unstable
sudo apt update
sudo apt install neovim

pythonのモジュールをインストール

pip3 install neovim

nvimで起動し,echo has('python3')で1が出力されれば成功.

設定

設定ファイルを以下のように分割している

lsd -T
.
├── dein.toml
├── deinlazy.toml
├── init.vim
├── keymap.rc.vim
├── options.rc.vim
├── plugins
│ ├── airline.vim
│ ├── ale.vim
│ ├── anzu.vim
│ ├── autoclose.vim
│ ├── denite.vim
│ ├── deoplete-latex.vim
│ ├── deoplete.vim
│ ├── fzf.vim
│ ├── gitgutter.vim
│ ├── markdown.vim
│ └── sonictemplate.vim
└── template
 ├── latex
 │ ├── base-lab.tex
 │ └── base-repo.tex
 ├── markdown
 │ └── base-rist_activity.md.
 └── python
 └── base-exploit.py

init.vimがneovimの起動時に最初に読み込まれる.

augroup MyAutoCmd
    autocmd!
augroup END

let $NVIM_TUI_ENABLE_TRUE_COLOR=1
set termguicolors

let s:dein_cache_path = expand('~/.cache/nvim/dein')
let s:dein_dir = s:dein_cache_path
           \ .'/repos/github.com/Shougo/dein.vim'

if &runtimepath !~ '/dein.vim'
    if !isdirectory(s:dein_dir)
        execute '!git clone https://github.com/Shougo/dein.vim' s:dein_dir
    endif
    execute 'set runtimepath+=' . fnamemodify(s:dein_dir, ':p')
endif

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

    call dein#load_toml('~/.config/nvim/dein.toml', {'lazy' : 0})
    call dein#load_toml('~/.config/nvim/deinlazy.toml', {'lazy' : 1})
    call dein#load_toml('~/.config/nvim/dein.toml')

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

if dein#check_install()
    call dein#install()
endif

filetype plugin indent on
colorscheme lucius

runtime! ./options.rc.vim
runtime! ./keymap.rc.vim
runtime! ./functions.rc.vim

let g:dein#auto_recache = 1

" Restore cursor shape to beam on exit
augroup restore_cursor_shape
    autocmd!
    au VimLeave * set guicursor=a:ver10-blinkoff0
augroup END

highlight Normal ctermbg=NONE guibg=NONE
highlight NonText ctermbg=NONE guibg=NONE
highlight SpecialKey ctermbg=NONE guibg=NONE
highlight EndOfBuffer ctermbg=NONE guibg=NONE

プラグインは,dein.tomlに記述し,遅延ロードするプラグインは,deinlazy.tomlに記述する. また,プラグインごとの設定は,pluginsディレクトリ内で記述する.

[[plugins]]
repo = 'Shougo/denite.nvim'
hook_add = 'source ~/.config/nvim/plugins/denite.vim'

[[plugins]]
repo = 'Shougo/deoplete.nvim'
hook_add = 'source ~/.config/nvim/plugins/deoplete.vim'

[[plugins]]
repo = 'junegunn/fzf.vim'
hook_add = 'source ~/.config/nvim/plugins/fzf.vim'

[[plugins]]
repo = 'ujihisa/neco-look'

[[plugins]]
repo = 'Townk/vim-autoclose'
hook_add = 'source ~/.config/nvim/plugins/autoclose.vim'

[[plugins]]
repo = 'iamcco/markdown-preview.vim'

[[plugins]]
repo = 'lervag/vimtex'

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

[[plugins]]
repo = 'vim-airline/vim-airline'
hook_add = 'source ~/.config/nvim/plugins/airline.vim'

[[plugins]]
repo = 'vim-airline/vim-airline-themes'

[[plugins]]
repo = 'w0rp/ale'
hook_add = 'source ~/.config/nvim/plugins/ale.vim'

[[plugins]]
repo = 'airblade/vim-gitgutter'
hook_add = 'source ~/.config/nvim/plugins/gitgutter.vim'

[[plugins]]
repo = 'osyo-manga/vim-anzu'
hook_add = 'source ~/.config/nvim/plugins/anzu.vim'

[[plugins]]
repo = 'vim-scripts/Align'

[[plugins]]
repo = 'jonathanfilip/vim-lucius'

[[plugins]]
repo = 'smancill/conky-syntax.vim'

[[plugins]]
repo = 'mattn/sonictemplate-vim'
hook_add = 'source ~/.config/nvim/plugins/sonictemplate.vim'

[[plugins]]
repo = 'cespare/vim-toml'

optionやkeymapの設定はまた今度書く