mirror of
https://github.com/dense-analysis/ale.git
synced 2026-08-13 03:11:01 +08:00
add autoflake fixer (#3779)
* first attempt * added autoflake executable * added Windows executable for appveyor * delete unused files * corrected wrong sorting
This commit is contained in:
@@ -17,6 +17,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['python'],
|
||||
\ 'description': 'Fix import issues with autoimport.',
|
||||
\ },
|
||||
\ 'autoflake': {
|
||||
\ 'function': 'ale#fixers#autoflake#Fix',
|
||||
\ 'suggested_filetypes': ['python'],
|
||||
\ 'description': 'Fix flake issues with autoflake.',
|
||||
\ },
|
||||
\ 'autopep8': {
|
||||
\ 'function': 'ale#fixers#autopep8#Fix',
|
||||
\ 'suggested_filetypes': ['python'],
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
" Author: circld <circld1@gmail.com>
|
||||
" Description: Fixing files with autoflake.
|
||||
|
||||
call ale#Set('python_autoflake_executable', 'autoflake')
|
||||
call ale#Set('python_autoflake_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('python_autoflake_options', '')
|
||||
|
||||
function! ale#fixers#autoflake#Fix(buffer) abort
|
||||
let l:executable = ale#python#FindExecutable(
|
||||
\ a:buffer,
|
||||
\ 'python_autoflake',
|
||||
\ ['autoflake'],
|
||||
\)
|
||||
|
||||
if !executable(l:executable)
|
||||
return 0
|
||||
endif
|
||||
|
||||
let l:options = ale#Var(a:buffer, 'python_autoflake_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' --in-place '
|
||||
\ . ' %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
Reference in New Issue
Block a user