mirror of
https://github.com/aquatix/dotfiles.git
synced 2025-12-06 20:35:11 +01:00
Support ruff as Python linter and fixer
This commit is contained in:
@@ -28,6 +28,7 @@ virtualenv_path = find_virtualenv(['virtualenv', 'venv']) #vim.eval('ale_virtua
|
||||
if virtualenv_path:
|
||||
has_pylint_django = glob.glob(os.path.join(virtualenv_path, 'lib/*/site-packages/pylint_django'))
|
||||
has_pylint = glob.glob(os.path.join(virtualenv_path, 'lib/*/site-packages/pylint'))
|
||||
has_ruff = glob.glob(os.path.join(virtualenv_path, 'lib/*/site-packages/ruff'))
|
||||
has_flake8 = glob.glob(os.path.join(virtualenv_path, 'lib/*/site-packages/flake8'))
|
||||
has_bandit = glob.glob(os.path.join(virtualenv_path, 'lib/*/site-packages/bandit'))
|
||||
else:
|
||||
@@ -43,6 +44,12 @@ else:
|
||||
except ImportError:
|
||||
has_pylint = False
|
||||
|
||||
try:
|
||||
find_spec('ruff')
|
||||
has_ruff = True
|
||||
except ImportError:
|
||||
has_ruff = False
|
||||
|
||||
try:
|
||||
find_spec('flake8')
|
||||
has_flake8 = True
|
||||
@@ -58,6 +65,8 @@ else:
|
||||
linters = []
|
||||
if has_pylint:
|
||||
linters.append('pylint')
|
||||
if has_ruff:
|
||||
linters.append('ruff')
|
||||
if has_flake8:
|
||||
linters.append('flake8')
|
||||
if has_bandit:
|
||||
|
||||
8
.vimrc
8
.vimrc
@@ -396,12 +396,14 @@ nmap <leader>= <Plug>(ale_fix)
|
||||
" Quickly open the loclist to see syntax errors
|
||||
nmap <leader>; :lopen<CR>
|
||||
let g:ale_maximum_file_size = 500000 " Don't lint large files (> 500KB), it can slow things down
|
||||
let g:ale_fixers = {}
|
||||
"let g:ale_fixers = {}
|
||||
let g:ale_fixers = { '*': ['remove_trailing_lines', 'trim_whitespace'], }
|
||||
" Python specific settings
|
||||
let g:ale_fixers.python = ['isort']
|
||||
let g:ale_fixers.python = ['isort', 'ruff', 'black']
|
||||
" JS specific settings
|
||||
let g:ale_fixers.javascript = ['eslint', 'prettier']
|
||||
|
||||
" See VIMHOME/after/ftplugin/python.vim for some pylint configuration, also checking whether a
|
||||
" See VIMHOME/after/ftplugin/python.vim for some linting configuration, also checking whether a
|
||||
" project uses Django
|
||||
|
||||
" Show errors or warnings in the statusline
|
||||
|
||||
Reference in New Issue
Block a user