{ // ——— 工作區 VS Code 設定 ——— // 需安裝擴充(建議): // 1) charliermarsh.ruff → Python 格式化 + 匯入排序 + Lint/修復 // 2) ms-python.python → Python 語言支援、測試、偵錯、終端環境 // 3) ms-python.vscode-pylance → 型別分析/智慧提示(使用 Pylance) // 4) ms-toolsai.jupyter →(可選)Notebook 支援 // 也可直接接受工作區推薦(.vscode/extensions.json) // 檔案總管把雜物藏起來,乾淨一點 "files.exclude": { "**/.git": true, "**/.svn": true, "**/.hg": true, "**/CVS": true, "**/__pycache__": true, "**/.DS_Store": true }, // 不愛被一直彈參數提示,關掉就清爽 "editor.parameterHints.enabled": false, // 字型&連字:看起來順眼一點 "editor.fontFamily": "JetBrainsMono Nerd Font Mono", "editor.fontLigatures": true, // 介面縮放:0 就是原尺寸,自己再調 "window.zoomLevel": 0, // 存檔只格式化實際修改的區塊(減少整檔 diff) "editor.formatOnSaveMode": "modificationsIfAvailable", // 若未安裝 Code Runner,避免未知設定警告:先移除相關設定 // 版面微調:全域用空白縮排,預設 2 格;換行一律 LF "editor.insertSpaces": true, "editor.tabSize": 2, "files.eol": "\n", "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true, // 專案行寬 100 欄(與 Ruff 設定一致) "editor.rulers": [100], // 使用 Ruff:Lint + 匯入排序 + 格式化(見 ruff.toml) // Python 語言專屬設定 "[python]": { // 以 Ruff 當預設格式器 "editor.defaultFormatter": "charliermarsh.ruff", // 存檔:格式化 + 自動修復 + 匯入排序 "editor.formatOnSave": true, // 交給 Ruff 做自動修復與匯入排序(避免與 isort 重疊) "editor.codeActionsOnSave": { "source.fixAll.ruff": "explicit", "source.organizeImports.ruff": "explicit" }, // Python 習慣 4 空白縮排 "editor.tabSize": 4 }, // Pylance/分析:全專案診斷(型別等級改由 pyrightconfig.json 管理) "python.analysis.diagnosticMode": "workspace", "python.terminal.activateEnvironment": true, // 指定預設的工作區 Interpreter(本機虛擬環境) "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python", // 若需調整 Pylance 型別檢查或診斷嚴重度,請至 pyrightconfig.json // 測試(若使用 pytest):VS Code 直接偵測測試並執行 "python.testing.pytestEnabled": true, "python.testing.unittestEnabled": false, "python.testing.pytestArgs": ["tests"], // 搜尋/監控忽略更多常見產物與虛擬環境 "search.exclude": { "**/node_modules": true, "**/bower_components": true, "**/.venv": true, "**/venv": true, "**/.tox": true, "**/.mypy_cache": true, "**/.pytest_cache": true, "**/.ruff_cache": true, "**/dist": true, "**/build": true }, "search.useIgnoreFiles": true, "files.watcherExclude": { "**/node_modules/**": true, "**/.venv/**": true, "**/venv/**": true, "**/.tox/**": true, "**/.git/**": true } }