Updated VS Code (markdown)
parent
f14c898a07
commit
f5778336cb
58
VS-Code.md
58
VS-Code.md
|
@ -2,3 +2,61 @@ Visual Studio Code, also commonly referred to as VS Code, is a source-code edito
|
|||
|
||||
In the Stack Overflow 2022 Developer Survey, Visual Studio Code was ranked the most popular developer environment tool among 71,010 respondents, with 74.48% reporting that they use it.
|
||||
|
||||
While there isn't an official plugin for micropython, the official python plugins can be set up to be quite helpful, devcontainer support can be used to make compilation easier and the built in terminal can be used to communicate with your board via mpremote etc.
|
||||
|
||||
# VS Code settings & Python plugin
|
||||
All project-specific vscode settings are stored in a `<myproject>/.vscode/settings.json` file which can be editing manually, or via the gui settings editor in vscode.
|
||||
|
||||
I like to structure my project such that the top level folder has things like readme, tool config files like pyproject.toml, Makefiles, .devcontainer etc.
|
||||
I then have a `src` folder which contains a `firmware` folder with my project `.py` files and a `lib` folder with any external libraries I bring in.
|
||||
These folders can be listed in the settings `extraPaths` so that the python plugin find and uses them.
|
||||
|
||||
It also helps to get a copy of micropython stubs to assist with type hinting (and mypy). Pick the [appropriate platform for you project](https://micropython-stubs.readthedocs.io/en/latest/firmware_grp.html) and [install a copy](https://micropython-stubs.readthedocs.io/en/latest/20_using.html#install-into-a-typings-folder) to `<myproject>/tools/typing` or similar:
|
||||
```
|
||||
pip install -U micropython-stm32-stubs==1.20.* --target ./tools/typings --no-user
|
||||
```
|
||||
This can then be referenced in the settings file below.
|
||||
|
||||
Here's a copy of my `.vscode/settings.json` files:
|
||||
``` json
|
||||
{
|
||||
"python.linting.enabled": true,
|
||||
"python.languageServer": "Pylance",
|
||||
"python.analysis.typeCheckingMode": "basic",
|
||||
"python.analysis.diagnosticSeverityOverrides": {
|
||||
"reportMissingModuleSource": "none"
|
||||
},
|
||||
"python.analysis.typeshedPaths": [
|
||||
"tools/typings"
|
||||
],
|
||||
"python.analysis.extraPaths": [
|
||||
"src/firmware",
|
||||
"src/firmware/test",
|
||||
"src/libs",
|
||||
"src/libs/micropython-lib/micropython/aiorepl",
|
||||
"tools/typings"
|
||||
],
|
||||
"python.formatting.provider": "black",
|
||||
// Set line length to 99 to match micropython
|
||||
"python.formatting.blackArgs": [
|
||||
"--line-length",
|
||||
"99"
|
||||
],
|
||||
// pylint doesn't honor extraPaths settings
|
||||
"python.linting.pylintEnabled": false,
|
||||
"python.linting.pylintArgs": [
|
||||
"--disable=W"
|
||||
],
|
||||
"python.linting.flake8Enabled": false,
|
||||
"editor.formatOnSave": true,
|
||||
"editor.formatOnType": true,
|
||||
"files.trimTrailingWhitespace": true,
|
||||
"files.exclude": {
|
||||
"build-*/**": false
|
||||
},
|
||||
"files.insertFinalNewline": true
|
||||
}
|
||||
```
|
||||
|
||||
# devcontainer
|
||||
VS Code [devcontainer](https://code.visualstudio.com/docs/devcontainers/containers) feature allows your coding environment to be hosted inside a docker container, providing all the tools and consistent environment of that docker container, without needing to install everything onto your computer manually.
|
Loading…
Reference in New Issue