From 77769d53fa17227e29a0d437f5f527d4efebffc9 Mon Sep 17 00:00:00 2001 From: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Tue, 28 Jan 2025 19:02:46 +0000 Subject: [PATCH 1/5] feat: add support for tree-sitter-helix --- languages.toml | 10 ++++++++++ lol.helix | 8 ++++++++ lol.md | 23 +++++++++++++++++++++++ ok.helix | 15 +++++++++++++++ runtime/queries/helix/highlights.scm | 19 +++++++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 lol.helix create mode 100644 lol.md create mode 100644 ok.helix create mode 100644 runtime/queries/helix/highlights.scm diff --git a/languages.toml b/languages.toml index 0aca142a8..cda6d6552 100644 --- a/languages.toml +++ b/languages.toml @@ -4077,3 +4077,13 @@ indent = { tab-width = 4, unit = " " } [[grammar]] name = "gren" source = { git = "https://github.com/MaeBrooks/tree-sitter-gren", rev = "76554f4f2339f5a24eed19c58f2079b51c694152" } + +[[language]] +name = "helix" +scope = "source.helix" +injection-regex = "helix" +file-types = ["helix"] + +[[grammar]] +name = "helix" +source = { git = "https://github.com/nik-rev/tree-sitter-helix", rev = "e452003505a02ccaeb9d159907af3b6998847355" } diff --git a/lol.helix b/lol.helix new file mode 100644 index 000000000..a3912970c --- /dev/null +++ b/lol.helix @@ -0,0 +1,8 @@ +This is a +#(b +a +[s] +i|)# +c +Selection with cursor on the right + diff --git a/lol.md b/lol.md new file mode 100644 index 000000000..9d8503528 --- /dev/null +++ b/lol.md @@ -0,0 +1,23 @@ +`copy_selection_on_prev_line` + +Copies the current primary selection to the first previous line long enough to accomodate it. + +# Examples + +The selection is copied from line 2 to line 1. + +Before: + +```helix +This is text #[|on line 1]#. +This is text on line 2. +``` + +Command: `C` + +After: + +```helix +This is text #(|on line 1)#. +This is text #[|on line 2]#. +``` diff --git a/ok.helix b/ok.helix new file mode 100644 index 000000000..92ba25404 --- /dev/null +++ b/ok.helix @@ -0,0 +1,15 @@ +Regular selection, with cursor on the right: + +#(hello world|)# + +Regular selection, with cursor on the left: + +#(|hello world)# + +Primary selection, with cursor on the right: + +#[hello world|]# + +Primary selection, with cursor on the left: + +#[|hello world]# diff --git a/runtime/queries/helix/highlights.scm b/runtime/queries/helix/highlights.scm new file mode 100644 index 000000000..3049e05a8 --- /dev/null +++ b/runtime/queries/helix/highlights.scm @@ -0,0 +1,19 @@ +(start_left_primary) @ui.cursor.primary +(end_right_primary) @ui.cursor.primary + +(start_left) @ui.cursor +(end_right) @ui.cursor + +[ + (end_left_primary) + (start_right_primary) + (end_left) + (start_right) +] @ui.selection + +(left_primary (text) @ui.selection.primary) +(right_primary (text) @ui.selection.primary) +(left (text) @ui.selection) +(right (text) @ui.selection) + +(ERROR) @error From cceb04479cf2f1ddbdb234462746a4162a4e97e2 Mon Sep 17 00:00:00 2001 From: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Tue, 28 Jan 2025 19:06:04 +0000 Subject: [PATCH 2/5] chore: remove unnecessary files --- lol.helix | 8 -------- lol.md | 23 ----------------------- ok.helix | 15 --------------- 3 files changed, 46 deletions(-) delete mode 100644 lol.helix delete mode 100644 lol.md delete mode 100644 ok.helix diff --git a/lol.helix b/lol.helix deleted file mode 100644 index a3912970c..000000000 --- a/lol.helix +++ /dev/null @@ -1,8 +0,0 @@ -This is a -#(b -a -[s] -i|)# -c -Selection with cursor on the right - diff --git a/lol.md b/lol.md deleted file mode 100644 index 9d8503528..000000000 --- a/lol.md +++ /dev/null @@ -1,23 +0,0 @@ -`copy_selection_on_prev_line` - -Copies the current primary selection to the first previous line long enough to accomodate it. - -# Examples - -The selection is copied from line 2 to line 1. - -Before: - -```helix -This is text #[|on line 1]#. -This is text on line 2. -``` - -Command: `C` - -After: - -```helix -This is text #(|on line 1)#. -This is text #[|on line 2]#. -``` diff --git a/ok.helix b/ok.helix deleted file mode 100644 index 92ba25404..000000000 --- a/ok.helix +++ /dev/null @@ -1,15 +0,0 @@ -Regular selection, with cursor on the right: - -#(hello world|)# - -Regular selection, with cursor on the left: - -#(|hello world)# - -Primary selection, with cursor on the right: - -#[hello world|]# - -Primary selection, with cursor on the left: - -#[|hello world]# From 655453821bf3e2a821eda699acbc1def7ba2cab1 Mon Sep 17 00:00:00 2001 From: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Tue, 28 Jan 2025 20:56:32 +0000 Subject: [PATCH 3/5] feat: `.multicursor` file type name --- languages.toml | 2 +- runtime/queries/helix/highlights.scm | 19 ------------------- runtime/queries/multicursor/highlights.scm | 20 ++++++++++++++++++++ 3 files changed, 21 insertions(+), 20 deletions(-) delete mode 100644 runtime/queries/helix/highlights.scm create mode 100644 runtime/queries/multicursor/highlights.scm diff --git a/languages.toml b/languages.toml index cda6d6552..84672bf39 100644 --- a/languages.toml +++ b/languages.toml @@ -4086,4 +4086,4 @@ file-types = ["helix"] [[grammar]] name = "helix" -source = { git = "https://github.com/nik-rev/tree-sitter-helix", rev = "e452003505a02ccaeb9d159907af3b6998847355" } +source = { git = "https://github.com/nik-rev/tree-sitter-multicursor", rev = "5449de20df54adb3862cec85663ee386ef969fbd" } diff --git a/runtime/queries/helix/highlights.scm b/runtime/queries/helix/highlights.scm deleted file mode 100644 index 3049e05a8..000000000 --- a/runtime/queries/helix/highlights.scm +++ /dev/null @@ -1,19 +0,0 @@ -(start_left_primary) @ui.cursor.primary -(end_right_primary) @ui.cursor.primary - -(start_left) @ui.cursor -(end_right) @ui.cursor - -[ - (end_left_primary) - (start_right_primary) - (end_left) - (start_right) -] @ui.selection - -(left_primary (text) @ui.selection.primary) -(right_primary (text) @ui.selection.primary) -(left (text) @ui.selection) -(right (text) @ui.selection) - -(ERROR) @error diff --git a/runtime/queries/multicursor/highlights.scm b/runtime/queries/multicursor/highlights.scm new file mode 100644 index 000000000..803442d95 --- /dev/null +++ b/runtime/queries/multicursor/highlights.scm @@ -0,0 +1,20 @@ +[ + (start_left_primary) + (end_left_primary) + (start_right_primary) + (end_right_primary) + (start_left) + (end_left) + (start_right) + (end_right) +] @punctuation.special + +(cursor_primary) @ui.cursor.primary +(cursor) @ui.cursor + +(left_primary (char) @ui.selection.primary) +(right_primary (char) @ui.selection.primary) +(left (char) @ui.selection) +(right (char) @ui.selection) + +(ERROR) @error From f5745a5ace16760c54c45dacdac232e44e697d25 Mon Sep 17 00:00:00 2001 From: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Tue, 28 Jan 2025 21:16:05 +0000 Subject: [PATCH 4/5] docs: add documentation for `.multicursor` file type --- book/src/generated/lang-support.md | 1 + languages.toml | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 404749456..29b5fb769 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -140,6 +140,7 @@ | mojo | ✓ | ✓ | ✓ | `magic` | | move | ✓ | | | | | msbuild | ✓ | | ✓ | | +| multicursor | ✓ | | | | | nasm | ✓ | ✓ | | `asm-lsp` | | nestedtext | ✓ | ✓ | ✓ | | | nginx | ✓ | | | | diff --git a/languages.toml b/languages.toml index 84672bf39..4004084ce 100644 --- a/languages.toml +++ b/languages.toml @@ -4079,10 +4079,10 @@ name = "gren" source = { git = "https://github.com/MaeBrooks/tree-sitter-gren", rev = "76554f4f2339f5a24eed19c58f2079b51c694152" } [[language]] -name = "helix" -scope = "source.helix" -injection-regex = "helix" -file-types = ["helix"] +name = "multicursor" +scope = "source.multicursor" +injection-regex = "multicursor" +file-types = ["multicursor"] [[grammar]] name = "helix" From 948e50d6586f58a728da89d1ccfd043de35f1b3c Mon Sep 17 00:00:00 2001 From: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Tue, 28 Jan 2025 21:27:15 +0000 Subject: [PATCH 5/5] fix: `multicursor` grammar and not for helix --- languages.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/languages.toml b/languages.toml index 4004084ce..cc1e43bce 100644 --- a/languages.toml +++ b/languages.toml @@ -4085,5 +4085,5 @@ injection-regex = "multicursor" file-types = ["multicursor"] [[grammar]] -name = "helix" -source = { git = "https://github.com/nik-rev/tree-sitter-multicursor", rev = "5449de20df54adb3862cec85663ee386ef969fbd" } +name = "multicursor" +source = { git = "https://github.com/nik-rev/tree-sitter-multicursor", rev = "f6f868ecfe3de2fb2cd815cb40be55493f699a49" }