最近使用VS Code学习开发一些小例子,为了避免写Python的时候看到很多Go、Rust的选项,我打算将这三个语言的开发环境按照Profile全部分开,在此记录一下。

创建三个Profile

点击菜单栏文件 -> 首选项 -> 配置文件 -> 创建配置文件,分别创建三个ProfilePython DevGo DevRust Dev。除了键盘快捷方式选择默认,其他都选择对应的Profile名称。

vscode-profile

Python Dev

扩展列表

需要安装的扩展如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
ms-python.vscode-pylance
ms-python.python
ms-python.vscode-python-envs
ms-python.debugpy
charliermarsh.ruff
esbenp.prettier-vscode
vue.volar
dbaeumer.vscode-eslint
fastapilabs.fastapi-vscode
pkief.material-icon-theme
ms-vscode.remote-explorer
ms-vscode-remote.remote-ssh
ms-vscode-remote.remote-ssh-edit
njpwerner.autodocstring
kevinrose.vsc-python-indent
ms-toolsai.vscode-jupyter-slideshow
ms-toolsai.jupyter-keymap
ms-toolsai.vscode-jupyter-cell-tags
ms-toolsai.jupyter-renderers
ms-toolsai.jupyter
eamodio.gitlens
ms-vscode-remote.remote-containers
ms-azuretools.vscode-containers
ms-azuretools.vscode-docker
yzhang.markdown-all-in-one
openai.chatgpt
bazz.uv-manager
tamasfe.even-better-toml

settings.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
{
// 基础编辑器设置

// 关闭辅助功能提示,减少编辑器干扰
"editor.accessibilitySupport": "off",
// 编辑器字体大小
"editor.fontSize": 24,
// 字体优先级
// JetBrainsMono NF 用于终端和代码显示
"editor.fontFamily": "JetBrainsMono NF, MesloLGM Nerd Font Mono,JetBrains Mono, Consolas, monospace",
// 开启字体连字,例如 => != 等符号优化
"editor.fontLigatures": true,
// Ctrl + 鼠标滚轮缩放字体
"editor.mouseWheelZoom": true,
// 超长代码行最大 Token 化长度
"editor.maxTokenizationLineLength": 100000,
// 文件图标主题
"workbench.iconTheme": "material-icon-theme",

// Python / Pylance

// Python 分析日志级别
"python.analysis.logLevel": "Information",
// 类型检查级别
// basic = 平衡性能和检查能力
"python.analysis.typeCheckingMode": "basic",
// 自动 import 补全
"python.analysis.autoImportCompletions": true,
// 开启代码索引
// 大型项目跳转更快
"python.analysis.indexing": true,

// 优先使用 uv 管理虚拟环境
"python-envs.alwaysUseUv": true,
// 工作区搜索虚拟环境
"python-envs.workspaceSearchPaths": [
".venv"
],
// 终端自动激活虚拟环境
"python.terminal.activateEnvironment": true,

// Python 编辑配置
"[python]": {
// 保存自动格式化
"editor.formatOnSave": true,
// 输入时不自动格式化
// 避免补全和 Ruff 冲突
"editor.formatOnType": false,
// Python 使用 Ruff Formatter
"editor.defaultFormatter": "charliermarsh.ruff",
// PEP8 推荐长度
"editor.rulers": [
88
],
// 保存时自动执行代码操作
"editor.codeActionsOnSave": {
// 自动整理 import
"source.organizeImports.ruff": "explicit",
// 自动修复 Ruff 问题
"source.fixAll.ruff": "explicit"
}
},

// 使用 Ruff 原生语言服务器
"ruff.nativeServer": true,

// Python 测试
// 启用 pytest
"python.testing.pytestEnabled": true,
// 禁用 unittest
"python.testing.unittestEnabled": false,
// 默认测试目录
"python.testing.pytestArgs": [
"tests"
],

// Jupyter
// Kernel 重启不询问
"jupyter.askForKernelRestart": false,
// 每个 Python 文件独立交互窗口
// 适合 AI 实验、Embedding、数据分析
"jupyter.interactiveWindow.creationMode": "perFile",

// Web 开发格式化

"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},

"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},

"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},

"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},

"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},

"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},

"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},


// 配置文件格式化

"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},

"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},

"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},

// Markdown 使用专业 Markdown 插件
"[markdown]": {

"editor.defaultFormatter":
"yzhang.markdown-all-in-one",

// 自动换行
"editor.wordWrap": "on"
},

// Markdown 预览支持换行
"markdown.preview.breaks": true,

// Git / GitLens
// 显示当前行 Git 信息
"gitlens.currentLine.enabled": true,
// 关闭 CodeLens
// 避免大型项目性能下降
"gitlens.codeLens.enabled": false,

// GitHub Copilot
// 开启下一步代码建议
"github.copilot.nextEditSuggestions.enabled": true,

// Agent 调试日志关闭
// 需要排查问题时再开启
"github.copilot.chat.agentDebugLog.fileLogging.enabled": false,

// Python Docstring

// Google 风格文档字符串
"autoDocstring.docstringFormat": "google",
// 自动推断类型
"autoDocstring.guessTypes": true,
// 包含参数名称
"autoDocstring.includeName": true,
// 新行开始生成
"autoDocstring.startOnNewLine": true,
// 三引号格式
"autoDocstring.quoteStyle": "\"\"\"",


// =========================================================
// Python 缩进
// =========================================================
// 悬挂缩进使用 Tab
"pythonIndent.useTabOnHangingIndent": true,
// 删除纯空格行
"pythonIndent.trimLinesWithOnlyWhitespace": true,
// =========================================================
// 文件关联
// =========================================================

// EditorConfig 使用 TOML 高亮
"files.associations": {
".editorconfig": "toml"
},

// Windows Terminal

// Windows 默认终端 PowerShell 7
"terminal.integrated.defaultProfile.windows": "PowerShell",
// Windows Terminal 配置
"terminal.integrated.profiles.windows": {
"PowerShell": {
"path":
"C:\\Program Files\\PowerShell\\7\\pwsh.exe"
},
"Command Prompt": {
"path":
[
"${env:windir}\\System32\\cmd.exe"
]
},
"Git Bash": {
"source":
"Git Bash"
}
},
// macOS Terminal
// macOS 默认终端
"terminal.integrated.defaultProfile.osx": "zsh",
// macOS Terminal 配置
"terminal.integrated.profiles.osx": {
// 默认 zsh
"zsh": {
"path": "zsh",
// 登录 shell
"args": [
"-l"
]
},
// bash 备用
"bash": {
"path": "bash",
"args": [
"-l"
]
},
// fish 备用
"fish": {
"path": "fish",
"args": [
"-l"
]
}
},
// Linux 默认 bash
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash": {
"path":
"bash",
"args":
[
"-l"
]
},
"zsh": {
"path":
"zsh",
"args":
[
"-l"
]
}
},

// 文件
"files.watcherExclude": {
"**/.venv/**": true,
"**/__pycache__/**": true,
"**/.pytest_cache/**": true,
"**/.git/**": true,
"**/.idea": true,
"**/node_modules/**": true,
"**/dist/**": true,
"**/build/**": true
}
}

Go Dev

扩展列表

1
2
3
4
5
6
7
8
9
10
11
12
13
14
golang.go
ms-azuretools.vscode-docker
ms-azuretools.vscode-containers
redhat.vscode-yaml
ms-kubernetes-tools.vscode-kubernetes-tools
tim-koehler.helm-intellisense
eamodio.gitlens
ms-vscode.makefile-tools
esbenp.prettier-vscode
dbaeumer.vscode-eslint
tamasfe.even-better-toml
yzhang.markdown-all-in-one
vscode-icons-team.vscode-icons
openai.chatgpt

还需要安装一些工具

1
2
3
4
5
6
7
8
9
10
11
12
# 安装gopls
go install golang.org/x/tools/gopls@latest
# 安装debug 提供强大的调试功能,支持断点、单步执行等
go install github.com/go-delve/delve/cmd/dlv@latest
# 安装Staticcheck
go install honnef.co/go/tools/cmd/staticcheck@latest
# 安装测试生成 自动生成单元测试代码,提高测试效率
go install github.com/cweill/gotests/gotests@latest
# 安装 Tag
go install github.com/fatih/gomodifytags@latest
# 安装interface
go install github.com/josharian/impl@latest

