From a7f49fa56fecd7f44efca7e6074e5cd9e5d91c92 Mon Sep 17 00:00:00 2001 From: Thomas Wehmöller Date: Sun, 10 Oct 2021 15:09:17 +0200 Subject: Add Vue tree sitter grammar (#787) * ✨ Add vue tree sitter support * Update .gitmodules Co-authored-by: Blaž Hrastnik --- runtime/queries/vue/highlights.scm | 21 +++++++++++++++++++++ runtime/queries/vue/injections.scm | 17 +++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 runtime/queries/vue/highlights.scm create mode 100644 runtime/queries/vue/injections.scm (limited to 'runtime') diff --git a/runtime/queries/vue/highlights.scm b/runtime/queries/vue/highlights.scm new file mode 100644 index 00000000..f90ae429 --- /dev/null +++ b/runtime/queries/vue/highlights.scm @@ -0,0 +1,21 @@ +(tag_name) @tag +(end_tag) @tag + +(directive_name) @keyword +(directive_argument) @constant + +(attribute + (attribute_name) @attribute + (quoted_attribute_value + (attribute_value) @string) +) + +(comment) @comment + +[ + "<" + ">" + " # "ui.linenr.selected" = { fg = "#d8dee9" } -# "ui.text.focus" = { fg = "#e5ded6", modifiers= ["bold"] } +"ui.text.focus" = { fg = "#88c0d0", modifiers= ["bold"] } # "ui.menu.selected" = { fg = "#e5ded6", bg = "#313f4e" } # "info" = "#b48ead" -- cgit v1.2.3-70-g09d2 From 43465926be77e6890203fe6a4942f674bfb2a8f4 Mon Sep 17 00:00:00 2001 From: Omnikar Date: Fri, 15 Oct 2021 23:47:45 -0400 Subject: Continue tutor (#737) * Add sections * `COUNTS WITH MOTIONS` * `SELECTING LINES` * `UNDOING` * Adjust lesson spacing to conform to page-wise scrolling Vertical length of lessons reduced by 1 line so that page-up and page-down move cleanly between lessons. * Add sections * `THE CHANGE COMMAND` * `RECAP` * `MULTIPLE CURSORS` * Fix height of `RECAP` section * Fix typo in `MULTIPLE CURSORS` * Add additional information about space mode to `MULTIPLE CURSORS` * Change `` to `,` * Add sections * `THE SELECT COMMAND` * `SELECTING VIA REGEX` * `COLLAPSING SELECTIONS` * Fix quote inconsistency--- runtime/tutor.txt | 208 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 198 insertions(+), 10 deletions(-) (limited to 'runtime') diff --git a/runtime/tutor.txt b/runtime/tutor.txt index 07b88884..b6f600d0 100644 --- a/runtime/tutor.txt +++ b/runtime/tutor.txt @@ -20,7 +20,6 @@ _________________________________________________________________ the first lesson. - ================================================================= = BASIC CURSOR MOVEMENT = ================================================================= @@ -43,7 +42,6 @@ _________________________________________________________________ - ================================================================= = EXITING HELIX = ================================================================= @@ -66,7 +64,6 @@ _________________________________________________________________ - ================================================================= = DELETION = ================================================================= @@ -89,7 +86,6 @@ _________________________________________________________________ - ================================================================= = INSERT MODE = ================================================================= @@ -112,7 +108,6 @@ _________________________________________________________________ Note: The status bar will display your current mode. Notice that when you press i, 'NOR' changes to 'INS'. - ================================================================= = MORE ON INSERT MODE = ================================================================= @@ -123,7 +118,7 @@ _________________________________________________________________ Common examples of insertion commands include: i - Insert before the selection. - a - Insert after the selection. (a means "append") + a - Insert after the selection. (a means 'append') I - Insert at the start of the line. A - Insert at the end of the line. @@ -135,7 +130,6 @@ _________________________________________________________________ --> This sentence is miss This sentence is missing some text. - ================================================================= = SAVING A FILE = ================================================================= @@ -158,7 +152,6 @@ _________________________________________________________________ - ================================================================= = RECAP = ================================================================= @@ -181,7 +174,6 @@ _________________________________________________________________ - ================================================================= = MOTIONS AND SELECTIONS = ================================================================= @@ -204,7 +196,6 @@ _________________________________________________________________ - ================================================================= = MORE ON MOTIONS = ================================================================= @@ -227,6 +218,203 @@ _________________________________________________________________ +================================================================= += THE CHANGE COMMAND = +================================================================= + + Press c to change the current selection. + + The change command deletes the current selection and enters + Insert mode, so it is a very common shorthand for di. + + 1. Move the cursor to the line below marked -->. + 2. Move to the start of an incorrect word and press w to + select it. + 3. Press c to delete the word and enter Insert mode. + 4. Type the correct word. + 5. Repeat until the line matches the line below it. + + --> This paper has heavy words behind it. + This sentence has incorrect words in it. + + + + +================================================================= += COUNTS WITH MOTIONS = +================================================================= + + Type a number before a motion to repeat it that many times. + + 1. Move the cursor to the line below marked -->. + + 2. Type 2w to move 2 words forward. + + 3. Type 3e to move to the end of the third word forward. + + 4. Type 2b to move 2 words backwards + + 5. Try the above with different numbers. + + --> This is just a line with words you can move around in. + + + + + +================================================================= += SELECTING LINES = +================================================================= + + Press x to select a whole line. Press again to select the next. + + 1. Move the cursor to the second line below marked -->. + 2. Press x to select the line, and d to delete it. + 3. Move to the fourth line. + 4. Press x twice or type 2x to select 2 lines, and d to delete. + + --> 1) Roses are red, + --> 2) Mud is fun, + --> 3) Violets are blue, + --> 4) I have a car, + --> 5) Clocks tell time, + --> 6) Sugar is sweet, + --> 7) And so are you. + + + + +================================================================= += UNDOING = +================================================================= + + Type u to undo. Type U to redo. + + 1. Move the cursor to the line below marked -->. + 2. Move to the first error, and press d to delete it. + 3. Type u to undo your deletion. + 4. Fix all the errors on the line. + 5. Type u several times to undo your fixes. + 6. Type U ( + u) several times to redo your fixes. + + --> Fiix the errors on thhis line and reeplace them witth undo. + + + + + + + + +================================================================= += RECAP = +================================================================= + + * Type w to select forward until the next word. + * Type e to select to the end of the current word. + * Type b to select backward to the start of the current word. + * Use uppercase counterparts, W,E,B, to traverse WORDS. + + * Typing d deletes the entire selection, so you can delete a + word forward by typing wd. + + * Type c to delete the selection and enter Insert mode. + + * Type a number before a motion to repeat it that many times. + + * Type x to select the entire current line. Type x again to + select the next line. + + * Type u to undo. Type U to redo. + + +================================================================= += MULTIPLE CURSORS = +================================================================= + + Type C to duplicate the cursor to the next line. + + 1. Move the cursor to the first line below marked -->. + 2. Type C to duplicate the cursor to the next line. Keys you + press will now affect both cursors. + 3. Use Insert mode to correct the lines. The two cursors will + fix both lines simultaneously. + 4. Type , to remove the second cursor. + + --> Fix th two nes at same ime. + --> Fix th two nes at same ime. + + Fix these two lines at the same time. + + + + + +================================================================= += THE SELECT COMMAND = +================================================================= + + Type s to select matches in the selection. + + 1. Move the cursor to the line below marked -->. + 2. Press x to select the line. + 3. Press s. A prompt will appear. + 4. Type 'apples' and press . Both occurrences of + 'apples' in the line will be selected. + 5. You can now press c and change 'apples' to something else, + like 'oranges'. + 6. Type , to remove the second cursor. + + --> I like to eat apples since my favorite fruit is apples. + + + + + + +================================================================= += SELECTING VIA REGEX = +================================================================= + + The select command selects regular expressions, not just exact + matches, allowing you to target more complex patterns. + + 1. Move the cursor to the line below marked -->. + 2. Select the line with x and then press s. + 3. Enter ' +' to select any amount of consecutive spaces >1. + 4. Press c and change the matches to single spaces. + + --> This sentence has some extra spaces. + + Note: If you want to perform find-and-replace, the select + command is the way to do it. Select the text you want + to replace in — type % to select the whole file — and + then perform the steps explained above. + + + + +================================================================= += COLLAPSING SELECTIONS = +================================================================= + + Type ; to collapse selections to single cursors. + + Sometimes, you want to deselect without having to move the + cursor(s). This can be done using the ; key. + + 1. Move the cursor to the line below marked -->. + + 2. Use the motions you have learned to move around the line, + and try using ; to deselect the text after it is selected + by the motions. + + --> This is an error-free line with words to move around in. + + + + + ================================================================= This tutorial is still a work-in-progress. -- cgit v1.2.3-70-g09d2 From e069fb9dea0d41eedb9257050f2231b7b0b88d0e Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sat, 16 Oct 2021 03:58:04 -0500 Subject: Add highlight support for tree-sitter-query language (tsq) (#845) * add submodule on tree-sitter/tree-sitter-tsq mark tsq submodule as shallow * add tree-sitter-tsq to languages * add highlight queries for tsq * Update .gitmodules Co-authored-by: Blaž Hrastnik --- .gitmodules | 4 +++ helix-syntax/languages/tree-sitter-tsq | 1 + languages.toml | 8 ++++++ runtime/queries/tsq/highlights.scm | 46 ++++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-tsq create mode 100644 runtime/queries/tsq/highlights.scm (limited to 'runtime') diff --git a/.gitmodules b/.gitmodules index 95b3670b..a8e6481e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -126,3 +126,7 @@ path = helix-syntax/languages/tree-sitter-vue url = https://github.com/ikatyang/tree-sitter-vue shallow = true +[submodule "helix-syntax/languages/tree-sitter-tsq"] + path = helix-syntax/languages/tree-sitter-tsq + url = https://github.com/tree-sitter/tree-sitter-tsq + shallow = true diff --git a/helix-syntax/languages/tree-sitter-tsq b/helix-syntax/languages/tree-sitter-tsq new file mode 160000 index 00000000..b665659d --- /dev/null +++ b/helix-syntax/languages/tree-sitter-tsq @@ -0,0 +1 @@ +Subproject commit b665659d3238e6036e22ed0e24935e60efb39415 diff --git a/languages.toml b/languages.toml index 7715425b..60b996c0 100644 --- a/languages.toml +++ b/languages.toml @@ -328,3 +328,11 @@ language-server = { command = "swipl", args = [ "-g", "use_module(library(lsp_server))", "-g", "lsp_server:main", "-t", "halt", "--", "stdio"] } + +[[language]] +name = "tsq" +scope = "source.tsq" +file-types = ["scm"] +roots = [] +comment-token = ";" +indent = { tab-width = 2, unit = " " } diff --git a/runtime/queries/tsq/highlights.scm b/runtime/queries/tsq/highlights.scm new file mode 100644 index 00000000..9ba5699a --- /dev/null +++ b/runtime/queries/tsq/highlights.scm @@ -0,0 +1,46 @@ +; mark the string passed #match? as a regex +(((predicate_name) @function + (capture) + (string) @string.regexp) + (#eq? @function "#match?")) + +; highlight inheritance comments +((query . (comment) @keyword.directive) + (#match? @keyword.directive "^;\ +inherits *:")) + +[ + "(" + ")" + "[" + "]" +] @punctuation.bracket + +":" @punctuation.delimiter + +[ + (one_or_more) + (zero_or_one) + (zero_or_more) +] @operator + +[ + (wildcard_node) + (anchor) +] @constant.builtin + +[ + (anonymous_leaf) + (string) +] @string + +(comment) @comment + +(field_name) @property + +(capture) @label + +(predicate_name) @function + +(escape_sequence) @escape + +(node_name) @variable -- cgit v1.2.3-70-g09d2 From be428a295a0884ed0523a8a995e913ee1c863b60 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sat, 16 Oct 2021 04:02:06 -0500 Subject: fix digit escapes in java & php highlights (#846) --- runtime/queries/java/highlights.scm | 2 +- runtime/queries/php/highlights.scm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/queries/java/highlights.scm b/runtime/queries/java/highlights.scm index 3f8ae0d5..e7d793df 100644 --- a/runtime/queries/java/highlights.scm +++ b/runtime/queries/java/highlights.scm @@ -47,7 +47,7 @@ ; Variables ((identifier) @constant - (#match? @constant "^_*[A-Z][A-Z\d_]+")) + (#match? @constant "^_*[A-Z][A-Z\\d_]+$")) (identifier) @variable diff --git a/runtime/queries/php/highlights.scm b/runtime/queries/php/highlights.scm index 83850403..02904555 100644 --- a/runtime/queries/php/highlights.scm +++ b/runtime/queries/php/highlights.scm @@ -42,7 +42,7 @@ (relative_scope) @variable.builtin ((name) @constant - (#match? @constant "^_?[A-Z][A-Z\d_]+$")) + (#match? @constant "^_?[A-Z][A-Z\\d_]+$")) ((name) @constructor (#match? @constructor "^[A-Z]")) -- cgit v1.2.3-70-g09d2 From e216e9621e73cda1968632cd20595231af5e07be Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sat, 16 Oct 2021 23:45:09 -0500 Subject: Enable c-sharp language and highlights (#861) --- languages.toml | 10 ++ runtime/queries/c-sharp/highlights.scm | 238 +++++++++++++++++++++++++++++++++ 2 files changed, 248 insertions(+) create mode 100644 runtime/queries/c-sharp/highlights.scm (limited to 'runtime') diff --git a/languages.toml b/languages.toml index 60b996c0..67f4d3d6 100644 --- a/languages.toml +++ b/languages.toml @@ -74,6 +74,16 @@ comment-token = "//" language-server = { command = "clangd" } indent = { tab-width = 2, unit = " " } +[[language]] +name = "c-sharp" +scope = "source.csharp" +injection-regex = "c-?sharp" +file-types = ["cs"] +roots = [] +comment-token = "//" + +indent = { tab-width = 4, unit = "\t" } + [[language]] name = "go" scope = "source.go" diff --git a/runtime/queries/c-sharp/highlights.scm b/runtime/queries/c-sharp/highlights.scm new file mode 100644 index 00000000..b76f4e60 --- /dev/null +++ b/runtime/queries/c-sharp/highlights.scm @@ -0,0 +1,238 @@ +;; Methods +(method_declaration (identifier) @type (identifier) @function) + +;; Types +(interface_declaration name: (identifier) @type) +(class_declaration name: (identifier) @type) +(enum_declaration name: (identifier) @type) +(struct_declaration (identifier) @type) +(record_declaration (identifier) @type) +(namespace_declaration name: (identifier) @type) + +(constructor_declaration name: (identifier) @type) + +[ + (implicit_type) + (nullable_type) + (pointer_type) + (function_pointer_type) + (predefined_type) +] @type.builtin + +;; Enum +(enum_member_declaration (identifier) @variable.property) + +;; Literals +[ + (real_literal) + (integer_literal) +] @number + +[ + (character_literal) + (string_literal) + (verbatim_string_literal) + (interpolated_string_text) + (interpolated_verbatim_string_text) + "\"" + "$\"" + "@$\"" + "$@\"" + ] @string + +[ + (boolean_literal) + (null_literal) + (void_keyword) +] @constant.builtin + +;; Comments +(comment) @comment + +;; Tokens +[ + ";" + "." + "," +] @punctuation.delimiter + +[ + "--" + "-" + "-=" + "&" + "&&" + "+" + "++" + "+=" + "<" + "<<" + "=" + "==" + "!" + "!=" + "=>" + ">" + ">>" + "|" + "||" + "?" + "??" + "^" + "~" + "*" + "/" + "%" + ":" +] @operator + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +;; Keywords +(modifier) @keyword +(this_expression) @keyword +(escape_sequence) @keyword + +[ + "as" + "base" + "break" + "case" + "catch" + "checked" + "class" + "continue" + "default" + "delegate" + "do" + "else" + "enum" + "event" + "explicit" + "finally" + "for" + "foreach" + "goto" + "if" + "implicit" + "interface" + "is" + "lock" + "namespace" + "operator" + "params" + "return" + "sizeof" + "stackalloc" + "struct" + "switch" + "throw" + "try" + "typeof" + "unchecked" + "using" + "while" + "new" + "await" + "in" + "yield" + "get" + "set" + "when" + "out" + "ref" + "from" + "where" + "select" + "record" + "init" + "with" + "let" +] @keyword + + +;; Linq +(from_clause (identifier) @variable) +(group_clause) +(order_by_clause) +(select_clause (identifier) @variable) +(query_continuation (identifier) @variable) @keyword + +;; Record +(with_expression + (with_initializer_expression + (simple_assignment_expression + (identifier) @variable))) + +;; Exprs +(binary_expression (identifier) @variable (identifier) @variable) +(binary_expression (identifier)* @variable) +(conditional_expression (identifier) @variable) +(prefix_unary_expression (identifier) @variable) +(postfix_unary_expression (identifier)* @variable) +(assignment_expression (identifier) @variable) +(cast_expression (identifier) @type (identifier) @variable) + +;; Class +(base_list (identifier) @type) +(property_declaration (generic_name)) +(property_declaration + type: (nullable_type) @type + name: (identifier) @variable) +(property_declaration + type: (predefined_type) @type + name: (identifier) @variable) +(property_declaration + type: (identifier) @type + name: (identifier) @variable) + +;; Lambda +(lambda_expression) @variable + +;; Attribute +(attribute) @type + +;; Parameter +(parameter + type: (identifier) @type + name: (identifier) @variable.parameter) +(parameter (identifier) @variable.parameter) +(parameter_modifier) @keyword + +;; Typeof +(type_of_expression (identifier) @type) + +;; Variable +(variable_declaration (identifier) @type) +(variable_declarator (identifier) @variable) + +;; Return +(return_statement (identifier) @variable) +(yield_statement (identifier) @variable) + +;; Type +(generic_name (identifier) @type) +(type_parameter (identifier) @variable.parameter) +(type_argument_list (identifier) @type) + +;; Type constraints +(type_parameter_constraints_clause (identifier) @variable.parameter) +(type_constraint (identifier) @type) + +;; Exception +(catch_declaration (identifier) @type (identifier) @variable) +(catch_declaration (identifier) @type) + +;; Switch +(switch_statement (identifier) @variable) +(switch_expression (identifier) @variable) + +;; Lock statement +(lock_statement (identifier) @variable) -- cgit v1.2.3-70-g09d2