Add PyLS linter (#1097)

* Support PyLS (python language server)
* Replace pyls#GetProjectRoot and add more config types to ale#python#FindProjectRoot
This commit is contained in:
Auri 2017-11-08 19:58:56 +02:00 committed by w0rp
parent 86e8074017
commit 8a4cf923a8
5 changed files with 35 additions and 2 deletions

View File

@ -126,7 +126,7 @@ formatting.
| Pod | [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) | | Pod | [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) |
| Pug | [pug-lint](https://github.com/pugjs/pug-lint) | | Pug | [pug-lint](https://github.com/pugjs/pug-lint) |
| Puppet | [puppet](https://puppet.com), [puppet-lint](https://puppet-lint.com) | | Puppet | [puppet](https://puppet.com), [puppet-lint](https://puppet-lint.com) |
| 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/), [pycodestyle](https://github.com/PyCQA/pycodestyle), [pylint](https://www.pylint.org/) !!, [yapf](https://github.com/google/yapf) | | 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/), [pycodestyle](https://github.com/PyCQA/pycodestyle), [pyls](https://github.com/palantir/python-language-server), [pylint](https://www.pylint.org/) !!, [yapf](https://github.com/google/yapf) |
| R | [lintr](https://github.com/jimhester/lintr) | | R | [lintr](https://github.com/jimhester/lintr) |
| ReasonML | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-integration-reason-merlin` for configuration instructions, [refmt](https://github.com/reasonml/reason-cli) | | ReasonML | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-integration-reason-merlin` for configuration instructions, [refmt](https://github.com/reasonml/reason-cli) |
| reStructuredText | [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) | | reStructuredText | [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) |

View File

@ -0,0 +1,21 @@
" Author: aurieh <me@aurieh.me>
" Description: A language server for Python
call ale#Set('python_pyls_executable', 'pyls')
function! ale_linters#python#pyls#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'python_pyls_executable')
endfunction
function! ale_linters#python#pyls#GetLanguage(buffer) abort
return 'python'
endfunction
call ale#linter#Define('python', {
\ 'name': 'pyls',
\ 'lsp': 'stdio',
\ 'executable_callback': 'ale_linters#python#pyls#GetExecutable',
\ 'command_callback': 'ale_linters#python#pyls#GetExecutable',
\ 'language_callback': 'ale_linters#python#pyls#GetLanguage',
\ 'project_root_callback': 'ale#python#FindProjectRoot',
\})

View File

@ -18,6 +18,8 @@ function! ale#python#FindProjectRootIni(buffer) abort
\|| filereadable(l:path . '/setup.cfg') \|| filereadable(l:path . '/setup.cfg')
\|| filereadable(l:path . '/pytest.ini') \|| filereadable(l:path . '/pytest.ini')
\|| filereadable(l:path . '/tox.ini') \|| filereadable(l:path . '/tox.ini')
\|| filereadable(l:path . '/pycodestyle.cfg')
\|| filereadable(l:path . '/flake8.cfg')
return l:path return l:path
endif endif
endfor endfor

View File

@ -189,6 +189,15 @@ g:ale_python_pylint_use_global *g:ale_python_pylint_use_global*
See |ale-integrations-local-executables| See |ale-integrations-local-executables|
===============================================================================
pyls *ale-python-pyls*
g:ale_python_pyls_executable *g:ale_python_pyls_executable*
*b:ale_python_pyls_executable*
Type: |String|
Default: `pyls`
See |ale-integrations-local-executables|
=============================================================================== ===============================================================================
yapf *ale-python-yapf* yapf *ale-python-yapf*

View File

@ -145,6 +145,7 @@ CONTENTS *ale-contents*
mypy................................|ale-python-mypy| mypy................................|ale-python-mypy|
pycodestyle.........................|ale-python-pycodestyle| pycodestyle.........................|ale-python-pycodestyle|
pylint..............................|ale-python-pylint| pylint..............................|ale-python-pylint|
pyls................................|ale-python-pyls|
yapf................................|ale-python-yapf| yapf................................|ale-python-yapf|
r.....................................|ale-r-options| r.....................................|ale-r-options|
lintr...............................|ale-r-lintr| lintr...............................|ale-r-lintr|
@ -309,7 +310,7 @@ Notes:
* Pod: `proselint`, `write-good` * Pod: `proselint`, `write-good`
* Pug: `pug-lint` * Pug: `pug-lint`
* Puppet: `puppet`, `puppet-lint` * Puppet: `puppet`, `puppet-lint`
* Python: `autopep8`, `flake8`, `isort`, `mypy`, `pycodestyle`, `pylint`!!, `yapf` * Python: `autopep8`, `flake8`, `isort`, `mypy`, `pycodestyle`, `pyls`, `pylint`!!, `yapf`
* R: `lintr` * R: `lintr`
* ReasonML: `merlin`, `refmt` * ReasonML: `merlin`, `refmt`
* reStructuredText: `proselint`, `write-good` * reStructuredText: `proselint`, `write-good`