The following is a brief guide to reinstalling/setting up Visual Studio Code (VSC) on a new Linux system. The main use is Python development. As such, it is very brief and mostly for my own documentation.
Install VSC
sudo snap install --classic code
Install Python packages
! DO THIS OUTSIDE OF AN ACTIVE VIRTUAL ENVIRONMENT !
- linting (flake8):
python -m pip install pyflakes pycodestyle mccabe flake8
- Refactoring (rope):
python -m pip install rope
- Formatting (Yapf):
python -m pip install yapf
- Type checking (mypy):
python -m pip install -U mypy --user
- Flake8 Bugbear:
python -m pip install flake8-bugbear
, then check if installed withflake8 --version
(should include flake8-bugbear) - Sphinx/RST support:
python -m pip install doc8 rstcheck sphinx-autobuild
- Snooty languageserver:
python -m pip install snooty-lextudio
Install and configure plugins
- ms-python.python
- Micropy
- Set up and configure YAPF (separate post)
- Gitlens
- Autodocstring
- Convert to snippet
- Set up Sourcery (separate post)
- Set up/configure MarkDown
- lextudio.restructuredtext
- Set up and configure for Sphinx
Select interpreter
Add
"python.pythonPath": "/usr/bin/python3",
to $HOME
/.config/Code/User/settings.json
Set up linting
List of possible linters and how to configure them
Open user settings and
- set
Python > linting: flake8 path
, toC:\Python39\Scripts\flake8.exe
- Add
max-line-length=99
to Python > Linting: Flake8 Args - Enable flake8
or add
"python.linting.flake8Path": "C:\\Python39\\Scripts\\flake8.exe",
"python.linting.flake8Args": [
"max-line-length=99"
],
"python.linting.flake8Enabled": true,
to %APPDATA%\Code\User\settings.json
(Windows) or $HOME/.config/Code/User/settings.json
(Linux)
MyPy:
- Install package
python -m pip install -U mypy --user
- Enable
"python.linting.mypyEnabled": true,
"python.linting.mypyArgs": [],
"python.analysis.typeCheckingMode" :"basic",
"python.linting.mypyPath": "C:\\Users\\dieterv\\AppData\\Roaming\\Python\\Python39\\Scripts\\mypy.exe",
to ~/.config/Code/User/settings.json
Autodocstring
Add the following to your settings.json
"autoDocstring.docstringFormat": "google",
"autoDocstring.guessTypes": true,
"autoDocstring.generateDocstringOnEnter": true,
"autoDocstring.includeExtendedSummary": true,
"autoDocstring.quoteStyle": "\"\"\"",