Configurando o VSCode

Extensões

Instale as seguintes extensões:

  • Python
  • Python Debugger
  • Pylance
  • Pylint
  • Black Formatter
  • Material Icon

Settings

Crie o arquivo .vscode/settings.json com o seguinte conteúdo:

{
    "black-formatter.args": [
        "–line-length",
        "120"
    ],
    "workbench.colorCustomizations": {
        "scrollbarSlider.background": "#00ff5140",
    },
    "editor.codeActionsOnSave": {"source.sortImports": "explicit"}, // Organize imports
    "editor.defaultFormatter": "ms-python.black-formatter", // formatter 
    "editor.fontFamily": "Fira Code", // My Font
    "editor.fontLigatures": true, // enabled ligatures
    "editor.fontSize": 12, // Font size
    "editor.formatOnPaste": true, // text will format on pasting the code
    "editor.formatOnSave": true, // text will format if you hit ctrl + S
    "editor.minimap.enabled": false, // disabled minimap
    "debug.terminal.clearBeforeReusing": true, // clears your debug terminal before using
    "files.autoSave": "afterDelay", // Save automatic
    "[python]": {
        "editor.rulers": [
            {
                "column": 80,
                "color": "#95eb80"
            },
            {
                "column": 100,
                "color": "#ffae00"
            },
            {
                "column": 120,
                "color": "#ff0000"
            },
        ],
        }, // Visual column line 
    "pylint.args": ["Enabled=True",], // Code analyser with pep8
    "python.testing.pytestArgs": ["tests"], // Arguments to tests
    "python.testing.unittestEnabled": false, // Arguments to tests
    "python.testing.pytestEnabled": true, // Arguments to tests
    "terminal.integrated.fontFamily": "MesloLGS Nerd Font", // terminal font to use icons
    "terminal.integrated.fontSize": 12, // terminal font size
    "workbench.colorTheme": "Andromeda Mariana", // My Theme
    "workbench.iconTheme": "material-icon-theme", // My Icon Theme
  }

Launch

Crie o arquivo .vscode/launch.json com o seguinte conteúdo:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: FastAPI",
            "type": "debugpy",
            "request": "launch",
            "module": "uvicorn",
            "args": [
                "app.main:app",
                "–port", "8888"
            ],
            "jinja": true,
            "justMyCode": true
        },
        {
            "name": "PyTest",
            "type": "debugpy",
            "request": "launch",
            "stopOnEntry": false,
            "module": "pytest",
            "args": [
                "-sv"
            ]
        },
        {
            "name": "Current",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": true,
            "args": [
                ""
            ]
        },
    ]
}

Conclusão

É muito fácil personalizar e configurar o VsCode.

Espero que possa, de alguma forma, ser útil a outros também.

Fontes de referência

Diversas na internet.

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *