Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add jbang-vscode to codium + add usability vscode settings #1427

Merged
merged 1 commit into from
Aug 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions src/main/java/dev/jbang/cli/Edit.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@CommandLine.Command(name = "edit", description = "Setup a temporary project to edit script in an IDE.")
public class Edit extends BaseCommand {

static String[] knownEditors = { "code", "eclipse", "idea", "netbeans" };
static String[] knownEditors = { "codium", "code", "eclipse", "idea", "netbeans" };

@CommandLine.Mixin
ScriptMixin scriptMixin;
Expand Down Expand Up @@ -226,12 +226,39 @@ private static void setupEditor(Path editorBinPath, Path dataPath) throws IOExce
Files.createDirectories(dataPath);
}

Path settingsjson = dataPath.resolve("user-data/User/settings.json");

if (!Files.exists(settingsjson)) {
verboseMsg("Setting up some good default settings at " + settingsjson);
Files.createDirectories(settingsjson.getParent());

String vscodeSettings = "{\n" +
// better than breadcrumbs
" \"editor.experimental.stickyScroll.enabled\": true,\n" +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't work well with Java code. Try a file with a copyright header, or annotations

// autosave because vscode has it default and it just makes things work smoother
" \"files.autoSave\": \"onFocusChange\",\n" +
// use modern java
" \"java.codeGeneration.hashCodeEquals.useJava7Objects\": true,\n" +
// instead of `out.println(x);` you get
// `out.println(argClosestWithMatchingType)`
" \"java.completion.guessMethodArguments\": true,\n" +
// when editing html/xml editing tags updates the matching pair
" \"editor.linkedEditing\": true,\n" +
// looks cooler - doesn't hurt
" \"editor.cursorBlinking\": \"phase\",\n" +
// making easy to zoom for presentations
" \"editor.mouseWheelZoom\": true\n" +
"}";
Util.writeString(settingsjson, vscodeSettings);
}

verboseMsg("Installing Java extensions...");
ProcessBuilder pb = new ProcessBuilder(editorBinPath.toAbsolutePath().toString(),
"--install-extension", "redhat.java",
"--install-extension", "vscjava.vscode-java-debug",
"--install-extension", "vscjava.vscode-java-test",
"--install-extension", "vscjava.vscode-java-dependency");
"--install-extension", "vscjava.vscode-java-dependency",
"--install-extension", "jbangdev.jbang-vscode");
pb.inheritIO();
Process process = pb.start();
try {
Expand Down