通用工作区配置

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
{
// 编辑器基础配置
"editor.tabSize": 4, // tab缩进大小,设置为4个空格宽度
"editor.insertSpaces": true, // 插入空格而非tab字符,按tab键时插入空格
"editor.detectIndentation": false, // 禁用自动检测缩进,使用统一的缩进设置
"editor.formatOnSave": true, // 保存时自动格式化,保存文件时自动整理代码格式
"editor.formatOnPaste": true, // 粘贴时自动格式化,粘贴代码时自动调整格式
"editor.formatOnType": true, // 输入时自动格式化,输入特定字符时自动格式化

// 终端环境
"terminal.integrated.env.osx": {},
"terminal.integrated.env.linux": {},
"terminal.integrated.env.windows": {},

// 文件保存处理
"files.trimTrailingWhitespace": true, // 保存时删除行尾空格,清理多余的空白字符
"files.insertFinalNewline": true, // 文件末尾插入空行,符合unix文件规范
"files.trimFinalNewlines": true, // 删除文件末尾多余空行,保持文件整洁

// 文件监控排除
"files.watcherExclude": {
"**/.git/objects/**": true, // 排除git对象目录,减少文件监控开销
"**/node_modules/**": true, // 排除node模块目录,避免监控大量依赖文件
"**/dist/**": true, // 排除构建输出目录,不监控编译生成的文件
"**/build/**": true, // 排除构建目录,不监控构建产物
"**/.next/**": true, // 排除Next.js构建目录,不监控Next.js编译文件
"**/.venv/**": true, // 排除python虚拟环境,避免监控虚拟环境文件
"**/venv/**": true, // 排除python虚拟环境(另一种命名),避免监控虚拟环境文件
"**/vendor/**": true, // 排除php依赖目录,不监控第三方库文件
"**/.gradle/**": true, // 排除gradle缓存目录,不监控gradle构建缓存
"**/target/**": true // 排除maven构建目录,不监控maven编译产物
},

// 文件搜索排除
"search.exclude": {
"**/node_modules": true, // 搜索时排除node模块,提高搜索速度
"**/dist": true, // 搜索时排除构建输出,不搜索编译后的文件
"**/build": true, // 搜索时排除构建目录,不搜索构建产物
"**/.next": true, // 搜索时排除Next.js目录,不搜索Next.js编译文件
"**/coverage": true, // 搜索时排除测试覆盖率目录,不搜索覆盖率报告
"**/.venv": true, // 搜索时排除python虚拟环境,不搜索虚拟环境文件
"**/venv": true, // 搜索时排除python虚拟环境(另一种命名)
"**/vendor": true, // 搜索时排除php依赖,不搜索第三方库
"**/.git": true, // 搜索时排除git目录,不搜索版本控制文件
"**/target": true // 搜索时排除maven构建目录,不搜索编译产物
},

// unicode字符处理
"editor.unicodeHighlight.ambiguousCharacters": false, // 去除中文字符警告,不高亮显示易混淆的unicode字符
"editor.unicodeHighlight.invisibleCharacters": false // 不高亮不可见字符,避免零宽字符等特殊字符的警告
}

