(Neo)Vimで気持ち良い環境を構築する
前置き的な
今までVimを適当に使ってきた私ですが、一度自分の環境を見直すことにしてみました(1月末くらいから)。
その理由として、プラグインを入れすぎてテキストエディタとしてのシンプルさを失ったVimに疑問を持ったこと、
純粋にVim本来の力を忘れいたこと...などがあります。
ということで本記事では、最低限vimで欲しいプラグインたちを紹介します
プラグイン管理
Shougoさんが開発しているdein.vimを使用しています こちらは以前から使っていますが、パッケージをtomlで管理できるところが良いです
補完系
補完系はdeoplete.nvimとLSPクライアント(LanguageClient-neovim)を使用しています。
LSPを導入することで、補完系のプラグインを減らせました。
Ruby
,Python
だとLanguageClient-neovimの設定は、こんな感じです。
[[plugins]] repo = 'autozimu/LanguageClient-neovim' rev = 'next' build = 'source install.sh' hook_source = ''' set hidden let g:LanguageClient_serverCommands = { \ 'python': ['pyls'], \ 'ruby': ['solargraph', 'stdio'] \} nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR> nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR> nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
もっさり pic.twitter.com/tyiBZ1KdXi
— 𝚃𝚛𝚜 (@TrsNium) February 5, 2019
pylsと組み合わせるとこんな感じです。
その他
ステータスバーのカスタムはvim-airlineとvim-airline-themeを使っています
設定はこんな感じ、<Cntl-n>, <Cntl-p>でbufferを切り替えれるようにしてます
[[plugins]] repo = 'vim-airline/vim-airline' hook_add=''' let g:airline_powerline_fonts=1 let g:airline#extensions#tabline#enabled = 1 nmap <C-p> <Plug>AirlineSelectPrevTab nmap <C-n> <Plug>AirlineSelectNextTab let g:airline#extensions#tabline#buffer_idx_mode = 1 if !exists('g:airline_symbols') let g:airline_symbols = {} endif ''' [[plugins]] repo = 'vim-airline/vim-airline-themes' hook_add=''' let g:airline_theme='minimalist'
行末の不要な空白を可視化するためにvim-trailing-whitespaceを入れています
インデントを可視化するためにvim-indent-lineを入れています
デフォルトだと|
でインデントが可視化されるのですが、好みではなかったので·
で置き換えています
[[plugins]] repo = 'Yggdroot/indentLine' hook_add=''' let g:indentLine_enabled = 0 let g:indentLine_char = '|' let g:indentLine_leadingSpaceEnabled = 1 let g:indentLine_leadingSpaceChar = '·' '''
windowサイズの変更を楽にするためwinresizerを使用しています
<Cntl-e>でリサイズが始まりh
,j
,k
,l
でサイズを変えることができます
もう<Cntl-w>> とかには戻れない....
最後にカラースキームですがicebergを使用しています
ここら辺は好みなので、好きなのを入れましょう
基本的に私が中心に使っているのは、上記のプラグインたちです。
他にもオススメがぜひ教えてください!
最後まで見ていただき、ありがとうございました。
Raspbianにneovimをインストールする
n年ぶりにラズピッピで作業する機会があったのですが、neovimのインストールに手間取ったので共有です
ubuntuだと下記のコマンドでインストールできます。
sudo apt-get install software-properties-common sudo add-apt-repository ppa:neovim-ppa/stable sudo apt-get update sudo apt-get install neovim
がraspbianでは上手くいきません。
上の記事のようにraspbianのレポジトリではないのでadd-apt-repository
をしようとするとエラーが発生します。
なので上の記事と同様にubuntu用のneovim PPAを登録します。
準備
公開鍵はこちらを参照してください
公開鍵の登録をします
sudo apt install dirmngr sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9DBB0BE9366964F134855E2255F96FCF8231B6DD
レポジトリの設定
sudo touch /etc/apt/sources.list.d/neovim-ppa.list
ファイルの中は下記の通り
deb http://ppa.launchpad.net/neovim-ppa/stable/ubuntu YOUR_UBUNTU_VERSION_HERE main deb-src http://ppa.launchpad.net/neovim-ppa/stable/ubuntu YOUR_UBUNTU_VERSION_HERE main
後はこのように
$sudo apt update $sudo apt-get install neovim Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libjemalloc1 libluajit-5.1-2 libmsgpackc2 libtermkey1 libunibilium0 libvterm0 neovim-runtime Suggested packages: ctags vim-scripts Recommended packages: python-neovim python3-neovim The following NEW packages will be installed: libjemalloc1 libluajit-5.1-2 libmsgpackc2 libtermkey1 libunibilium0 libvterm0 neovim neovim-runtime 0 upgraded, 8 newly installed, 0 to remove and 88 not upgraded. Need to get 4729 kB of archives. After this operation, 20.4 MB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 http://ppa.launchpad.net/neovim-ppa/stable/ubuntu xenial/main armhf neovim-runtime all 0.3.1-3ppa1~ubuntu16.04.5 [3336 kB] Get:2 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf libluajit-5.1-2 armhf 2.0.4+dfsg-1 [171 kB] Get:3 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf libjemalloc1 armhf 3.6.0-9.1 [81.1 kB] Get:4 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf libmsgpackc2 armhf 1.4.2-4 [16.1 kB] Get:5 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf libunibilium0 armhf 1.2.0-1 [18.5 kB] Get:6 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf libvterm0 armhf 0~bzr684-1 [23.3 kB] Get:7 http://ppa.launchpad.net/neovim-ppa/stable/ubuntu xenial/main armhf libtermkey1 armhf 0.20-1ppa1~ubuntu16.04.2 [15.4 kB] Get:8 http://ppa.launchpad.net/neovim-ppa/stable/ubuntu xenial/main armhf neovim armhf 0.3.1-3ppa1~ubuntu16.04.5 [1068 kB] Fetched 4729 kB in 20s (235 kB/s) apt-listchanges: Can't set locale; make sure $LC_* and $LANG are correct! perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_CTYPE = "en_US.UTF-8", LANG = "en_GB.UTF-8" are supported and installed on your system. perl: warning: Falling back to a fallback locale ("en_GB.UTF-8"). locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory Selecting previously unselected package libluajit-5.1-2:armhf. (Reading database ... 137685 files and directories currently installed.) Preparing to unpack .../0-libluajit-5.1-2_2.0.4+dfsg-1_armhf.deb ... Unpacking libluajit-5.1-2:armhf (2.0.4+dfsg-1) ... Selecting previously unselected package neovim-runtime. Preparing to unpack .../1-neovim-runtime_0.3.1-3ppa1~ubuntu16.04.5_all.deb ... Unpacking neovim-runtime (0.3.1-3ppa1~ubuntu16.04.5) ... Selecting previously unselected package libjemalloc1. Preparing to unpack .../2-libjemalloc1_3.6.0-9.1_armhf.deb ... Unpacking libjemalloc1 (3.6.0-9.1) ... Selecting previously unselected package libmsgpackc2:armhf. Preparing to unpack .../3-libmsgpackc2_1.4.2-4_armhf.deb ... Unpacking libmsgpackc2:armhf (1.4.2-4) ... Selecting previously unselected package libunibilium0:armhf. Preparing to unpack .../4-libunibilium0_1.2.0-1_armhf.deb ... Unpacking libunibilium0:armhf (1.2.0-1) ... Selecting previously unselected package libtermkey1:armhf. Preparing to unpack .../5-libtermkey1_0.20-1ppa1~ubuntu16.04.2_armhf.deb ... Unpacking libtermkey1:armhf (0.20-1ppa1~ubuntu16.04.2) ... Selecting previously unselected package libvterm0:armhf. Preparing to unpack .../6-libvterm0_0~bzr684-1_armhf.deb ... Unpacking libvterm0:armhf (0~bzr684-1) ... Selecting previously unselected package neovim. Preparing to unpack .../7-neovim_0.3.1-3ppa1~ubuntu16.04.5_armhf.deb ... Unpacking neovim (0.3.1-3ppa1~ubuntu16.04.5) ... Setting up libunibilium0:armhf (1.2.0-1) ... Processing triggers for mime-support (3.60) ... Processing triggers for desktop-file-utils (0.23-1) ... Setting up libjemalloc1 (3.6.0-9.1) ... Setting up neovim-runtime (0.3.1-3ppa1~ubuntu16.04.5) ... Setting up libtermkey1:armhf (0.20-1ppa1~ubuntu16.04.2) ... Processing triggers for libc-bin (2.24-11+deb9u3) ... Setting up libvterm0:armhf (0~bzr684-1) ... Setting up libluajit-5.1-2:armhf (2.0.4+dfsg-1) ... Processing triggers for man-db (2.7.6.1-2) ... Processing triggers for gnome-menus (3.13.3-9) ... Setting up libmsgpackc2:armhf (1.4.2-4) ... Setting up neovim (0.3.1-3ppa1~ubuntu16.04.5) ... Processing triggers for libc-bin (2.24-11+deb9u3) ...
以上で終了です 良いVimライフを〜