Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to correctly enable pylint with ALE in Vim?

I want to set up python linting in Vim using the ALE Vim-package. So far it works well in Atom using the Atom-Plugin, but in Vim it somehow is not working. I installed

  • pylint using pip3,
  • Vim 8.1 and
  • ALE using the Vundle Plugin-Manager.

In my .vimrc I set the

let g:ale_linters={
'python': ['pylint'],
.....+other languages....
}

option. Additionally I read the ALE docs and also tried setting the following:

let g:ale_python_executable='python3'
let g:ale_python_pylint_use_global=1

ALE gets installed correctly and works for Javascript, but for Python, there is just nothing happening. In case of incorrect code (missing ")") like:

print("Hi"

nothing is marked as error.

It would be great if someone knows how to set this up and can provide some help! Thanks.

like image 264
avermaet Avatar asked Jun 15 '19 22:06

avermaet


1 Answers

I was able to get this working, with the following steps:

  1. install pylint

    python3 -m pip install pylint

    At least for my setup there was a warning:

    Installing collected packages: pylint

    WARNING: The scripts epylint, pylint, pyreverse and symilar are installed in '/home/vagrant/.local/bin' which is not on PATH.

    so then:

  2. Add pylint to $PATH

    export PATH="$HOME/.local/bin:$PATH"

    (this can be added to ~/.profile to be configured persistently)

    At you should be able to run pylint manually:

    $ cat syntaxerr.py
    print("hi
    $ pylint syntaxerr.py
    ************* Module syntaxerr
    syntaxerr.py:1:10: E0001: EOL while scanning string literal (, line 1) (syntax-error)
    
  3. Install ALE

    git clone https://github.com/dense-analysis/ale.git ~/.vim/pack/git-plugins/start/ale

At this point the syntax check is working as long as syntax is enabled:

$ cat .vimrc
syntax on

If you'd like to configure g:ale_linters, note that you must escape the newline to create a multi-line dictionary:

let g:ale_linters={
\ 'python': ['pylint'],
\}

Finally, to see how ALE is currently configured, you can always run the following command:

:ALEInfo
like image 78
Razzi Abuissa Avatar answered Nov 13 '22 22:11

Razzi Abuissa