From 45230382b118c6f16615928767cdc75863931503 Mon Sep 17 00:00:00 2001 From: Kenzi Connor Date: Fri, 14 Jun 2024 18:07:12 -0700 Subject: [PATCH 1/3] Fix for fmt sync issues - replace file with out Textmate reload on filesytem changes isn't dependable, ime. Running the file contents through rustfmt directly means we don't have to save the file, which is a little better POLS, imo. Cursor can jump left or right a bit, but line interpolation works fairly well. --- Commands/Format.tmCommand | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Commands/Format.tmCommand b/Commands/Format.tmCommand index c35aec9..f55da2f 100644 --- a/Commands/Format.tmCommand +++ b/Commands/Format.tmCommand @@ -3,16 +3,16 @@ beforeRunningCommand - saveActiveFile + nop command #!/bin/bash cd $TM_PROJECT_DIRECTORY : ${CARGO_HOME=$HOME/.cargo} && export CARGO_HOME -$CARGO_HOME/bin/rustfmt $TM_FILEPATH +$CARGO_HOME/bin/rustfmt --emit stdout input - none + document inputFormat text keyEquivalent @@ -20,16 +20,16 @@ $CARGO_HOME/bin/rustfmt $TM_FILEPATH name Format outputCaret - afterOutput + interpolateByLine outputFormat text outputLocation - discard + replaceDocument scope source.rust uuid 62C653C0-B18A-4B68-9598-32972B821814 version - 2 + 3 From 9305a8851884e837bc84d51d08b8ba4999a3c71b Mon Sep 17 00:00:00 2001 From: Kenzi Connor Date: Fri, 14 Jun 2024 18:15:45 -0700 Subject: [PATCH 2/3] fmt on save via callback so covers all cases We/you could default it to off if you think that's too aggressive --- Commands/Fmt on Save.tmCommand | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Commands/Fmt on Save.tmCommand diff --git a/Commands/Fmt on Save.tmCommand b/Commands/Fmt on Save.tmCommand new file mode 100644 index 0000000..9375102 --- /dev/null +++ b/Commands/Fmt on Save.tmCommand @@ -0,0 +1,37 @@ + + + + + beforeRunningCommand + nop + command + #!/bin/bash + +cd $TM_PROJECT_DIRECTORY +: ${CARGO_HOME=$HOME/.cargo} && export CARGO_HOME +$CARGO_HOME/bin/rustfmt --emit stdout + + input + document + inputFormat + text + hideFromUser + + name + Fmt on Save + outputCaret + interpolateByLine + outputFormat + text + outputLocation + replaceDocument + scope + source.rust + semanticClass + callback.document.will-save.100 + uuid + 83ef2c73-1a43-48de-9fb5-a52cb6ad4540 + version + 1 + + \ No newline at end of file From 7bc91ad720268cd24a3fcb6ff17f4ae5621c0189 Mon Sep 17 00:00:00 2001 From: Kenzi Connor Date: Fri, 14 Jun 2024 18:38:44 -0700 Subject: [PATCH 3/3] update readme --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 2bd4070..3366c6a 100644 --- a/README.md +++ b/README.md @@ -85,8 +85,14 @@ tmb update rust +- rustfmt auto run on save (see instructions below to disable) - Autocompletion when racer is available (see instructions below) +## How to disable format on save + + - Bundles menu > Edit Bundles > Rust > Other Actions > Fmt on save > Uncheck "Enable this item" + + ## How to enable autocompletion via racer - Install racer by following [the instructions in racer's README](https://github.com/phildawes/racer)