At work we use VS Code but if possible I would prefer not to use that on my work station at home. Since I’ve been apt purging nano for ages I started looking for a way to do this with Vim. In the end it turned out to be quite simple on my Debian Bookworm install.
Prerequisites
You will need the following packages:
- vim
- flake8
- python3-pylsp
- vim-ale
Install them with sudo apt install vim flake8 python3-pylsp vim-ale
.
Configuration
Add the following lines to your .vimrc
and you should be good to go!
packadd! ale
let g:ale_completion_enabled = 1
let g:ale_linters = {'python': ['pylsp']}
On Ubuntu the situation is a bit different, the linter to add for autocompletion is called pyls
but the executable is called pylsp
. So to have ALE load the correct executable some extra configuration is needed.
packadd! ale
let g:ale_completion_enabled = 1
let g:ale_linters = {'python': ['pyls']}
let g:ale_python_pyls_executable = 'pylsp'
Todo: Check if flake8 dependency is really needed.