From ad75ab04f7b088cfcdc7e688724f5ddcd12ccd84 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Sun, 19 Jul 2020 19:12:50 -0600 Subject: [PATCH] Formatters for C, C++, C#, Java, D --- backend/src/langs.ts | 11 +++++++++-- scripts/docker-install-phase3a.bash | 2 ++ scripts/docker-install-phase3b.bash | 1 + scripts/docker-install-phase4.bash | 7 ++++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/backend/src/langs.ts b/backend/src/langs.ts index db135c2..02bd5ed 100644 --- a/backend/src/langs.ts +++ b/backend/src/langs.ts @@ -301,6 +301,7 @@ Nude pagoda careens. main: "main.c", compile: "clang -Wall -Wextra main.c -o main", run: "./main", + format: "clang-format main.c", lspSetup: `echo '-Wall -Wextra' | sed -E 's/\\s+/\\n/g' > compile_flags.txt`, lsp: "clangd", template: `#include @@ -437,6 +438,7 @@ Refrigerate for 1 hour. main: "main.cpp", compile: "clang++ -Wall -Wextra main.cpp -o main", run: "./main", + format: "clang-format main.cpp", lspSetup: `echo '-Wall -Wextra' | sed -E 's/\\s+/\\n/g' > compile_flags.txt`, lsp: "clangd", template: `#include @@ -462,6 +464,7 @@ int main() { main: "main.cs", compile: "mcs main.cs", run: "mono main.exe", + format: `clang-format --style="{BasedOnStyle: llvm, IndentWidth: 4}" main.cs`, template: `class main { static void Main(string[] args) { System.Console.WriteLine("Hello, world!"); @@ -523,10 +526,12 @@ require("/usr/lib/node_modules/coffeescript/repl").start() main: "main.d", compile: "dmd main.d", run: "./main", + format: "dfmt main.d", template: `import std.stdio; -void main() { - writeln("Hello, world!"); +void main() +{ + writeln("Hello, world!"); } `, }, @@ -878,6 +883,7 @@ PLEASE GIVE UP main: "Main.java", compile: "javac Main.java", run: "java Main", + format: `clang-format --style="{BasedOnStyle: llvm, IndentWidth: 4}" Main.java`, template: `public class Main { public static void main(String[] args) { System.out.println("Hello, world!"); @@ -1141,6 +1147,7 @@ require("repl").start() compile: "gcc $(gnustep-config --objc-flags) main.m $(gnustep-config --base-libs) -o main", run: "./main", + format: "clang-format main.m", lspSetup: `(gnustep-config --objc-flags && gnustep-config --base-libs) | sed -E 's/\\s+/\\n/g' > compile_flags.txt`, lsp: "clangd", template: `#import diff --git a/scripts/docker-install-phase3a.bash b/scripts/docker-install-phase3a.bash index 03d0e47..3f3aaf1 100755 --- a/scripts/docker-install-phase3a.bash +++ b/scripts/docker-install-phase3a.bash @@ -39,9 +39,11 @@ beef # C/C++ clang +clang-format clangd # C# +clang-format mono-mcs # Ceylon diff --git a/scripts/docker-install-phase3b.bash b/scripts/docker-install-phase3b.bash index e795213..640fcaa 100755 --- a/scripts/docker-install-phase3b.bash +++ b/scripts/docker-install-phase3b.bash @@ -51,6 +51,7 @@ haxe intercal # Java +clang-format default-jdk # Julia diff --git a/scripts/docker-install-phase4.bash b/scripts/docker-install-phase4.bash index 2b00846..5c1197e 100755 --- a/scripts/docker-install-phase4.bash +++ b/scripts/docker-install-phase4.bash @@ -50,6 +50,11 @@ npm install -g lumo-cljs # CoffeeScript npm install -g coffeescript +# D +dub fetch --version='~master' dfmt +dub run dfmt -- --version +mv "$HOME/.dub/packages/dfmt-master/dfmt/bin/dfmt" /usr/local/bin/ + # Dogescript npm install -g dogescript @@ -126,7 +131,7 @@ pip3 install whitespace # Wolfram Language python3.7 -m pip install mathics -rm -rf /root/.cache /root/.config /root/.cpan /root/.cpanm /root/.gem /root/.npm /root/.npmrc +rm -rf /root/.cache /root/.config /root/.cpan /root/.cpanm /root/.dub /root/.gem /root/.npm /root/.npmrc rm -f /tmp/core-js-banners rm "$0"