Skip to content

Commit

Permalink
Add syntax highlighting for diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastinez committed Dec 9, 2024
1 parent 6bbaaa3 commit 74f31e5
Show file tree
Hide file tree
Showing 36 changed files with 2,088 additions and 15 deletions.
197 changes: 195 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions crates/radicle-tauri/src/commands/diff.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use radicle_surf as surf;

use radicle::identity;
use radicle_types as types;
use radicle_types::error::Error;
use radicle_types::traits::repo::Repo;

Expand All @@ -11,6 +10,6 @@ pub async fn get_diff(
ctx: tauri::State<'_, AppState>,
rid: identity::RepoId,
options: radicle_types::cobs::diff::Options,
) -> Result<surf::diff::Diff, Error> {
) -> Result<types::diff::Diff, Error> {
ctx.get_diff(rid, options)
}
15 changes: 15 additions & 0 deletions crates/radicle-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,18 @@ thiserror = { version = "1.0.65" }
ts-rs = { version = "10.0.0", features = ["serde-json-impl", "no-serde-warnings", "format"] }
localtime = { version = "1.3.1" }
tempfile = { version = "3.14.0" }
tree-sitter-bash = { version = "0.23.3" }
tree-sitter-c = { version = "0.23.2" }
tree-sitter-css = { version = "0.23.1" }
tree-sitter-go = { version = "0.23.4" }
tree-sitter-highlight = { version = "0.24.4" }
tree-sitter-html = { version = "0.23.2" }
tree-sitter-javascript = { version = "0.23.1" }
tree-sitter-json = { version = "0.24.8" }
tree-sitter-md = { version = "0.3.2" }
tree-sitter-python = { version = "0.23.4" }
tree-sitter-ruby = { version = "0.23.1" }
tree-sitter-rust = { version = "0.23.2" }
tree-sitter-svelte-ng = { version = "1.0.2" }
tree-sitter-toml-ng = { version = "0.7.0" }
tree-sitter-typescript = { version = "0.23.2" }
5 changes: 5 additions & 0 deletions crates/radicle-types/bindings/diff/Added.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { DiffContent } from "./DiffContent";
import type { DiffFile } from "./DiffFile";

export type Added = { path: string; diff: DiffContent; new: DiffFile };
4 changes: 4 additions & 0 deletions crates/radicle-types/bindings/diff/Addition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Line } from "../syntax/Line";

export type Addition = { line: string; lineNo: number; highlight: Line | null };
11 changes: 11 additions & 0 deletions crates/radicle-types/bindings/diff/Copied.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { DiffContent } from "./DiffContent";
import type { DiffFile } from "./DiffFile";

export type Copied = {
oldPath: string;
newPath: string;
old: DiffFile;
new: DiffFile;
diff: DiffContent;
};
5 changes: 5 additions & 0 deletions crates/radicle-types/bindings/diff/Deleted.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { DiffContent } from "./DiffContent";
import type { DiffFile } from "./DiffFile";

export type Deleted = { path: string; diff: DiffContent; old: DiffFile };
4 changes: 4 additions & 0 deletions crates/radicle-types/bindings/diff/Deletion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Line } from "../syntax/Line";

export type Deletion = { line: string; lineNo: number; highlight: Line | null };
5 changes: 5 additions & 0 deletions crates/radicle-types/bindings/diff/Diff.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { FileDiff } from "./FileDiff";
import type { Stats } from "./Stats";

export type Diff = { files: Array<FileDiff>; stats: Stats };
11 changes: 11 additions & 0 deletions crates/radicle-types/bindings/diff/DiffContent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { EofNewLine } from "./EofNewLine";
import type { FileStats } from "./FileStats";
import type { Hunks } from "./Hunks";

export type DiffContent = { "type": "binary" } | {
"type": "plain";
hunks: Hunks;
stats: FileStats;
eof: EofNewLine;
} | { "type": "empty" };
4 changes: 4 additions & 0 deletions crates/radicle-types/bindings/diff/DiffFile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { FileMode } from "./FileMode";

export type DiffFile = { oid: string; mode: FileMode };
7 changes: 7 additions & 0 deletions crates/radicle-types/bindings/diff/EofNewLine.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type EofNewLine =
| "oldMissing"
| "newMissing"
| "bothMissing"
| "noneMissing";
13 changes: 13 additions & 0 deletions crates/radicle-types/bindings/diff/FileDiff.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Added } from "./Added";
import type { Copied } from "./Copied";
import type { Deleted } from "./Deleted";
import type { Modified } from "./Modified";
import type { Moved } from "./Moved";

export type FileDiff =
| { "status": "added" } & Added
| { "status": "deleted" } & Deleted
| { "status": "modified" } & Modified
| { "status": "moved" } & Moved
| { "status": "copied" } & Copied;
3 changes: 3 additions & 0 deletions crates/radicle-types/bindings/diff/FileMode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type FileMode = "blob" | "blobExecutable" | "tree" | "link" | "commit";
3 changes: 3 additions & 0 deletions crates/radicle-types/bindings/diff/FileStats.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type FileStats = { additions: number; deletions: number };
9 changes: 9 additions & 0 deletions crates/radicle-types/bindings/diff/Hunk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Modification } from "./Modification";

export type Hunk = {
header: string;
lines: Array<Modification>;
old: { start: number; end: number };
new: { start: number; end: number };
};
4 changes: 4 additions & 0 deletions crates/radicle-types/bindings/diff/Hunks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Hunk } from "./Hunk";

export type Hunks = Array<Hunk>;
3 changes: 3 additions & 0 deletions crates/radicle-types/bindings/diff/Line.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type Line = Array<number>;
15 changes: 15 additions & 0 deletions crates/radicle-types/bindings/diff/Modification.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Addition } from "./Addition";
import type { Deletion } from "./Deletion";
import type { Line } from "../syntax/Line";

export type Modification =
| { "type": "addition" } & Addition
| { "type": "deletion" } & Deletion
| {
"type": "context";
line: string;
lineNoOld: number;
lineNoNew: number;
highlight: Line | null;
};
10 changes: 10 additions & 0 deletions crates/radicle-types/bindings/diff/Modified.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { DiffContent } from "./DiffContent";
import type { DiffFile } from "./DiffFile";

export type Modified = {
path: string;
diff: DiffContent;
old: DiffFile;
new: DiffFile;
};
Loading

0 comments on commit 74f31e5

Please sign in to comment.