java工作区配置文件

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
{
// maven配置
"maven.executable.options": "D:\\java\\apache-maven-3.8.4\\bin\\mvn", // maven可执行文件路径,指定maven命令的位置
"java.configuration.maven.userSettings": "D:\\java\\apache-maven-3.8.4\\conf\\settings.xml", // maven用户配置文件路径,指定settings.xml的位置用于配置仓库和镜像

// 代码补全与提示
"java.completion.chain.enabled": true, // 启用链式方法补全,支持连续调用方法的智能提示
"java.completion.matchCase": "off", // 补全时不区分大小写,输入小写也能匹配大写开头的类名
"java.signatureHelp.description.enabled": true, // 方法签名帮助显示描述,显示方法参数的详细说明
"java.dependency.showMembers": true, // 显示类成员,在依赖视图中展示类的字段和方法

// 调试与日志
"java.debug.logLevel": "error", // 调试器日志级别,只显示错误级别的调试信息
"java.errors.incompleteClasspath.severity": "ignore", // 类路径不完整时忽略错误,不提示classpath缺失警告

// 编辑器配置
"[java]": {
"editor.defaultFormatter": "redhat.java", // 默认格式化工具,使用redhat的java插件格式化代码
"editor.suggest.snippetsPreventQuickSuggestions": false // 快速建议不阻止片段提示,代码片段和智能提示可以同时显示
},

// gradle支持
"java.import.gradle.enabled": false, // 禁用gradle导入,不自动导入gradle项目
"java.import.gradle.wrapper.enabled": false, // 禁用gradle wrapper支持,不使用gradle wrapper构建

// 高亮与jdk
"java.semanticHighlighting.enabled": true, // 语法高亮,启用基于语义的代码着色
"java.jdk.ls.java.home": "D:\\java\\jdk-17", // language server使用的jdk,指定java语言服务器运行的jdk版本
"java.configuration.runtimes": [
{
"name": "JavaSE-1.8", // 运行时名称,标识java8运行环境
"path": "D:\\java\\jdk-8", // jdk路径,指定java8的安装位置
"default": true // 默认运行时,设置为项目默认使用的jdk版本
}
],
"java.home": "D:\\java\\jdk-17", // 默认jdk,全局默认使用的jdk路径

// 文件排除
"files.exclude": {
"**/.classpath": true, // 隐藏eclipse的classpath文件,不在资源管理器中显示
"**/.project": true, // 隐藏eclipse的project文件,不显示项目配置文件
"**/.settings": true, // 隐藏eclipse的settings目录,不显示ide配置
"**/.factorypath": true // 隐藏eclipse的factorypath文件,不显示注解处理器配置
}
}

golang工作区配置文件

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
{
"[go]": {
// 缩进和格式化
"editor.insertSpaces": false, // 使用tab而不是空格,go语言标准使用tab缩进
"editor.formatOnSave": true, // 保存时自动格式化,保存时运行gofmt格式化代码
"editor.formatOnType": true, // 输入时自动格式化,输入特定字符时自动调整格式

// 组织导入
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit" // 保存时自动整理导入,自动添加缺失和删除未使用的import
},

// 代码提示
"editor.suggest.snippetsPreventQuickSuggestions": false // 不阻止快速片段提示,代码片段和智能提示可以同时显示
},

// go工具链路径(可选)
// "go.gopath": "${workspaceFolder}/.go", // 工作区gopath,指定当前项目的gopath路径
"go.useLanguageServer": true, // 启用gopls,使用官方的go语言服务器提供智能提示
"go.formatTool": "gofmt", // 默认格式化工具,使用gofmt格式化go代码
// "go.lintTool": "golangci-lint", // 默认linter,使用golangci-lint进行代码检查
// "go.buildOnSave": "package", // 保存时构建当前包,保存文件时编译当前package
// "go.testOnSave": true, // 保存时自动运行测试,保存文件时执行单元测试

// 禁用旧工具的安装提示
"go.toolsManagement.autoUpdate": false, // 禁用自动更新工具,不自动更新go工具链
"go.toolsManagement.checkForUpdates": "off", // 关闭工具更新检查,不检查工具是否有新版本

