1、插件安装
Python
Python Debugger
Django
Black Formatter 或者 Ruff
Project Manager
2、用户配置文件
{
"terminal.integrated.profiles.osx": {
"zsh": {
"path": "/bin/zsh",
"args": [
"-l"
] // “-l” 参数代表以登录Shell模式启动,确保加载配置文件
}
},
"terminal.integrated.defaultProfile.osx": "zsh",
"python.terminal.activateEnvironment": true,
// ===== 代码格式化配置 =====
"editor.formatOnSave": true,
"editor.formatOnPaste": false,
// Python 文件格式化
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.tabSize": 4,
"editor.insertSpaces": true,
"editor.detectIndentation": true,
},
"black-formatter.path": [
"${workspaceFolder}/venv/bin/black"
],
"black-formatter.args": [
"--line-length=110",
"--skip-string-normalization"
],
// ===== 代码检查配置 =====
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"git.ignoreRebaseWarning": true,
"editor.fontSize": 13,
"editor.fontLigatures": false,
"git.untrackedChanges": "separate", // hidden
"python.languageServer": "Jedi",
"files.exclude": {
"**/__pycache__": true,
"**/.pytest_cache": true,
"**/.idea": true,
"**/.vscode": true,
"**/.codebuddy": true
},
"search.exclude": {
"**/__pycache__": true,
"**/.pytest_cache": true,
"**/.idea": true,
"**/.vscode": true,
"**/.codebuddy": true
},
// 内嵌调试配置
"launch": {
"version": "0.2.0",
"configurations": [
{
"name": "Python: Django",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"runserver",
"8001"
// "--noreload"
],
"console": "integratedTerminal",
"django": true,
"justMyCode": false
},
{
"name": "Python: Django Shell", // 新增一个用于交互式Shell的配置
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"shell" // 运行manage.py shell
],
"django": true,
"justMyCode": true,
"console": "integratedTerminal", // 输出到集成终端
// "purpose": [
// "debug-test"
// ], // 明确这个配置的用途
// "stopOnEntry": true // 在启动时暂停,这样可以进入调试控制台
}
]
},
"git.confirmSync": false,
// "python.defaultInterpreterPath": "/usr/local/bin/python3.12",
}