diff options
author | w0rp <w0rp@users.noreply.github.com> | 2019-06-10 19:33:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-10 19:33:00 +0100 |
commit | 8b46fa3ee716485b4dd7c3f86c9302a140be6bfa (patch) | |
tree | d370bffd0d5607e6b8f272e56b179d2abb72fbc1 /autoload | |
parent | 22e7a6f6c2914a2fd77085f1241bc6907bd85c06 (diff) | |
parent | 56641e02301475cfee9ddcaf547066898f073048 (diff) | |
download | ale-8b46fa3ee716485b4dd7c3f86c9302a140be6bfa.zip |
Merge pull request #2567 from theevocater/add_reorder_python_imports
Add support for reorder-python-imports fixer
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fix/registry.vim | 5 | ||||
-rw-r--r-- | autoload/ale/fixers/reorder_python_imports.vim | 25 |
2 files changed, 30 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index d72877af..1a8d02ef 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -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. diff --git a/autoload/ale/fixers/reorder_python_imports.vim b/autoload/ale/fixers/reorder_python_imports.vim new file mode 100644 index 00000000..42a0a6e2 --- /dev/null +++ b/autoload/ale/fixers/reorder_python_imports.vim @@ -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 |