0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[macOS Big Sur] dein.vim + syntastic + flake8 で vim上でpythonの文法チェックする

Last updated at Posted at 2019-12-11

#flake8
https://pypi.org/project/flake8/
Pythonの文法チェックツール。
以下の3つのライブラリのラッパーとなる

  • PyFlakes
  • pycodestyle
  • Ned Batchelder’s McCabe script

dein.vim

https://github.com/Shougo/dein.vim
dein.vim は vimプラグインマネージャー

syntastic

https://github.com/vim-syntastic/syntastic
vim における汎用シンタックスチェッカー

#flake8のインストール

% brew install flake8
% flake8 --version
3.9.2 (mccabe: 0.6.1, pycodestyle: 2.7.0, pyflakes: 2.3.1) CPython 3.9.6 on Darwin

#dein.vimとsyntasticのインストール


% cd /tmp
% curl https://raw.githubusercontent.com/Shougo/dein-installer.vim/master/installer.sh  > installer.sh
% sh ./installer.sh

既存の~/.vimrc 下記を追記

~/.vimrc
"----------------------------------------------------------
" Vim/Neovim plugin manager
" https://github.com/Shougo/dein.vim
"----------------------------------------------------------
"dein Scripts-----------------------------
if &compatible
  set nocompatible               " Be iMproved
endif

" Required:
set runtimepath+=~/.cache/dein/repos/github.com/Shougo/dein.vim

" Required:
if dein#load_state('~/.cache/dein')
  call dein#begin('~/.cache/dein')

  " Let dein manage dein
  " Required:
  call dein#add('~/.cache/dein/repos/github.com/Shougo/dein.vim')

  " Add or remove your plugins here like this:
  "call dein#add('Shougo/neosnippet.vim')
  "call dein#add('Shougo/neosnippet-snippets')

  " syntax checking plugin
  " https://github.com/vim-syntastic/syntastic
  call dein#add('scrooloose/syntastic')

  " Required:
  call dein#end()
  call dein#save_state()
endif

" Required:
filetype plugin indent on
syntax enable

" If you want to install not installed plugins on startup.
if dein#check_install()
  call dein#install()
endif

"End dein Scripts-------------------------

"----------------------------------------------------------
" syntastic
"----------------------------------------------------------
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

"----------------------------------------------------------
" flake8
"----------------------------------------------------------
let g:syntastic_python_checkers = ["flake8"]

実際に使用してlintしてくれるか確認する。

vim /tmp/test.py
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?