Last active
May 5, 2020 19:40
-
-
Save wmvanvliet/4aa309c2c3e7228060122e7beda14ece to your computer and use it in GitHub Desktop.
Vim keybinding for toggling PEP8 linting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Linter (provided through ALE) | |
let g:ale_lint_on_text_changed = 'never' | |
let g:ale_lint_on_save = 1 | |
let g:ale_linters = { | |
\ 'python': ['flake8'], | |
\} | |
" By default, don't worry about PEP8 | |
let g:ale_python_flake8_options = "--ignore=E2,E3,E4,E5,E7,W" | |
let g:python_highlight_space_errors = 0 | |
" Function to enable PEP8 checking | |
function! TogglePep8() | |
if g:ale_python_flake8_options == "" | |
let g:ale_python_flake8_options = "--ignore=E2,E3,E4,E5,E7,W" | |
setlocal colorcolumn=0 | |
let g:python_highlight_space_errors = 0 | |
else | |
let g:ale_python_flake8_options = "" | |
setlocal colorcolumn=80 | |
let g:python_highlight_space_errors = 1 | |
endif | |
endfunction | |
" Python PEP8 checking | |
nmap <leader>8 :call TogglePep8()<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment