1、java 插件
-
Extension Pack for Java
1. redhat-v0.64.1(支持jdk8)
2. Maven for java
3. Debugger for Java-0.37.0
版本不要安装错,当前时间的最新版本有bug:No delegateCommandHandler for vscode.java.resolveMainMethod
4. Test Runner for Java
5. Project Manager for Java
6. Visual Studio IntelliCode 代码提示功能
注 : 我只安装了前五个1. redhat 版本与jdk版本有依赖,jdk8请用redhat-v0.64.1 2. Debugger for Java要安装0.37.0版本 最新版本有bug,运行java时报错:No delegateCommandHandler for vscode.java.resolveMainMethod 4. Visual Studio IntelliCode 我使用了aiXcoder 来代替,基础功能不收费
-
koroFileHeader ----- 注释插件(将下面json加入setting最外层{}中)
快捷键 :
ctrl+cmd+i 头注释
ctrl+cmd+t 方法注释
注 : 头注释和方法注释 需要分别设置内容"fileheader.configObj": { "createHeader": true, "headInsertLine": {//头注释插入第几行 "php": 2, "java": 3, "python": 3 }, "autoAdd": false, "language": { "java": { "head": "/**", "middle": " * @", "end": " */", "functionSymbol": { "head": "/** ", "middle": " * @", "end": " */" } }, "python": { "head": "'''", "middle": " ", "end": "'''", "functionSymbol": { "head": "'''", "middle": " ", "end": "'''" } } }, "fileheader.customMade": {//头注释 "author": "HMZ", "Date": "Do not edit", "LastEditTime": "Do not edit" }, "diffEditor.ignoreTrimWhitespace": false, "git.enableStatusBarSync": false, "explorer.confirmDelete": false, "[python]": { "editor.defaultFormatter": "ms-python.python" }, "editor.largeFileOptimizations": false, "python.formatting.provider": "yapf", "python.formatting.yapfArgs": [ "--style", "{column_limit: 400}" ], "python.linting.pylintEnabled": false, "python.linting.flake8Enabled": false, "python.linting.flake8Args": [ "--max-line-length=300" ],
2、环境配置
-
jdk(将下面json加入setting最外层{}中)
"java.configuration.runtimes": [ { "name": "JavaSE-1.8", "path": "/Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home",//写bin目录的上一层 "default": true//启动 }, { "name": "JavaSE-11", "path": "/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home", "default": false//不启动 }]
-
maven
注 : settings.xml 默认~/.m2/settings.xml"maven.executable.path": "/Users/myhappiness/work/apache-maven-3.2.5/bin/mvn",
3、格式化工具
找了好多java格式化插件,没有搞懂,最终采用了redhat自带格式化功能
-
配置格式化工具
在setting.json添加设置(将下面json加入setting最外层{}中)// ===========java格式化工具================ "java.format.settings.url": "/Users/[你的电脑用户名]/.vscode/extensions/redhat.java-0.64.1/formatters/eclipse-formatter.xml", "[java]": { "editor.defaultFormatter": "redhat.java" }, "maven.view": "hierarchical", "files.watcherExclude": { "**/.bloop": true, "**/.metals": true, "**/.ammonite": true }
-
配置格式化功能
文件地址mac:/Users/[你的电脑用户名]/.vscode/extensions/redhat.java-0.64.1/formatters/eclipse-formatter.xml
1. 格式化时,不格式化注释块 <setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="false"/>