// 禁用除gopls外的所有工具
"go.alternateTools": {
"go": "", // 禁用go命令,不使用额外的go命令
"go-outline": "", // 禁用go-outline,不使用文档大纲工具
"gopkgs": "", // 禁用gopkgs,不使用包列表工具
"guru": "", // 禁用guru,不使用代码导航工具
"gorename": "", // 禁用gorename,不使用重命名工具
"gotests": "", // 禁用gotests,不使用测试生成工具
"gomodifytags": "", // 禁用gomodifytags,不使用结构体标签修改工具
"impl": "", // 禁用impl,不使用接口实现生成工具
"fillstruct": "", // 禁用fillstruct,不使用结构体填充工具
"goplay": "", // 禁用goplay,不使用go playground工具
"godoctor": "", // 禁用godoctor,不使用重构工具
"godef": "", // 禁用godef,不使用定义跳转工具
"goreturns": "", // 禁用goreturns,不使用导入和格式化工具
"golint": "", // 禁用golint,不使用代码风格检查工具
"dlv": "", // 禁用dlv,不使用delve调试器
"staticcheck": "" // 禁用staticcheck,不使用静态分析工具
}
}

python工作区配置文件

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
{
// python解释器
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python", // 默认解释器路径,指定项目使用的python虚拟环境
"python.analysis.extraPaths": ["${workspaceFolder}/.venv/lib/python3.10/site-packages"], // 模块搜索路径,添加额外的包搜索目录

// 代码分析
"python.analysis.logLevel": "Error", // 分析日志级别,只显示错误级别的分析日志
"python.analysis.autoSearchPaths": true, // 自动搜索自定义模块路径,自动查找项目中的python模块
"python.analysis.completeFunctionParens": true, // 自动补全括号,补全函数名时自动添加括号
"python.analysis.autoImportCompletions": true, // 自动导入缺失模块,补全时自动添加import语句
"python.analysis.typeCheckingMode": "off", // 类型检查模式,关闭类型检查以提高性能
"python.analysis.useLibraryCodeForTypes": true, // 使用第三方库类型信息,从库代码中推断类型
"python.analysis.indexing": false, // 禁用索引加快启动,不建立代码索引以加快启动速度
"python.analysis.importFormat": "absolute", // 使用绝对路径导入,import语句使用绝对路径而非相对路径
"python.analysis.inlayHints.variableTypes": true, // 显示变量类型提示,在编辑器中显示变量的类型信息
"python.analysis.inlayHints.functionReturnTypes": true, // 显示函数返回值类型提示,在编辑器中显示函数返回类型

// 终端环境
"terminal.integrated.env.osx": {
"PYTHONPATH": "${workspaceFolder}", // 设置pythonpath环境变量,将项目根目录添加到模块搜索路径
"PYTHONDONTWRITEBYTECODE": "1" // 禁止生成pyc文件,不生成字节码缓存文件
},
"terminal.integrated.env.windows": {
"PYTHONPATH": "${workspaceFolder}", // 设置pythonpath环境变量,将项目根目录添加到模块搜索路径
"PYTHONDONTWRITEBYTECODE": "1" // 禁止生成pyc文件,不生成字节码缓存文件
},
"terminal.integrated.env.linux": {
"PYTHONPATH": "${workspaceFolder}", // 设置pythonpath环境变量,将项目根目录添加到模块搜索路径
"PYTHONDONTWRITEBYTECODE": "1" // 禁止生成pyc文件,不生成字节码缓存文件
},

// 编辑器配置
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8", // 默认格式化工具,使用autopep8格式化python代码
"editor.formatOnType": true, // 输入时自动格式化,输入特定字符时自动调整格式
"editor.formatOnSave": true // 保存时自动格式化,保存文件时自动整理代码格式
},

// linting
"python.linting.enabled": true, // 启用代码检查,开启python代码质量检查
"python.linting.pylintEnabled": true, // 启用pylint,使用pylint进行代码规范检查
"python.linting.mypyEnabled": true // 启用mypy,使用mypy进行类型检查
}

php工作区配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
// php可执行文件路径
"php.validate.executablePath": "D:\\php\\php.exe", // php可执行文件路径,指定php命令的位置

// php代码检查
"php.validate.enable": true, // 启用php代码验证,开启语法错误检查
"php.suggest.basic": true, // 启用基础代码建议,提供基本的代码补全功能

