diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | autoload/ale/fixers/autopep8.vim | 17 | ||||
-rw-r--r-- | autoload/ale/fixers/isort.vim | 10 | ||||
-rw-r--r-- | autoload/ale/fixers/yapf.vim | 10 | ||||
-rw-r--r-- | autoload/ale/python.vim | 50 | ||||
-rw-r--r-- | doc/ale-css.txt | 11 | ||||
-rw-r--r-- | doc/ale-handlebars.txt | 11 | ||||
-rw-r--r-- | doc/ale-html.txt | 25 | ||||
-rw-r--r-- | doc/ale-javascript.txt | 74 | ||||
-rw-r--r-- | doc/ale-python.txt | 79 | ||||
-rw-r--r-- | doc/ale-sass.txt | 11 | ||||
-rw-r--r-- | doc/ale-scss.txt | 11 | ||||
-rw-r--r-- | doc/ale-typescript.txt | 11 | ||||
-rw-r--r-- | doc/ale.txt | 27 | ||||
-rw-r--r-- | test/fixers/test_autopep8_fixer_callback.vader | 39 | ||||
-rw-r--r-- | test/fixers/test_isort_fixer_callback.vader | 29 | ||||
-rw-r--r-- | test/fixers/test_python_fixer_command_callback.vader | 58 | ||||
-rw-r--r-- | test/fixers/test_yapf_fixer_callback.vader | 29 |
18 files changed, 287 insertions, 217 deletions
@@ -102,7 +102,7 @@ name. That seems to be the fairest way to arrange this table. | Pod | [proselint](http://proselint.com/)| | Pug | [pug-lint](https://github.com/pugjs/pug-lint) | | Puppet | [puppet](https://puppet.com), [puppet-lint](https://puppet-lint.com) | -| Python | [flake8](http://flake8.pycqa.org/en/latest/), [mypy](http://mypy-lang.org/), [pylint](https://www.pylint.org/) | +| Python | [autopep8](https://github.com/hhatto/autopep8), [flake8](http://flake8.pycqa.org/en/latest/), [isort](https://github.com/timothycrosley/isort), [mypy](http://mypy-lang.org/), [pylint](https://www.pylint.org/), [yapf](https://github.com/google/yapf) | | ReasonML | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-integration-reason-merlin` for configuration instructions | reStructuredText | [proselint](http://proselint.com/)| | RPM spec | [rpmlint](https://github.com/rpm-software-management/rpmlint) (disabled by default; see `:help ale-integration-spec`) | diff --git a/autoload/ale/fixers/autopep8.vim b/autoload/ale/fixers/autopep8.vim index 32d2824b..8bfc0d90 100644 --- a/autoload/ale/fixers/autopep8.vim +++ b/autoload/ale/fixers/autopep8.vim @@ -1,13 +1,26 @@ " Author: w0rp <devw0rp@gmail.com> " Description: Fixing files with autopep8. +call ale#Set('python_autopep8_executable', 'autopep8') +call ale#Set('python_autopep8_use_global', 0) +call ale#Set('python_autopep8_options', '') + function! ale#fixers#autopep8#Fix(buffer) abort - let l:executable = ale#python#GetExecutable(a:buffer, 'autopep8') + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'python_autopep8', + \ ['/bin/autopep8'], + \) + if empty(l:executable) return 0 endif + let l:options = ale#Var(a:buffer, 'python_autopep8_options') + return { - \ 'command': ale#Escape(l:executable) . ' -' + \ 'command': ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' -', \} endfunction diff --git a/autoload/ale/fixers/isort.vim b/autoload/ale/fixers/isort.vim index c37f12f7..e1ddcda3 100644 --- a/autoload/ale/fixers/isort.vim +++ b/autoload/ale/fixers/isort.vim @@ -1,8 +1,16 @@ " Author: w0rp <devw0rp@gmail.com> " Description: Fixing Python imports with isort. +call ale#Set('python_isort_executable', 'isort') +call ale#Set('python_isort_use_global', 0) + function! ale#fixers#isort#Fix(buffer) abort - let l:executable = ale#python#GetExecutable(a:buffer, 'isort') + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'python_isort', + \ ['/bin/isort'], + \) + if empty(l:executable) return 0 endif diff --git a/autoload/ale/fixers/yapf.vim b/autoload/ale/fixers/yapf.vim index 3eae09bc..fe6512aa 100644 --- a/autoload/ale/fixers/yapf.vim +++ b/autoload/ale/fixers/yapf.vim @@ -1,8 +1,16 @@ " Author: w0rp <devw0rp@gmail.com> " Description: Fixing Python files with yapf. +call ale#Set('python_yapf_executable', 'yapf') +call ale#Set('python_yapf_use_global', 0) + function! ale#fixers#yapf#Fix(buffer) abort - let l:executable = ale#python#GetExecutable(a:buffer, 'yapf') + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'python_yapf', + \ ['/bin/yapf'], + \) + if empty(l:executable) return 0 endif diff --git a/autoload/ale/python.vim b/autoload/ale/python.vim index f835e942..a88b4b62 100644 --- a/autoload/ale/python.vim +++ b/autoload/ale/python.vim @@ -9,27 +9,6 @@ let g:ale_virtualenv_dir_names = get(g:, 'ale_virtualenv_dir_names', [ \ 'virtualenv', \]) -" Given a buffer number and a command name, find the path to the executable. -" First search on a virtualenv for Python, if nothing is found, try the global -" command. Returns an empty string if cannot find the executable -function! ale#python#GetExecutable(buffer, cmd_name) abort - let l:virtualenv = ale#python#FindVirtualenv(a:buffer) - - if !empty(l:virtualenv) - let l:ve_executable = l:virtualenv . '/bin/' . a:cmd_name - - if executable(l:ve_executable) - return l:ve_executable - endif - endif - - if executable(a:cmd_name) - return a:cmd_name - endif - - return '' -endfunction - " Given a buffer number, find the project root directory for Python. " The root directory is defined as the first directory found while searching " upwards through paths, including the current directory, until a path @@ -58,3 +37,32 @@ function! ale#python#FindVirtualenv(buffer) abort return '' endfunction + +" Given a buffer number and a command name, find the path to the executable. +" First search on a virtualenv for Python, if nothing is found, try the global +" command. Returns an empty string if cannot find the executable +function! ale#python#FindExecutable(buffer, base_var_name, path_list) abort + if ale#Var(a:buffer, a:base_var_name . '_use_global') + return ale#Var(a:buffer, a:base_var_name . '_executable') + endif + + let l:virtualenv = ale#python#FindVirtualenv(a:buffer) + + if !empty(l:virtualenv) + for l:path in a:path_list + let l:ve_executable = l:virtualenv . l:path + + if executable(l:ve_executable) + return l:ve_executable + endif + endfor + endif + + let l:global_executable = ale#Var(a:buffer, a:base_var_name . '_executable') + + if executable(l:global_executable) + return l:global_executable + endif + + return '' +endfunction diff --git a/doc/ale-css.txt b/doc/ale-css.txt index 83838fb9..bce84602 100644 --- a/doc/ale-css.txt +++ b/doc/ale-css.txt @@ -10,11 +10,7 @@ g:ale_css_stylelint_executable *g:ale_css_stylelint_executable* Type: |String| Default: `'stylelint'` - ALE will first discover the stylelint path in an ancestor node_modules - directory. If no such path exists, this variable will be used instead. - - If you wish to use only a globally installed version of stylelint, set - |g:ale_css_stylelint_use_global| to `1`. + See |ale-integrations-local-executables| g:ale_css_stylelint_options *g:ale_css_stylelint_options* @@ -30,10 +26,7 @@ g:ale_css_stylelint_use_global *g:ale_css_stylelint_use_global* Type: |String| Default: `0` - This variable controls whether or not ALE will search for a local path for - stylelint first. If this variable is set to `1`, then ALE will always use the - global version of stylelint, in preference to locally installed versions of - stylelint in node_modules. + See |ale-integrations-local-executables| ------------------------------------------------------------------------------- diff --git a/doc/ale-handlebars.txt b/doc/ale-handlebars.txt index bf186766..94781101 100644 --- a/doc/ale-handlebars.txt +++ b/doc/ale-handlebars.txt @@ -10,11 +10,7 @@ g:ale_handlebars_embertemplatelint_executable Type: |String| *b:ale_handlebars_embertemplatelint_executable* Default: `'ember-template-lint'` - ALE will look for ember-template-lint executable in ancestor node_modules - directory. When it cannot find it, this variable will be used instead. - - If you wish to use only a globally installed version of ember-template-lint, - set |g:ale_handlebars_embertemplatelint_use_global| to `1`. + See |ale-integrations-local-executables| g:ale_handlebars_embertemplatelint_use_global @@ -22,10 +18,7 @@ g:ale_handlebars_embertemplatelint_use_global Type: |Number| *b:ale_handlebars_embertemplatelint_use_global* Default: `0` - This variable controls whether or not ALE will search for a local - ember-template-lint executable first. If this variable is set to `1`, then - ALE will always use the global version of ember-template-lint, in preference - to version installed in local node_modules directory. + See |ale-integrations-local-executables| ------------------------------------------------------------------------------- diff --git a/doc/ale-html.txt b/doc/ale-html.txt index 5869257a..b2fdc4c8 100644 --- a/doc/ale-html.txt +++ b/doc/ale-html.txt @@ -5,24 +5,20 @@ ALE HTML Integration *ale-html-options* ------------------------------------------------------------------------------- htmlhint *ale-html-htmlhint* -g:ale_html_htmlhint_options *g:ale_html_htmlhint_options* - *b:ale_html_htmlhint_options* - Type: |String| - Default: `'--format=unix'` - - This variable can be changed to modify flags given to HTMLHint. - - g:ale_html_htmlhint_executable *g:ale_html_htmlhint_executable* *b:ale_html_htmlhint_executable* Type: |String| Default: `'htmlhint'` - ALE will first discover the htmlhint path in an ancestor node_modules - directory. If no such path exists, this variable will be used instead. + See |ale-integrations-local-executables| - If you wish to use only a globally installed version of htmlhint, set - |g:ale_html_htmlhint_use_global| to `1`. + +g:ale_html_htmlhint_options *g:ale_html_htmlhint_options* + *b:ale_html_htmlhint_options* + Type: |String| + Default: `'--format=unix'` + + This variable can be changed to modify flags given to HTMLHint. g:ale_html_htmlhint_use_global *g:ale_html_htmlhint_use_global* @@ -30,10 +26,7 @@ g:ale_html_htmlhint_use_global *g:ale_html_htmlhint_use_global* Type: |String| Default: `0` - This variable controls whether or not ALE will search for a local path for - htmlhint first. If this variable is set to `1`, then ALE will always use the - global version of htmlhint, in preference to locally installed versions of - htmlhint in node_modules. + See |ale-integrations-local-executables| ------------------------------------------------------------------------------- diff --git a/doc/ale-javascript.txt b/doc/ale-javascript.txt index e104656b..f7b01fa2 100644 --- a/doc/ale-javascript.txt +++ b/doc/ale-javascript.txt @@ -31,14 +31,7 @@ g:ale_javascript_eslint_executable *g:ale_javascript_eslint_executable* Type: |String| Default: `'eslint'` - ALE will first discover the eslint path in an ancestor node_modules - directory. If no such path exists, this variable will be used instead. - - This variable can be set to change the path to eslint. If you have eslint_d - installed, you can set this option to use eslint_d instead. - - If you wish to use only a globally installed version of eslint, set - |g:ale_javascript_eslint_use_global| to `1`. + See |ale-integrations-local-executables| g:ale_javascript_eslint_options *g:ale_javascript_eslint_options* @@ -54,10 +47,7 @@ g:ale_javascript_eslint_use_global *g:ale_javascript_eslint_use_global* Type: |Number| Default: `0` - This variable controls whether or not ALE will search for a local path for - eslint first. If this variable is set to `1`, then ALE will always use the - global version of eslint, in preference to locally installed versions of - eslint in node_modules. + See |ale-integrations-local-executables| ------------------------------------------------------------------------------- @@ -68,11 +58,7 @@ g:ale_javascript_prettier_executable *g:ale_javascript_prettier_executable* Type: |String| Default: `'prettier'` - ALE will first discover the prettier path in an ancestor node_modules - directory. If no such path exists, this variable will be used instead. - - If you wish to use only a globally installed version of prettier set - |g:ale_javascript_prettier_use_global| to `1`. + See |ale-integrations-local-executables| g:ale_javascript_prettier_options *g:ale_javascript_prettier_options* @@ -88,9 +74,7 @@ g:ale_javascript_prettier_use_global *g:ale_javascript_prettier_use_global* Type: |Number| Default: `0` - This variable controls whether or not ALE will search for a local path for - prettier first. If this variable is set to `1`, then ALE will always use the - global version of Prettier. + See |ale-integrations-local-executables| ------------------------------------------------------------------------------- @@ -102,11 +86,7 @@ g:ale_javascript_prettier_eslint_executable Type: |String| Default: `'prettier-eslint'` - ALE will first discover the prettier-eslint path in an ancestor node_modules - directory. If no such path exists, this variable will be used instead. - - If you wish to use only a globally installed version of prettier-eslint set - |g:ale_javascript_prettier_eslint_use_global| to `1`. + See |ale-integrations-local-executables| g:ale_javascript_prettier_eslint_options @@ -124,9 +104,7 @@ g:ale_javascript_prettier_eslint_use_global Type: |Number| Default: `0` - This variable controls whether or not ALE will search for a local path for - prettier-eslint first. If this variable is set to `1`, then ALE will always - use the global version of Prettier-eslint. + See |ale-integrations-local-executables| ------------------------------------------------------------------------------- @@ -137,11 +115,7 @@ g:ale_javascript_flow_executable *g:ale_javascript_flow_executable* Type: |String| Default: `'flow'` - ALE will first discover the flow path in an ancestor node_modules - directory. If no such path exists, this variable will be used instead. - - If you wish to use only a globally installed version of flow, set - |g:ale_javascript_flow_use_global| to `1`. + See |ale-integrations-local-executables| g:ale_javascript_flow_use_global *g:ale_javascript_flow_use_global* @@ -149,10 +123,7 @@ g:ale_javascript_flow_use_global *g:ale_javascript_flow_use_global* Type: |Number| Default: `0` - This variable controls whether or not ALE will search for a local path for - flow first. If this variable is set to `1`, then ALE will always use the - global version of flow, in preference to locally installed versions of - flow in node_modules. + See |ale-integrations-local-executables| ------------------------------------------------------------------------------- @@ -163,13 +134,7 @@ g:ale_javascript_jshint_executable *g:ale_javascript_jshint_executable* Type: |String| Default: `'jshint'` - ALE will first discover the jshint path in an ancestor node_modules - directory. If no such path exists, this variable will be used instead. - - This variable can be changed to change the path to jshint. - - If you wish to use only a globally installed version of jshint, set - |g:ale_javascript_jshint_use_global| to `1`. + See |ale-integrations-local-executables| g:ale_javascript_jshint_use_global *g:ale_javascript_jshint_use_global* @@ -177,10 +142,7 @@ g:ale_javascript_jshint_use_global *g:ale_javascript_jshint_use_global* Type: |Number| Default: `0` - This variable controls whether or not ALE will search for a local path for - jshint first. If this variable is set to `1`, then ALE will always use the - global version of jshint, in preference to locally installed versions of - jshint in node_modules. + See |ale-integrations-local-executables| ------------------------------------------------------------------------------- @@ -191,9 +153,7 @@ g:ale_javascript_standard_executable *g:ale_javascript_standard_executable* Type: |String| Default: `'standard'` - Same as the eslint option. - - See: |g:ale_javascript_eslint_executable| + See |ale-integrations-local-executables| g:ale_javascript_standard_options *g:ale_javascript_standard_options* @@ -209,9 +169,7 @@ g:ale_javascript_standard_use_global *g:ale_javascript_standard_use_global* Type: |Number| Default: `0` - Same as the eslint option. - - See: |g:ale_javascript_eslint_use_global| + See |ale-integrations-local-executables| ------------------------------------------------------------------------------- @@ -222,9 +180,7 @@ g:ale_javascript_xo_executable *g:ale_javascript_xo_executable* Type: |String| Default: `'xo'` - Same as the eslint option. - - See: |g:ale_javascript_eslint_executable| + See |ale-integrations-local-executables| g:ale_javascript_xo_options *g:ale_javascript_xo_options* @@ -240,9 +196,7 @@ g:ale_javascript_xo_use_global *g:ale_javascript_xo_use_global* Type: |Number| Default: `0` - Same as the eslint option. - - See: |g:ale_javascript_eslint_use_global| + See |ale-integrations-local-executables| ------------------------------------------------------------------------------- diff --git a/doc/ale-python.txt b/doc/ale-python.txt index 26e1d71a..ddbe9e3a 100644 --- a/doc/ale-python.txt +++ b/doc/ale-python.txt @@ -18,6 +18,33 @@ g:ale_virtualenv_dir_names *g:ale_virtualenv_dir_names* ------------------------------------------------------------------------------- +autopep8 *ale-python-autopep8* + +g:ale_python_autopep8_executable *g:ale_python_autopep8_executable* + *b:ale_python_autopep8_executable* + Type: |String| + Default: `'autopep8'` + + See |ale-integrations-local-executables| + + +g:ale_python_autopep8_options *g:ale_python_autopep8_options* + *b:ale_python_autopep8_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to autopep8. + + +g:ale_python_autopep8_use_global *g:ale_python_autopep8_use_global* + *b:ale_python_autopep8_use_global* + Type: |Number| + Default: `0` + + See |ale-integrations-local-executables| + + +------------------------------------------------------------------------------- flake8 *ale-python-flake8* g:ale_python_flake8_executable *g:ale_python_flake8_executable* @@ -59,6 +86,25 @@ g:ale_python_flake8_use_global *g:ale_python_flake8_use_global* ------------------------------------------------------------------------------- +isort *ale-python-isort* + +g:ale_python_isort_executable *g:ale_python_isort_executable* + *b:ale_python_isort_executable* + Type: |String| + Default: `'isort'` + + See |ale-integrations-local-executables| + + +g:ale_python_isort_use_global *g:ale_python_isort_use_global* + *b:ale_python_isort_use_global* + Type: |Number| + Default: `0` + + See |ale-integrations-local-executables| + + +------------------------------------------------------------------------------- mypy *ale-python-mypy* g:ale_python_mypy_executable *g:ale_python_mypy_executable* @@ -66,7 +112,7 @@ g:ale_python_mypy_executable *g:ale_python_mypy_executable* Type: |String| Default: `'mypy'` - This variable can be changed to modify the executable used for mypy. + See |ale-integrations-local-executables| g:ale_python_mypy_options *g:ale_python_mypy_options* @@ -83,11 +129,7 @@ g:ale_python_mypy_use_global *g:ale_python_mypy_use_global* Type: |Number| Default: `0` - This variable controls whether or not ALE will search for mypy in a - virtualenv directory first. If this variable is set to `1`, then ALE will - always use |g:ale_python_mypy_executable| for the executable path. - - Both variables can be set with `b:` buffer variables instead. + See |ale-integrations-local-executables| ------------------------------------------------------------------------------- @@ -98,7 +140,7 @@ g:ale_python_pylint_executable *g:ale_python_pylint_executable* Type: |String| Default: `'pylint'` - This variable can be changed to modify the executable used for pylint. + See |ale-integrations-local-executables| g:ale_python_pylint_options *g:ale_python_pylint_options* @@ -126,11 +168,26 @@ g:ale_python_pylint_use_global *g:ale_python_pylint_use_global* Type: |Number| Default: `0` - This variable controls whether or not ALE will search for pylint in a - virtualenv directory first. If this variable is set to `1`, then ALE will - always use |g:ale_python_pylint_executable| for the executable path. + See |ale-integrations-local-executables| - Both variables can be set with `b:` buffer variables instead. + +------------------------------------------------------------------------------- +yapf *ale-python-yapf* + +g:ale_python_yapf_executable *g:ale_python_yapf_executable* + *b:ale_python_yapf_executable* + Type: |String| + Default: `'yapf'` + + See |ale-integrations-local-executables| + + +g:ale_python_yapf_use_global *g:ale_python_yapf_use_global* + *b:ale_python_yapf_use_global* + Type: |Number| + Default: `0` + + See |ale-integrations-local-executables| ------------------------------------------------------------------------------- diff --git a/doc/ale-sass.txt b/doc/ale-sass.txt index d8d36dfa..ea76c350 100644 --- a/doc/ale-sass.txt +++ b/doc/ale-sass.txt @@ -10,11 +10,7 @@ g:ale_sass_stylelint_executable *g:ale_sass_stylelint_executable* Type: |String| Default: `'stylelint'` - ALE will first discover the stylelint path in an ancestor node_modules - directory. If no such path exists, this variable will be used instead. - - If you wish to use only a globally installed version of stylelint, set - |g:ale_sass_stylelint_use_global| to `1`. + See |ale-integrations-local-executables| g:ale_sass_stylelint_use_global *g:ale_sass_stylelint_use_global* @@ -22,10 +18,7 @@ g:ale_sass_stylelint_use_global *g:ale_sass_stylelint_use_global* Type: |String| Default: `0` - This variable controls whether or not ALE will search for a local path for - stylelint first. If this variable is set to `1`, then ALE will always use the - global version of stylelint, in preference to locally installed versions of - stylelint in node_modules. + See |ale-integrations-local-executables| ------------------------------------------------------------------------------- diff --git a/doc/ale-scss.txt b/doc/ale-scss.txt index 9e222a0b..b16c8b11 100644 --- a/doc/ale-scss.txt +++ b/doc/ale-scss.txt @@ -10,11 +10,7 @@ g:ale_scss_stylelint_executable *g:ale_scss_stylelint_executable* Type: |String| Default: `'stylelint'` - ALE will first discover the stylelint path in an ancestor node_modules - directory. If no such path exists, this variable will be used instead. - - If you wish to use only a globally installed version of stylelint, set - |g:ale_scss_stylelint_use_global| to `1`. + See |ale-integrations-local-executables| g:ale_scss_stylelint_use_global *g:ale_scss_stylelint_use_global* @@ -22,10 +18,7 @@ g:ale_scss_stylelint_use_global *g:ale_scss_stylelint_use_global* Type: |String| Default: `0` - This variable controls whether or not ALE will search for a local path for - stylelint first. If this variable is set to `1`, then ALE will always use the - global version of stylelint, in preference to locally installed versions of - stylelint in node_modules. + See |ale-integrations-local-executables| ------------------------------------------------------------------------------- diff --git a/doc/ale-typescript.txt b/doc/ale-typescript.txt index a1f5aafc..009864b9 100644 --- a/doc/ale-typescript.txt +++ b/doc/ale-typescript.txt @@ -10,11 +10,7 @@ g:ale_typescript_tslint_executable *g:ale_typescript_tslint_executable* Type: |String| Default: `'tslint'` - ALE will first discover the tslint path in an ancestor node_modules - directory. If no such path exists, this variable will be used instead. - - If you wish to use only a globally installed version of tslint, set - |g:ale_typescript_tslint_use_global| to `1`. + See |ale-integrations-local-executables| g:ale_typescript_tslint_config_path *g:ale_typescript_tslint_config_path* @@ -31,10 +27,7 @@ g:ale_typescript_tslint_use_global *g:ale_typescript_tslint_use_global* Type: |Number| Default: `0` - This variable controls whether or not ALE will search for a local path for - tslint first. If this variable is set to `1`, then ALE will always use the - global version of tslint, in preference to locally installed versions of - tslint in node_modules. + See |ale-integrations-local-executables| ------------------------------------------------------------------------------- diff --git a/doc/ale.txt b/doc/ale.txt index 8c6ecf9d..6a17cc60 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -70,9 +70,12 @@ CONTENTS *ale-contents* phpcs...............................|ale-php-phpcs| phpmd...............................|ale-php-phpmd| python................................|ale-python-options| + autopep8............................|ale-python-autopep8| flake8..............................|ale-python-flake8| + isort...............................|ale-python-isort| mypy................................|ale-python-mypy| pylint..............................|ale-python-pylint| + yapf................................|ale-python-yapf| ruby..................................|ale-ruby-options| reek................................|ale-ruby-reek| rubocop.............................|ale-ruby-rubocop| @@ -177,7 +180,7 @@ The following languages and tools are supported. * Pod: 'proselint' * Pug: 'pug-lint' * Puppet: 'puppet', 'puppet-lint' -* Python: 'flake8', 'mypy', 'pylint' +* Python: 'autopep8', 'flake8', 'isort', 'mypy', 'pylint', 'yapf' * ReasonML: 'merlin' * reStructuredText: 'proselint' * RPM spec: 'spec' @@ -871,6 +874,28 @@ Every option for programs can be set globally, or individually for each buffer. For example, `b:ale_python_flake8_executable` will override any values set for `g:ale_python_flake8_executable`. + *ale-integrations-local-executables* + +Some tools will prefer to search for locally-installed executables, unless +configured otherwise. For example, the `eslint` linter will search for +various executable paths in `node_modules`. The `flake8` linter will search +for virtualenv directories. + +If you prefer to use global executables for those tools, set the relevant +`_use_global` and `_executable` options for those linters. > + + " Use the global executable with a special name for eslint. + let g:ale_javascript_eslint_executable = 'special-eslint' + let g:ale_javascript_eslint_use_global = 1 + + " Use the global executable with a special name for flake8. + let g:ale_python_flake8_executable = '/foo/bar/flake8' + let g:ale_python_flake8_use_global = 1 +< + +The option |g:ale_virtualenv_dir_names| controls the local virtualenv paths +ALE will use to search for Python executables. + =============================================================================== 6. Commands/Keybinds *ale-commands* diff --git a/test/fixers/test_autopep8_fixer_callback.vader b/test/fixers/test_autopep8_fixer_callback.vader new file mode 100644 index 00000000..3b5b057c --- /dev/null +++ b/test/fixers/test_autopep8_fixer_callback.vader @@ -0,0 +1,39 @@ +Before: + Save g:ale_python_autopep8_executable + Save g:ale_python_autopep8_options + + " Use an invalid global executable, so we don't match it. + let g:ale_python_autopep8_executable = 'xxxinvalid' + let g:ale_python_autopep8_options = '' + + silent! execute 'cd /testplugin/test/command_callback' + silent cd .. + silent cd command_callback + let g:dir = getcwd() + +After: + Restore + + silent execute 'cd ' . fnameescape(g:dir) + " Set the file to something else, + " or we'll cause issues when running other tests + silent file 'dummy.py' + unlet! g:dir + +Execute(The autopep8 callback should return the correct default values): + AssertEqual + \ 0, + \ ale#fixers#autopep8#Fix(bufnr('')) + + silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py') + AssertEqual + \ {'command': "'" . g:dir . "/python_paths/with_virtualenv/env/bin/autopep8' -" }, + \ ale#fixers#autopep8#Fix(bufnr('')) + +Execute(The autopep8 callback should include options): + let g:ale_python_autopep8_options = '--some-option' + + silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py') + AssertEqual + \ {'command': "'" . g:dir . "/python_paths/with_virtualenv/env/bin/autopep8' --some-option -" }, + \ ale#fixers#autopep8#Fix(bufnr('')) diff --git a/test/fixers/test_isort_fixer_callback.vader b/test/fixers/test_isort_fixer_callback.vader new file mode 100644 index 00000000..495f23c5 --- /dev/null +++ b/test/fixers/test_isort_fixer_callback.vader @@ -0,0 +1,29 @@ +Before: + Save g:ale_python_isort_executable + + " Use an invalid global executable, so we don't match it. + let g:ale_python_isort_executable = 'xxxinvalid' + + silent! execute 'cd /testplugin/test/command_callback' + silent cd .. + silent cd command_callback + let g:dir = getcwd() + +After: + Restore + + silent execute 'cd ' . fnameescape(g:dir) + " Set the file to something else, + " or we'll cause issues when running other tests + silent file 'dummy.py' + unlet! g:dir + +Execute(The isort callback should return the correct default values): + AssertEqual + \ 0, + \ ale#fixers#isort#Fix(bufnr('')) + + silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py') + AssertEqual + \ {'command': "'" . g:dir . "/python_paths/with_virtualenv/env/bin/isort' -" }, + \ ale#fixers#isort#Fix(bufnr('')) diff --git a/test/fixers/test_python_fixer_command_callback.vader b/test/fixers/test_python_fixer_command_callback.vader deleted file mode 100644 index 7ee0cafe..00000000 --- a/test/fixers/test_python_fixer_command_callback.vader +++ /dev/null @@ -1,58 +0,0 @@ -Before: - silent! execute 'cd /testplugin/test/command_callback' - let g:dir = getcwd() - -After: - " Set the file to something else, - " or we'll cause issues when running other tests - silent file 'dummy.py' - unlet! g:dir - -Execute(The python GetExecutable callbacks should return the correct path): - AssertEqual - \ '', - \ ale#python#GetExecutable(bufnr(''), 'isort') - - silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py') - AssertEqual - \ g:dir . '/python_paths/with_virtualenv/env/bin/isort', - \ ale#python#GetExecutable(bufnr(''), 'isort') - AssertEqual - \ g:dir . '/python_paths/with_virtualenv/env/bin/autopep8', - \ ale#python#GetExecutable(bufnr(''), 'autopep8') - AssertEqual - \ g:dir . '/python_paths/with_virtualenv/env/bin/yapf', - \ ale#python#GetExecutable(bufnr(''), 'yapf') - - -Execute(The autopep8 callbacks should return the correct default values): - AssertEqual - \ 0, - \ ale#fixers#autopep8#Fix(bufnr('')) - - silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py') - AssertEqual - \ {'command': "'" . g:dir . "/python_paths/with_virtualenv/env/bin/autopep8' -" }, - \ ale#fixers#autopep8#Fix(bufnr('')) - - -Execute(The isort callbacks should return the correct default values): - AssertEqual - \ 0, - \ ale#fixers#isort#Fix(bufnr('')) - - silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py') - AssertEqual - \ {'command': "'" . g:dir . "/python_paths/with_virtualenv/env/bin/isort' -" }, - \ ale#fixers#isort#Fix(bufnr('')) - - -Execute(The yapf callbacks should return the correct default values): - AssertEqual - \ 0, - \ ale#fixers#yapf#Fix(bufnr('')) - - silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py') - AssertEqual - \ {'command': "'" . g:dir . "/python_paths/with_virtualenv/env/bin/yapf' --no-local-style" }, - \ ale#fixers#yapf#Fix(bufnr('')) diff --git a/test/fixers/test_yapf_fixer_callback.vader b/test/fixers/test_yapf_fixer_callback.vader new file mode 100644 index 00000000..0b88e4d8 --- /dev/null +++ b/test/fixers/test_yapf_fixer_callback.vader @@ -0,0 +1,29 @@ +Before: + Save g:ale_python_yapf_executable + + " Use an invalid global executable, so we don't match it. + let g:ale_python_yapf_executable = 'xxxinvalid' + + silent! execute 'cd /testplugin/test/command_callback' + silent cd .. + silent cd command_callback + let g:dir = getcwd() + +After: + Restore + + silent execute 'cd ' . fnameescape(g:dir) + " Set the file to something else, + " or we'll cause issues when running other tests + silent file 'dummy.py' + unlet! g:dir + +Execute(The yapf callback should return the correct default values): + AssertEqual + \ 0, + \ ale#fixers#yapf#Fix(bufnr('')) + + silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py') + AssertEqual + \ {'command': "'" . g:dir . "/python_paths/with_virtualenv/env/bin/yapf' --no-local-style" }, + \ ale#fixers#yapf#Fix(bufnr('')) |