mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-03 16:42:50 +08:00
Add support for reorder-python-imports fixer
isort is great, but I've come to prefer reorder-python-imports. The tool has a focus on smaller diffs than isort. reorder-python-imports is also a little smarter than isort which is nice.
This commit is contained in:
@@ -310,6 +310,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['sql'],
|
||||
\ 'description': 'A PostgreSQL SQL syntax beautifier',
|
||||
\ },
|
||||
\ 'reorder-python-imports': {
|
||||
\ 'function': 'ale#fixers#reorder_python_imports#Fix',
|
||||
\ 'suggested_filetypes': ['python'],
|
||||
\ 'description': 'Sort Python imports with reorder-python-imports.',
|
||||
\ },
|
||||
\}
|
||||
|
||||
" Reset the function registry to the default entries.
|
||||
|
||||
25
autoload/ale/fixers/reorder_python_imports.vim
Normal file
25
autoload/ale/fixers/reorder_python_imports.vim
Normal file
@@ -0,0 +1,25 @@
|
||||
" Author: jake <me@jake.computer>
|
||||
" Description: Fixing Python imports with reorder-python-imports.
|
||||
|
||||
call ale#Set('python_reorder_python_imports_executable', 'reorder-python-imports')
|
||||
call ale#Set('python_reorder_python_imports_options', '')
|
||||
call ale#Set('python_reorder_python_imports_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
|
||||
function! ale#fixers#reorder_python_imports#Fix(buffer) abort
|
||||
let l:executable = ale#python#FindExecutable(
|
||||
\ a:buffer,
|
||||
\ 'python_reorder_python_imports',
|
||||
\ ['reorder-python-imports'],
|
||||
\)
|
||||
|
||||
if !executable(l:executable)
|
||||
return 0
|
||||
endif
|
||||
|
||||
let l:options = ale#Var(a:buffer, 'python_reorder_python_imports_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '') . ' -',
|
||||
\}
|
||||
endfunction
|
||||
Reference in New Issue
Block a user