// php格式化(需安装php intelephense插件)
"[php]": {
"editor.defaultFormatter": "bmewburn.vscode-intelephense-client", // 默认格式化工具,使用intelephense格式化php代码
"editor.formatOnSave": true // 保存时自动格式化,保存文件时自动整理代码格式
},

// 文件排除
"files.exclude": {
"**/vendor": true, // 隐藏composer依赖目录,不在资源管理器中显示第三方库
"**/.phpunit": true // 隐藏phpunit缓存目录,不显示测试框架缓存文件
}
}

前端工作区配置文件

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
{
// 编辑器缩进
"editor.tabSize": 4, // tab缩进大小,设置为4个空格宽度
"editor.insertSpaces": true, // 插入空格而非tab字符,按tab键时插入空格
"editor.detectIndentation": false, // 禁用自动检测缩进,使用统一的缩进设置
// 自动格式化
"editor.formatOnSave": true, // 保存时自动格式化,保存文件时自动整理代码格式
"editor.formatOnPaste": true, // 粘贴时自动格式化,粘贴代码时自动调整格式
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "never" // 保存时自动修复eslint错误,保存时自动修复可修复的代码问题
},
// 代码格式化
"editor.defaultFormatter": "esbenp.prettier-vscode", // 默认格式化工具,使用prettier格式化代码
// 语言特定格式化配置
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
// eslint配置
"eslint.enable": false, // 启用eslint,开启代码检查
"eslint.validate": ["javascript", "typescript", "javascriptreact", "typescriptreact", "vue"], // eslint验证的文件类型,指定需要进行eslint检查的语言
"eslint.run": "onType", // eslint运行时机,在输入时实时运行eslint检查
// prettier配置
"prettier.requireConfig": false, // 不要求prettier配置文件,项目中不需要配置文件
"prettier.tabWidth": 4, // prettier缩进宽度,设置为4个空格
"prettier.useTabs": false, // 使用空格而非tab字符,按tab键时插入空格
"prettier.singleQuote": false, // 使用双引号而非单引号,统一代码风格
// 文件保存处理
"files.trimTrailingWhitespace": true, // 保存时删除行尾空格,清理多余的空白字符
"files.insertFinalNewline": true, // 文件末尾插入空行,符合unix文件规范
"files.trimFinalNewlines": true, // 删除文件末尾多余空行,保持文件整洁
// 自动导入
"typescript.preferences.importModuleSpecifier": "no-relative", // 导入模块路径格式,使用非相对路径导入模块
"typescript.updateImportsOnFileMove.enabled": "always", // 移动文件时更新导入,自动更新import路径
"javascript.updateImportsOnFileMove.enabled": "prompt", // 移动或重命名文件时,自动更新相关的import语句
// 版本管理
"typescript.tsdk": "node_modules/typescript/lib", // typescript sdk路径,使用项目本地的typescript版本
"typescript.enablePromptUseWorkspaceTsdk": true, // 提示使用工作区typescript,询问是否使用项目本地的ts版本
// 参数提示
"typescript.inlayHints.parameterNames.enabled": "none", // 显示参数提示,在编辑器中显示函数参数提示
"typescript.inlayHints.parameterTypes.enabled": false, // 禁止显示参数类型提示
"typescript.inlayHints.variableTypes.enabled": false, // 禁止显示变量类型提示
"typescript.inlayHints.functionLikeReturnTypes.enabled": false, // 禁止显示函数返回值类型提示

// 文件监控排除
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/node_modules/**": true,
"**/dist/**": true,
"**/.next/**": true,
"**/build/**": true
},
// 文件搜索排除
"search.exclude": {
"**/node_modules": true,
"**/dist": true,
"**/build": true,
"**/.next": true,
"**/coverage": true
},
// 文件关联
"files.associations": {
"*.env*": "dotenv"
}
}