2023/1/27 追記: 現在はこのインストール方法は使用できなくなっています。
成長しない人について書かれている以下の記事で、syntasticというvim使用時に文法チェックしてくれる方法が紹介されていました。試しにインストールして使ってみたところ、良さげなので設定方法をメモしておきます。
qiita.com
dein.vimをインストール
まず、vimのプラグインマネージャのdein.vimをインストールします。プラグインマネージャは幾つかあるのですが、dein.vimが一番メジャーな気がします。
$ mkdir -p ~/.cache/dein $ curl https://raw.githubusercontent.com/Shougo/dein.vim/master/bin/installer.sh > installer.sh $ sh installer.sh ~/.cache/dein ... Please add the following settings for dein to the top of your vimrc (Vim) or init.vim (NeoVim) file:
installer.shを実行時に上の「Please add」の行の後に設定情報が表示されるのでそのまま~/.vimrc の先頭に追加します。
最後にある以下の部分をコメントアウト(ダブルクオーテーションを削除する)しておくと、vim起動時にインストールされていないモジュールは自動でインストールされるようになります。
" if dein#check_install() " call dein#install() " endif
syntastic(+α)をインストール
~/.vimrcの、「Add or remove your plugins here like this:」の部分に以下を追加して、syntasticがインストールされるようにします。
ついでにneocomplete/neosnippetやhybridのカラーマップも追加します。
" Add or remove your plugins here like this: call dein#add('Shougo/neocomplete.vim') call dein#add('Shougo/neosnippet.vim') call dein#add('Shougo/neosnippet-snippets') call dein#add('scrooloose/syntastic') call dein#add('w0ng/vim-hybrid') call dein#source('vim-hybrid')
設定を追加
~/.vimrcにsyntasticとneosnippetの設定を追加します。両方とも公式サイトのデフォルトの設定をそのまま使っています。
" syntastic settings set statusline+=%#warningmsg# set statusline+=%{SyntasticStatuslineFlag()} set statusline+=%* let g:syntastic_always_populate_loc_list = 1 let g:syntastic_auto_loc_list = 1 let g:syntastic_check_on_open = 1 let g:syntastic_check_on_wq = 0 " snippet settings imap <C-k> <Plug>(neosnippet_expand_or_jump) smap <C-k> <Plug>(neosnippet_expand_or_jump) xmap <C-k> <Plug>(neosnippet_expand_target) imap <expr><TAB> neosnippet#expandable_or_jumpable() ? \ "\<Plug>(neosnippet_expand_or_jump)" \: pumvisible() ? "\<C-n>" : "\<TAB>" smap <expr><TAB> neosnippet#expandable_or_jumpable() ? \ "\<Plug>(neosnippet_expand_or_jump)" \: "\<TAB>" if has('conceal') set conceallevel=2 concealcursor=i endif
最後に追加したhybridのカラーマップを使うよう、以下を~/.vimrcに追加します。
set shiftwidth=4 set t_Co=256 colorscheme hybrid
実行結果
セミコロンを削除してエラーになるようにした結果が以下になります。エラー部分が >> で表示されています。hybridのカラーマップもいい感じじゃないでしょうか。