settings.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
{
// 基础编辑器设置
// 关闭辅助功能提示
"editor.accessibilitySupport": "off",

// 编辑器字体大小
"editor.fontSize": 24,

// JetBrains Mono Nerd Font
"editor.fontFamily": "JetBrainsMono NF, MesloLGM Nerd Font Mono, JetBrains Mono, Consolas, monospace",

// 开启字体连字
"editor.fontLigatures": true,

// Ctrl + 滚轮调整字体
"editor.mouseWheelZoom": true,

// 超长代码行支持
"editor.maxTokenizationLineLength": 100000,

// 文件图标
"workbench.iconTheme": "material-icon-theme",
// Go 开发核心
// 使用 Go Language Server
"go.useLanguageServer": true,
// 自动更新 Go 工具
"go.toolsManagement.autoUpdate": true,
// Go 工具安装路径
// 默认使用 GOPATH/bin
"go.toolsManagement.path": "",
// 格式化工具
// 使用 gopls 内置 formatter
"go.formatTool": "default",
// 保存自动格式化
"[go]": {
"editor.formatOnSave": true,
// 保存自动整理 import
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
// Go 文件默认 formatter
"editor.defaultFormatter": "golang.go"
},
// gopls 配置
"gopls": {
// 语义高亮
"ui.semanticTokens": true,
// 自动补全参数
"ui.completion.usePlaceholders": true,
// Inlay Hint
"ui.inlayhint.hints": {
// 结构体字段
"compositeLiteralFields": true,
// 常量值
"constantValues": true,
// 参数名称提示
"parameterNames": true,
// range 类型
"rangeVariableTypes": true,
// 泛型提示
"functionTypeParameters": true
},
// 代码分析
"analyses": {
// 未使用参数
"unusedparams": true,
// 未使用变量
"unusedvariable": true,
// nil 检测
"nilness": true,
// shadow变量检测
"shadow": true,
// unused write
"unusedwrite": true
},
// staticcheck
"staticcheck": true,
// 项目过滤
"build.directoryFilters": [
"-node_modules",
"-vendor",
"-.git"
]
},
// Go Test
// 测试参数
"go.testFlags": [
"-v"
],
// 测试超时时间
"go.testTimeout": "60s",
// CodeLens
"go.enableCodeLens": {
"runtest": true
},

// Go Debug
"go.delveConfig": {
// 使用 DAP 调试协议
"debugAdapter": "dlv-dap",
// 不显示全部变量
"showGlobalVariables": false,
// 不显示寄存器
"showRegisters": false
},
// Golangci-lint
// 企业代码检查
"go.lintTool": "golangci-lint",
"go.lintFlags": [
"--fast"
],

// Git / GitLens
// 当前行提交信息
"gitlens.currentLine.enabled": true,
// 关闭 CodeLens
"gitlens.codeLens.enabled": false,
// GitHub Copilot
"github.copilot.nextEditSuggestions.enabled": true,
"github.copilot.chat.agentDebugLog.fileLogging.enabled": false,

// JSON/YAML/TOML
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[yaml]": {
"editor.defaultFormatter": "redhat.vscode-yaml"
},
"[toml]": {
"editor.defaultFormatter": "tamasfe.even-better-toml"
},

// Markdown
"[markdown]": {
"editor.defaultFormatter": "yzhang.markdown-all-in-one",
"editor.wordWrap": "on"
},

"markdown.preview.breaks": true,

// Docker / Kubernetes 文件
"[dockerfile]": {
"editor.defaultFormatter": "ms-azuretools.vscode-containers"
},

// Terminal Windows
"terminal.integrated.defaultProfile.windows": "PowerShell",
"terminal.integrated.profiles.windows": {
"PowerShell": {
"path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe"
},
"Git Bash": {
"source": "Git Bash"
}
},

// Terminal macOS
"terminal.integrated.defaultProfile.osx": "zsh",
"terminal.integrated.profiles.osx": {
"zsh": {
"path": "zsh",
"args": [
"-l"
]
}
},

// Terminal Linux / WSL
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash": {
"path": "bash",
"args": [
"-l"
]
},
"zsh": {
"path": "zsh",
"args": [
"-l"
]
}
},

