A simple CPU rendered GUI IDE experience.
better coloring
| -rw-r--r-- | diag | 225 | ||||
| -rw-r--r-- | src/com.rs | 6 | ||||
| -rw-r--r-- | src/lsp.rs | 8 | ||||
| -rw-r--r-- | src/main.rs | 91 | ||||
| -rw-r--r-- | src/text.rs | 9 |
5 files changed, 249 insertions, 90 deletions
@@ -2,51 +2,91 @@ { "range": { "start": { - "line": 69, + "line": 70, "character": 39 }, "end": { - "line": 69, + "line": 70, "character": 44 } }, "severity": 2, "code": "unused_imports", "source": "rustc", - "message": "unused import: `color`\n`#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default", + "message": "unused imports: `color` and `set_a`\n`#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default", "relatedInformation": [ { "location": { "uri": "file:///home/os/gracilaria/src/main.rs", "range": { "start": { - "line": 69, + "line": 70, "character": 37 }, "end": { - "line": 69, + "line": 70, "character": 44 } } }, - "message": "remove the unused import" + "message": "remove the unused imports" } ], "tags": [ 1 ], "data": { - "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unused import: `color`\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:70:40\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m70\u001b[0m \u001b[1m\u001b[94m|\u001b[0m use crate::text::{Diff, TextArea, col, color, is_word};\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^^^^^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default\n\n" + "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unused imports: `color` and `set_a`\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:71:40\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m71\u001b[0m \u001b[1m\u001b[94m|\u001b[0m use crate::text::{Diff, TextArea, col, color, is_word, set_a};\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^^^^^\u001b[0m \u001b[1m\u001b[33m^^^^^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default\n\n" } }, { "range": { "start": { - "line": 1272, + "line": 70, + "character": 55 + }, + "end": { + "line": 70, + "character": 60 + } + }, + "severity": 2, + "code": "unused_imports", + "source": "rustc", + "message": "unused imports: `color` and `set_a`\n`#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default", + "relatedInformation": [ + { + "location": { + "uri": "file:///home/os/gracilaria/src/main.rs", + "range": { + "start": { + "line": 70, + "character": 37 + }, + "end": { + "line": 70, + "character": 44 + } + } + }, + "message": "remove the unused imports" + } + ], + "tags": [ + 1 + ], + "data": { + "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unused imports: `color` and `set_a`\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:71:40\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m71\u001b[0m \u001b[1m\u001b[94m|\u001b[0m use crate::text::{Diff, TextArea, col, color, is_word, set_a};\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^^^^^\u001b[0m \u001b[1m\u001b[33m^^^^^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default\n\n" + } + }, + { + "range": { + "start": { + "line": 1296, "character": 6 }, "end": { - "line": 1272, + "line": 1296, "character": 7 } }, @@ -60,11 +100,11 @@ "uri": "file:///home/os/gracilaria/src/main.rs", "range": { "start": { - "line": 1272, + "line": 1296, "character": 6 }, "end": { - "line": 1272, + "line": 1296, "character": 7 } } @@ -73,17 +113,17 @@ } ], "data": { - "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unnecessary parentheses around type\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1273:7\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1273\u001b[0m \u001b[1m\u001b[94m|\u001b[0m C(((usize, usize)) => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^\u001b[0m \u001b[1m\u001b[33m^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `#[warn(unused_parens)]` (part of `#[warn(unused)]`) on by default\n\u001b[1m\u001b[96mhelp\u001b[0m: remove these parentheses\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1273\u001b[0m \u001b[91m- \u001b[0m C(\u001b[91m(\u001b[0m(usize, usize)\u001b[91m)\u001b[0m => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n\u001b[1m\u001b[94m1273\u001b[0m \u001b[92m+ \u001b[0m C((usize, usize) => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n \u001b[1m\u001b[94m|\u001b[0m\n\n" + "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unnecessary parentheses around type\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1297:7\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1297\u001b[0m \u001b[1m\u001b[94m|\u001b[0m C(((usize, usize)) => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^\u001b[0m \u001b[1m\u001b[33m^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `#[warn(unused_parens)]` (part of `#[warn(unused)]`) on by default\n\u001b[1m\u001b[96mhelp\u001b[0m: remove these parentheses\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1297\u001b[0m \u001b[91m- \u001b[0m C(\u001b[91m(\u001b[0m(usize, usize)\u001b[91m)\u001b[0m => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n\u001b[1m\u001b[94m1297\u001b[0m \u001b[92m+ \u001b[0m C((usize, usize) => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n \u001b[1m\u001b[94m|\u001b[0m\n\n" } }, { "range": { "start": { - "line": 1272, + "line": 1296, "character": 21 }, "end": { - "line": 1272, + "line": 1296, "character": 22 } }, @@ -97,11 +137,11 @@ "uri": "file:///home/os/gracilaria/src/main.rs", "range": { "start": { - "line": 1272, + "line": 1296, "character": 6 }, "end": { - "line": 1272, + "line": 1296, "character": 7 } } @@ -110,17 +150,57 @@ } ], "data": { - "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unnecessary parentheses around type\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1273:7\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1273\u001b[0m \u001b[1m\u001b[94m|\u001b[0m C(((usize, usize)) => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^\u001b[0m \u001b[1m\u001b[33m^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `#[warn(unused_parens)]` (part of `#[warn(unused)]`) on by default\n\u001b[1m\u001b[96mhelp\u001b[0m: remove these parentheses\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1273\u001b[0m \u001b[91m- \u001b[0m C(\u001b[91m(\u001b[0m(usize, usize)\u001b[91m)\u001b[0m => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n\u001b[1m\u001b[94m1273\u001b[0m \u001b[92m+ \u001b[0m C((usize, usize) => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n \u001b[1m\u001b[94m|\u001b[0m\n\n" + "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unnecessary parentheses around type\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1297:7\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1297\u001b[0m \u001b[1m\u001b[94m|\u001b[0m C(((usize, usize)) => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^\u001b[0m \u001b[1m\u001b[33m^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `#[warn(unused_parens)]` (part of `#[warn(unused)]`) on by default\n\u001b[1m\u001b[96mhelp\u001b[0m: remove these parentheses\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1297\u001b[0m \u001b[91m- \u001b[0m C(\u001b[91m(\u001b[0m(usize, usize)\u001b[91m)\u001b[0m => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n\u001b[1m\u001b[94m1297\u001b[0m \u001b[92m+ \u001b[0m C((usize, usize) => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n \u001b[1m\u001b[94m|\u001b[0m\n\n" } }, { "range": { "start": { - "line": 1282, + "line": 606, + "character": 32 + }, + "end": { + "line": 606, + "character": 36 + } + }, + "severity": 2, + "code": "unused_variables", + "source": "rustc", + "message": "unused variable: `diag`", + "relatedInformation": [ + { + "location": { + "uri": "file:///home/os/gracilaria/src/main.rs", + "range": { + "start": { + "line": 606, + "character": 32 + }, + "end": { + "line": 606, + "character": 36 + } + } + }, + "message": "if this is intentional, prefix it with an underscore: `_diag`" + } + ], + "tags": [ + 1 + ], + "data": { + "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unused variable: `diag`\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:607:33\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m607\u001b[0m \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[94m...\u001b[0m for diag in dawg {\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^^^^\u001b[0m \u001b[1m\u001b[33mhelp: if this is intentional, prefix it with an underscore: `_diag`\u001b[0m\n\n" + } + }, + { + "range": { + "start": { + "line": 1306, "character": 10 }, "end": { - "line": 1282, + "line": 1306, "character": 11 } }, @@ -134,11 +214,11 @@ "uri": "file:///home/os/gracilaria/src/main.rs", "range": { "start": { - "line": 1282, + "line": 1306, "character": 10 }, "end": { - "line": 1282, + "line": 1306, "character": 11 } } @@ -150,17 +230,17 @@ 1 ], "data": { - "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unused variable: `x`\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1283:11\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1283\u001b[0m \u001b[1m\u001b[94m|\u001b[0m Selection(x) => {\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^\u001b[0m \u001b[1m\u001b[33mhelp: if this is intentional, prefix it with an underscore: `_x`\u001b[0m\n\n" + "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unused variable: `x`\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1307:11\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1307\u001b[0m \u001b[1m\u001b[94m|\u001b[0m Selection(x) => {\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^\u001b[0m \u001b[1m\u001b[33mhelp: if this is intentional, prefix it with an underscore: `_x`\u001b[0m\n\n" } }, { "range": { "start": { - "line": 1310, + "line": 1334, "character": 8 }, "end": { - "line": 1310, + "line": 1334, "character": 9 } }, @@ -174,11 +254,11 @@ "uri": "file:///home/os/gracilaria/src/main.rs", "range": { "start": { - "line": 1310, + "line": 1334, "character": 8 }, "end": { - "line": 1310, + "line": 1334, "character": 9 } } @@ -190,17 +270,17 @@ 1 ], "data": { - "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unused variable: `x`\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1311:9\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1311\u001b[0m \u001b[1m\u001b[94m|\u001b[0m Search((x, y, m)) => {\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^\u001b[0m \u001b[1m\u001b[33mhelp: if this is intentional, prefix it with an underscore: `_x`\u001b[0m\n\n" + "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unused variable: `x`\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1335:9\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1335\u001b[0m \u001b[1m\u001b[94m|\u001b[0m Search((x, y, m)) => {\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^\u001b[0m \u001b[1m\u001b[33mhelp: if this is intentional, prefix it with an underscore: `_x`\u001b[0m\n\n" } }, { "range": { "start": { - "line": 1310, + "line": 1334, "character": 11 }, "end": { - "line": 1310, + "line": 1334, "character": 12 } }, @@ -214,11 +294,11 @@ "uri": "file:///home/os/gracilaria/src/main.rs", "range": { "start": { - "line": 1310, + "line": 1334, "character": 11 }, "end": { - "line": 1310, + "line": 1334, "character": 12 } } @@ -230,11 +310,11 @@ "uri": "file:///home/os/gracilaria/src/main.rs", "range": { "start": { - "line": 1310, + "line": 1334, "character": 11 }, "end": { - "line": 1310, + "line": 1334, "character": 12 } } @@ -246,17 +326,17 @@ 1 ], "data": { - "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unused variable: `y`\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1311:12\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1311\u001b[0m \u001b[1m\u001b[94m|\u001b[0m Search((x, y, m)) => {\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[96mhelp\u001b[0m: you might have meant to pattern match on the similarly named constant `N`\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1311\u001b[0m \u001b[91m- \u001b[0mSearch((x, \u001b[91my\u001b[0m, m)) => {\n\u001b[1m\u001b[94m1311\u001b[0m \u001b[92m+ \u001b[0mSearch((x, \u001b[92mcom::N\u001b[0m, m)) => {\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[96mhelp\u001b[0m: if this is intentional, prefix it with an underscore\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1311\u001b[0m \u001b[1m\u001b[94m| \u001b[0mSearch((x, \u001b[92m_\u001b[0my, m)) => {\n \u001b[1m\u001b[94m|\u001b[0m \u001b[92m+\u001b[0m\n\n" + "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unused variable: `y`\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1335:12\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1335\u001b[0m \u001b[1m\u001b[94m|\u001b[0m Search((x, y, m)) => {\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[96mhelp\u001b[0m: you might have meant to pattern match on the similarly named constant `N`\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1335\u001b[0m \u001b[91m- \u001b[0mSearch((x, \u001b[91my\u001b[0m, m)) => {\n\u001b[1m\u001b[94m1335\u001b[0m \u001b[92m+ \u001b[0mSearch((x, \u001b[92mcom::N\u001b[0m, m)) => {\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[96mhelp\u001b[0m: if this is intentional, prefix it with an underscore\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1335\u001b[0m \u001b[1m\u001b[94m| \u001b[0mSearch((x, \u001b[92m_\u001b[0my, m)) => {\n \u001b[1m\u001b[94m|\u001b[0m \u001b[92m+\u001b[0m\n\n" } }, { "range": { "start": { - "line": 1310, + "line": 1334, "character": 14 }, "end": { - "line": 1310, + "line": 1334, "character": 15 } }, @@ -270,11 +350,11 @@ "uri": "file:///home/os/gracilaria/src/main.rs", "range": { "start": { - "line": 1310, + "line": 1334, "character": 14 }, "end": { - "line": 1310, + "line": 1334, "character": 15 } } @@ -286,11 +366,11 @@ "uri": "file:///home/os/gracilaria/src/main.rs", "range": { "start": { - "line": 1310, + "line": 1334, "character": 14 }, "end": { - "line": 1310, + "line": 1334, "character": 15 } } @@ -302,17 +382,17 @@ 1 ], "data": { - "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unused variable: `m`\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1311:15\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1311\u001b[0m \u001b[1m\u001b[94m|\u001b[0m Search((x, y, m)) => {\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[96mhelp\u001b[0m: you might have meant to pattern match on the similarly named constant `N`\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1311\u001b[0m \u001b[91m- \u001b[0mSearch((x, y, \u001b[91mm\u001b[0m)) => {\n\u001b[1m\u001b[94m1311\u001b[0m \u001b[92m+ \u001b[0mSearch((x, y, \u001b[92mcom::N\u001b[0m)) => {\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[96mhelp\u001b[0m: if this is intentional, prefix it with an underscore\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1311\u001b[0m \u001b[1m\u001b[94m| \u001b[0mSearch((x, y, \u001b[92m_\u001b[0mm)) => {\n \u001b[1m\u001b[94m|\u001b[0m \u001b[92m+\u001b[0m\n\n" + "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unused variable: `m`\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1335:15\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1335\u001b[0m \u001b[1m\u001b[94m|\u001b[0m Search((x, y, m)) => {\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[96mhelp\u001b[0m: you might have meant to pattern match on the similarly named constant `N`\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1335\u001b[0m \u001b[91m- \u001b[0mSearch((x, y, \u001b[91mm\u001b[0m)) => {\n\u001b[1m\u001b[94m1335\u001b[0m \u001b[92m+ \u001b[0mSearch((x, y, \u001b[92mcom::N\u001b[0m)) => {\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[96mhelp\u001b[0m: if this is intentional, prefix it with an underscore\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1335\u001b[0m \u001b[1m\u001b[94m| \u001b[0mSearch((x, y, \u001b[92m_\u001b[0mm)) => {\n \u001b[1m\u001b[94m|\u001b[0m \u001b[92m+\u001b[0m\n\n" } }, { "range": { "start": { - "line": 1272, + "line": 1296, "character": 6 }, "end": { - "line": 1272, + "line": 1296, "character": 22 } }, @@ -326,11 +406,11 @@ "uri": "file:///home/os/gracilaria/src/main.rs", "range": { "start": { - "line": 1312, + "line": 1336, "character": 4 }, "end": { - "line": 1312, + "line": 1336, "character": 5 } } @@ -342,11 +422,11 @@ "uri": "file:///home/os/gracilaria/src/main.rs", "range": { "start": { - "line": 1272, + "line": 1296, "character": 6 }, "end": { - "line": 1272, + "line": 1296, "character": 22 } } @@ -358,17 +438,17 @@ 1 ], "data": { - "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: field `0` is never read\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1273:7\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1273\u001b[0m \u001b[1m\u001b[94m|\u001b[0m C(((usize, usize)) => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^^^^^^^^^^^^^^^^\u001b[0m\n\u001b[1m\u001b[94m...\u001b[0m\n\u001b[1m\u001b[94m1313\u001b[0m \u001b[1m\u001b[94m|\u001b[0m C(_) => Search((x, y, m)),\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[94m-\u001b[0m \u001b[1m\u001b[94mfield in this variant\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `Action` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default\n\u001b[1m\u001b[96mhelp\u001b[0m: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1273\u001b[0m \u001b[91m- \u001b[0m C(\u001b[91m((usize, usize))\u001b[0m => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n\u001b[1m\u001b[94m1273\u001b[0m \u001b[92m+ \u001b[0m C(\u001b[92m()\u001b[0m => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n \u001b[1m\u001b[94m|\u001b[0m\n\n" + "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: field `0` is never read\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1297:7\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1297\u001b[0m \u001b[1m\u001b[94m|\u001b[0m C(((usize, usize)) => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^^^^^^^^^^^^^^^^\u001b[0m\n\u001b[1m\u001b[94m...\u001b[0m\n\u001b[1m\u001b[94m1337\u001b[0m \u001b[1m\u001b[94m|\u001b[0m C(_) => Search((x, y, m)),\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[94m-\u001b[0m \u001b[1m\u001b[94mfield in this variant\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `Action` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default\n\u001b[1m\u001b[96mhelp\u001b[0m: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1297\u001b[0m \u001b[91m- \u001b[0m C(\u001b[91m((usize, usize))\u001b[0m => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n\u001b[1m\u001b[94m1297\u001b[0m \u001b[92m+ \u001b[0m C(\u001b[92m()\u001b[0m => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n \u001b[1m\u001b[94m|\u001b[0m\n\n" } }, { "range": { "start": { - "line": 1422, + "line": 1446, "character": 3 }, "end": { - "line": 1422, + "line": 1446, "character": 15 } }, @@ -380,17 +460,54 @@ 1 ], "data": { - "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: function `frunctinator` is never used\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1423:4\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1423\u001b[0m \u001b[1m\u001b[94m|\u001b[0m fn frunctinator(\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^^^^^^^^^^^^\u001b[0m\n\n" + "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: function `frunctinator` is never used\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1447:4\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1447\u001b[0m \u001b[1m\u001b[94m|\u001b[0m fn frunctinator(\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^^^^^^^^^^^^\u001b[0m\n\n" + } + }, + { + "range": { + "start": { + "line": 457, + "character": 36 + }, + "end": { + "line": 457, + "character": 104 + } + }, + "severity": 2, + "code": "unused_must_use", + "source": "rustc", + "message": "unused `Result` that must be used\nthis `Result` may be an `Err` variant, which should be handled", + "relatedInformation": [ + { + "location": { + "uri": "file:///home/os/gracilaria/src/main.rs", + "range": { + "start": { + "line": 457, + "character": 36 + }, + "end": { + "line": 457, + "character": 36 + } + } + }, + "message": "use `let _ = ...` to ignore the resulting value: `let _ = `" + } + ], + "data": { + "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unused `Result` that must be used\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:458:37\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m458\u001b[0m \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[94m...\u001b[0m std::fs::write(\"diag\", serde_json::to_string_pretty(&diag).unwrap());\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: this `Result` may be an `Err` variant, which should be handled\n\u001b[1m\u001b[96mhelp\u001b[0m: use `let _ = ...` to ignore the resulting value\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m458\u001b[0m \u001b[1m\u001b[94m| \u001b[0m \u001b[92mlet _ = \u001b[0mstd::fs::write(\"diag\", serde_json::to_string_pretty(&diag).unwrap());\n \u001b[1m\u001b[94m|\u001b[0m \u001b[92m+++++++\u001b[0m\n\n" } }, { "range": { "start": { - "line": 1427, + "line": 1451, "character": 31 }, "end": { - "line": 1427, + "line": 1451, "character": 41 } }, @@ -399,7 +516,7 @@ "source": "rustc", "message": "path statement with no effect\n`#[warn(path_statements)]` (part of `#[warn(unused)]`) on by default", "data": { - "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: path statement with no effect\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1428:32\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1428\u001b[0m \u001b[1m\u001b[94m|\u001b[0m lower::saturating::math! { parameter1 };\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^^^^^^^^^^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `#[warn(path_statements)]` (part of `#[warn(unused)]`) on by default\n\n" + "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: path statement with no effect\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1452:32\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1452\u001b[0m \u001b[1m\u001b[94m|\u001b[0m lower::saturating::math! { parameter1 };\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^^^^^^^^^^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `#[warn(path_statements)]` (part of `#[warn(unused)]`) on by default\n\n" } } ]
\ No newline at end of file @@ -64,7 +64,7 @@ fn score<'a>( let mut v = x .map(move |y| { let mut utf32 = vec![]; - + // std::env::args().nth(1).unwrap().as_bytes().fi .fold(0, |acc, x| acc * 10 + x - b'0'); let hay = y.filter_text.as_deref().unwrap_or(&y.label); let mut indices = vec![]; let score = p @@ -80,6 +80,10 @@ fn score<'a>( (score, y, indices) }) .collect::<Vec<_>>(); + // std::fs::write( + // "com", + // v.iter().map(|x| x.1.label.clone() + "\n").collect::<String>(), + // ); v.sort_by_key(|x| x.0); v.reverse(); v @@ -401,8 +401,13 @@ pub fn run( diagnostic: Some(DiagnosticWorkspaceClientCapabilities { refresh_support: Some(true) }), ..default() }), - text_document: Some(TextDocumentClientCapabilities { + code_action: Some( + CodeActionClientCapabilities { + data_support: Some(true), + ..default() + } + ), hover: Some(HoverClientCapabilities { dynamic_registration: None, content_format: Some(vec![MarkupKind::PlainText, MarkupKind::Markdown]), @@ -521,6 +526,7 @@ pub fn run( }), ..default() }), + general: Some(GeneralClientCapabilities { markdown: Some(MarkdownClientCapabilities { version: Some("1.0.0".into()), diff --git a/src/main.rs b/src/main.rs index f39ab27..297d7c5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,6 +31,7 @@ )] #![allow(incomplete_features, redundant_semicolons)] use std::borrow::Cow; +use std::iter::once; use std::num::NonZeroU32; use std::path::{Path, PathBuf}; use std::sync::LazyLock; @@ -67,7 +68,7 @@ use winit::window::Icon; use crate::bar::Bar; use crate::hov::Hovr; use crate::lsp::{RedrawAfter, RqS}; -use crate::text::{Diff, TextArea, col, color, is_word}; +use crate::text::{Diff, TextArea, col, color, is_word, set_a}; mod bar; pub mod com; pub mod hov; @@ -448,42 +449,60 @@ pub(crate) fn entry(event_loop: EventLoop<()>) { (t_ox, 0), x, |(_c, _r), text, mut x| { - if let Some((lsp, p)) = lsp!() && let Some(diag) = lsp.diagnostics.get(&Url::from_file_path(p).unwrap(), &lsp.diagnostics.guard()) { - for diag in diag { + if let Some((lsp, p)) = lsp!() && let uri = Url::from_file_path(p).unwrap() && let Some(diag) = lsp.diagnostics.get(&uri, &lsp.diagnostics.guard()) { + #[derive(Copy, Clone, Debug)] + enum EType { + Hint, Info, Error,Warning,Related(DiagnosticSeverity), + } + let mut occupied = vec![]; + diag.iter().flat_map(|diag| { let sev = diag.severity.unwrap_or(DiagnosticSeverity::ERROR); - let f = |cell:&mut Cell| { + let sev_ = match sev { + DiagnosticSeverity::ERROR => EType::Error, + DiagnosticSeverity::WARNING => EType::Warning, + DiagnosticSeverity::HINT => EType::Hint, + _ => EType::Info, + }; + once((diag.range, &*diag.message, sev_)).chain(diag.related_information.iter().flatten().filter(|sp| sp.location.uri == uri).map(move |x| { + (x.location.range, &*x.message, EType::Related(sev)) + })) + }).for_each(|(mut r, m, sev)| { + while occupied.contains(&r.start.line) { + r.start.line+=1 + }; + occupied.push(r.start.line); + let f = |cell:&mut Cell| { cell.style.bg.blend(match sev { - DiagnosticSeverity::ERROR => col!("#ff66662c"), - DiagnosticSeverity::WARNING => col!("#9469242c"), - _ => return + EType::Error => col!("#ff66662c"), + EType::Warning | EType::Hint | EType::Info => col!("#9469242c"), + EType::Related(DiagnosticSeverity::ERROR) => col!("#dfbfff26"), + EType::Related(_) => col!("#ffad6625"), }); }; - if diag.range.start == diag.range.end { - x.get((diag.range.start.character as _, diag.range.start.line as _)).map(f); - } else { - x.get_range((diag.range.start.character as _, diag.range.start.line as _), (diag.range.end.character as usize, diag.range.end.line as _)) - .for_each(f) - } - { - let l = diag.range.start.line as usize; - let x_ = text.rope.line(l).len_chars() + 2; + if r.start == r.end { + x.get((r.start.character as _, r.start.line as _)).map(f); + } else { + x.get_range((r.start.character as _, r.start.line as _), (r.end.character as usize, r.end.line as _)) + .for_each(f) + } + let l = r.start.line as usize; + let x_ = text.rope.line(l).len_chars() + 2; + let m = m.lines().next().unwrap_or(m); x.get_range( (x_, l), - (x_ + diag.message.chars().count(), l), - ).zip(diag.message.chars()).for_each(|(x, c)| { - *x=match sev { - DiagnosticSeverity::WARNING => { Style{ bg :col!("#362f2f"), - color: col!("#fa973a"), flags: 0 }}, - DiagnosticSeverity::ERROR => { - Style { bg : col!("#342833"), - color : col!("#f26462"), flags: 0 } - }, + (x_ + m.chars().count(), l), + ).zip(m.chars()).for_each(|(x, ch)| { + let (bg, fg) = match sev { + EType::Warning => { col!("#ff942f1b", "#fa973a") }, + EType::Error => { col!("#ff942f1b", "#f26462") }, + EType::Related(DiagnosticSeverity::WARNING) => { col!("#dfbfff26", "#DFBFFF") } _ => return - }.basic(c) - - }); - } - } + }; + x.style.bg.blend(bg); + x.style.color = fg; + x.letter = Some(ch); + }) + }); } if let State::Search(re, j, _) = &state { re.find_iter(&text.rope.to_string()) @@ -581,6 +600,12 @@ pub(crate) fn entry(event_loop: EventLoop<()>) { )}; (is_above, left, top, w, h) }; + if let Some((lsp, p)) = lsp!() && let Some(diag) = lsp.diagnostics.get(&Url::from_file_path(p).unwrap(), &lsp.diagnostics.guard()) { + let dawg = diag.iter().filter(|x| text.l_range(x.range).is_ok_and(|x| x.contains(&text.cursor))); + for diag in dawg { + + } + } hovering.result.as_ref().map(|x| x.span.clone().map(|sp| { let [(_x, _y), (_x2, _)] = text.position(sp); let [_x, _x2] = [_x, _x2].add(text.line_number_offset()+1); @@ -798,9 +823,7 @@ let handle = cl.runtime.spawn(window.redraw_after(async move { let m = hov::l(&x).into_iter().max().map(_+2).unwrap_or(usize::MAX).min(c-10); (m, hov::markdown2(m, &x)) }).await.unwrap(); - let span = x.range.and_then(|x| { - Some(text.l_position(x.start).ok()?..text.l_position(x.end).ok()?) - }); + let span = x.range.and_then(|x| text.l_range(x).ok()); anyhow::Ok(Some( hov::Hovr { span, item: text::CellBuffer { c: w, vo: 0, cells: cells.into() }}.into())) })); hovering.request = (DropH::new(handle), hover).into(); @@ -1395,7 +1418,7 @@ rust_fsm::state_machine! { // exit cases Complete(_) => Click => None, Complete(_) => NoResult => None, - Complete(_)=> K(Key::Named(Escape)) => None, + Complete(_) => K(Key::Named(Escape)) => None, Complete(_) => K(Key::Character(x) if !x.chars().all(is_word)) => None, Complete(Rq { result: Some(x), .. }) => K(Key::Named(NamedKey::Enter)) => None [Finish(Complete => x)], diff --git a/src/text.rs b/src/text.rs index f37b0b9..4b788a6 100644 --- a/src/text.rs +++ b/src/text.rs @@ -174,6 +174,9 @@ macro_rules! col { const __N: usize = $x.len(); const { crate::text::color($x.as_bytes().as_array::<__N>().unwrap()) } }}; + ($($x:literal),+)=> {{ + ($(crate::text::col!($x),)+) + }}; } #[derive(Clone, Debug)] pub struct Diff { @@ -736,6 +739,12 @@ impl TextArea { + (p.character as usize) .min(self.rope.line(p.line as _).len_chars())) } + pub fn l_range( + &self, + r: lsp_types::Range, + ) -> Result<Range<usize>, ropey::Error> { + Ok(self.l_position(r.start)?..self.l_position(r.end)?) + } #[implicit_fn] pub fn write_to<'lsp>( |