// 文件设置
"files.exclude": {
"**/.git": true,
"**/vendor": true,
"**/.idea": true,
"**/node_modules/**": true,
"**/dist/**": true,
"**/build/**": true
}
}

Rust Dev

扩展列表

1
2
3
4
5
6
7
8
9
10
11
12
13
14
openai.chatgpt
eamodio.gitlens
ms-azuretools.vscode-docker
ms-azuretools.vscode-containers
rust-lang.rust-analyzer
tamasfe.even-better-toml
yzhang.markdown-all-in-one
esbenp.prettier-vscode
dbaeumer.vscode-eslint
vue.volar
pkief.material-icon-theme
vadimcn.vscode-lldb
fill-labs.dependi
usernamehw.errorlens

settings.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
{
// 基础编辑器
// 关闭辅助功能提示
"editor.accessibilitySupport": "off",
// 编辑器字体
"editor.fontSize": 24,
// JetBrainsMono Nerd Font
"editor.fontFamily": "JetBrainsMono NF, MesloLGM Nerd Font Mono, JetBrains Mono, Consolas, monospace",
// 开启符号连字
"editor.fontLigatures": true,
// Ctrl + 鼠标滚轮调整字体
"editor.mouseWheelZoom": true,
// 超长代码支持
"editor.maxTokenizationLineLength": 100000,
// 文件图标
"workbench.iconTheme": "material-icon-theme",

// Rust Analyzer

// Rust Analyzer 扩展
"rust-analyzer.check.command": "clippy",

// 保存时检查
"rust-analyzer.checkOnSave": true,

// 自动导入
"rust-analyzer.imports.granularity.group": "module",

// 自动合并 use
"rust-analyzer.imports.merge.glob": true,

// 自动补全
"rust-analyzer.completion.autoimport.enable": true,

// 内联提示
"rust-analyzer.inlayHints.bindingModeHints.enable": true,
"rust-analyzer.inlayHints.closureReturnTypeHints.enable": "always",
"rust-analyzer.inlayHints.parameterHints.enable": true,
"rust-analyzer.inlayHints.typeHints.enable": true,
// Rust 格式化
"[rust]": {
// 保存自动格式化
"editor.formatOnSave": true,
// rustfmt
"editor.defaultFormatter": "rust-lang.rust-analyzer",
// 保存执行 clippy 修复
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
},
// Cargo
// Cargo 自动检测
"rust-analyzer.cargo.autoreload": true,

// 默认 feature 全开
"rust-analyzer.cargo.features": "all",
// 构建所有 target
"rust-analyzer.cargo.buildScripts.enable": true,

// Windows PowerShell 7
"terminal.integrated.defaultProfile.windows": "PowerShell",
"terminal.integrated.profiles.windows": {
"PowerShell": {
"path":
"C:\\Program Files\\PowerShell\\7\\pwsh.exe"
},
"Git Bash": {
"source": "Git Bash"
},
"Command Prompt": {
"path":
"${env:windir}\\System32\\cmd.exe"
}
},
// macOS
"terminal.integrated.defaultProfile.osx": "zsh",
"terminal.integrated.profiles.osx": {
"zsh": {
"path": "zsh",
"args": [
"-l"
]
},
"bash": {
"path": "bash",
"args": [
"-l"
]
}
},
// Linux / WSL
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash": {
"path": "bash",
"args": [
"-l"
]
},
"zsh": {
"path": "zsh",
"args": [
"-l"
]
}
},
// Git
// GitLens 当前行信息
"gitlens.currentLine.enabled": true,
// 关闭 CodeLens
"gitlens.codeLens.enabled": false,
// GitHub Copilot
"github.copilot.nextEditSuggestions.enabled": true,
"github.copilot.chat.agentDebugLog.fileLogging.enabled": false,
// 文件管理
// 自动保存
"files.autoSave": "afterDelay",
// 排除 Rust 编译目录
"files.watcherExclude": {
"**/target/**": true,
"**/.git/**": true,
"**/.idea": true,
"**/node_modules/**": true,
"**/dist/**": true,
"**/build/**": true
},
"editor.linkedEditing": true
}

更新记录