From cb01e52cd8b8021686ee98dd4d53dff8cdc826a9 Mon Sep 17 00:00:00 2001 From: Mike Trinkala Date: Thu, 7 Mar 2024 09:20:07 -0800 Subject: [PATCH 001/336] Fix panic in surround_replace/delete nested multi-cursor (#9815) Test Document ------------- ``` {{ } } ``` Steps To Reproduce ------------------ 1. 2j # move_visual_line_down 1. C # copy_selection_on_next_line 1. mdm # surround_delete Debug ----- `assertion failed: last <= from', transaction.rs:597:13` Release ------- `called `Result::unwrap()` on an `Err` value: Char range out of bounds: char range 18446744073709551614..18446744073709551615, Rope/RopeSlice char length 7', ropey-1.6.1/src/rope.rs:546:37` Description ----------- Processing the surrounding pairs in order violates the assertion the ranges are ordered. To handle nested surrounds all positions have to be sorted. Also surround_replace has to track the proper replacement character for each position. --- helix-term/src/commands.rs | 19 ++++++++++++++----- helix-term/tests/test/movement.rs | 29 +++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 0b2ea0b8a..4ac2496eb 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -5282,12 +5282,21 @@ fn surround_replace(cx: &mut Context) { None => return doc.set_selection(view.id, selection), }; let (open, close) = surround::get_pair(to); + + // the changeset has to be sorted to allow nested surrounds + let mut sorted_pos: Vec<(usize, char)> = Vec::new(); + for p in change_pos.chunks(2) { + sorted_pos.push((p[0], open)); + sorted_pos.push((p[1], close)); + } + sorted_pos.sort_unstable(); + let transaction = Transaction::change( doc.text(), - change_pos.iter().enumerate().map(|(i, &pos)| { + sorted_pos.iter().map(|&pos| { let mut t = Tendril::new(); - t.push(if i % 2 == 0 { open } else { close }); - (pos, pos + 1, Some(t)) + t.push(pos.1); + (pos.0, pos.0 + 1, Some(t)) }), ); doc.set_selection(view.id, selection); @@ -5309,14 +5318,14 @@ fn surround_delete(cx: &mut Context) { let text = doc.text().slice(..); let selection = doc.selection(view.id); - let change_pos = match surround::get_surround_pos(text, selection, surround_ch, count) { + let mut change_pos = match surround::get_surround_pos(text, selection, surround_ch, count) { Ok(c) => c, Err(err) => { cx.editor.set_error(err.to_string()); return; } }; - + change_pos.sort_unstable(); // the changeset has to be sorted to allow nested surrounds let transaction = Transaction::change(doc.text(), change_pos.into_iter().map(|p| (p, p + 1, None))); doc.apply(&transaction, view.id); diff --git a/helix-term/tests/test/movement.rs b/helix-term/tests/test/movement.rs index 0873edbe5..4ebaae854 100644 --- a/helix-term/tests/test/movement.rs +++ b/helix-term/tests/test/movement.rs @@ -577,6 +577,23 @@ async fn test_surround_replace() -> anyhow::Result<()> { )) .await?; + test(( + platform_line(indoc! {"\ + {{ + + #(}|)# + #[}|]# + "}), + "mrm)", + platform_line(indoc! {"\ + (( + + #()|)# + #[)|]# + "}), + )) + .await?; + Ok(()) } @@ -604,5 +621,17 @@ async fn test_surround_delete() -> anyhow::Result<()> { )) .await?; + test(( + platform_line(indoc! {"\ + {{ + + #(}|)# + #[}|]# + "}), + "mdm", + platform_line("\n\n#(\n|)##[\n|]#"), + )) + .await?; + Ok(()) } From e27b04735c630140b45ac9fab1b3087ae831f34a Mon Sep 17 00:00:00 2001 From: Mike Trinkala Date: Thu, 7 Mar 2024 11:37:01 -0800 Subject: [PATCH 002/336] Fix panic in select_textobject_around (#9832) Test Document ------------- ``` a)b ``` Steps to Reproduce ------------------ 1. % # select_all 1. ms( # surround_add 1. mam # select_textobject_around Debug and Release ----------------- `thread 'main' panicked at 'Attempt to index past end of RopeSlice: char index 7, RopeSlice char length 6', ropey-1.6.1/src/slice.rs:796:13` Description ----------- An index was selected beyond the end of the slice with chars_at. The fix adds a guard check to `find_nth_open_pair`, like in the other find_nth* functions. --- helix-core/src/surround.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/helix-core/src/surround.rs b/helix-core/src/surround.rs index 513f87493..ed9764883 100644 --- a/helix-core/src/surround.rs +++ b/helix-core/src/surround.rs @@ -167,6 +167,10 @@ fn find_nth_open_pair( mut pos: usize, n: usize, ) -> Option { + if pos >= text.len_chars() { + return None; + } + let mut chars = text.chars_at(pos + 1); // Adjusts pos for the first iteration, and handles the case of the @@ -383,6 +387,21 @@ mod test { ) } + #[test] + fn test_find_nth_closest_pairs_pos_index_range_panic() { + #[rustfmt::skip] + let (doc, selection, _) = + rope_with_selections_and_expectations( + "(a)c)", + "^^^^^" + ); + + assert_eq!( + find_nth_closest_pairs_pos(doc.slice(..), selection.primary(), 1), + Err(Error::PairNotFound) + ) + } + // Create a Rope and a matching Selection using a specification language. // ^ is a single-point selection. // _ is an expected index. These are returned as a Vec for use in assertions. From 301dfb07ccf3df41c381300dddb760bf76745cf5 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 7 Mar 2024 22:39:00 +0000 Subject: [PATCH 003/336] Add PowerShell highlighting (#9827) --- book/src/generated/lang-support.md | 1 + languages.toml | 14 ++ runtime/queries/powershell/highlights.scm | 174 ++++++++++++++++++++++ runtime/queries/powershell/injections.scm | 2 + 4 files changed, 191 insertions(+) create mode 100644 runtime/queries/powershell/highlights.scm create mode 100644 runtime/queries/powershell/injections.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index c9668549e..9149acadf 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -132,6 +132,7 @@ | po | ✓ | ✓ | | | | pod | ✓ | | | | | ponylang | ✓ | ✓ | ✓ | | +| powershell | ✓ | | | | | prisma | ✓ | | | `prisma-language-server` | | prolog | | | | `swipl` | | protobuf | ✓ | ✓ | ✓ | `bufls`, `pb` | diff --git a/languages.toml b/languages.toml index 49672a30b..70953b990 100644 --- a/languages.toml +++ b/languages.toml @@ -3259,3 +3259,17 @@ indent = { tab-width = 4, unit = " " } [[grammar]] name = "fidl" source = { git = "https://github.com/google/tree-sitter-fidl", rev = "bdbb635a7f5035e424f6173f2f11b9cd79703f8d" } + +[[language]] +name = "powershell" +scope = "source.powershell" +injection-regex = "(pwsh|powershell)" +file-types = [ "ps1", "psm1", "psd1", "pscc", "psrc" ] +shebangs = [ "pwsh", "powershell" ] +comment-token = '#' +block-comment-tokens = { start = "<#", end = "#>" } +indent = { tab-width = 4, unit = " " } + +[[grammar]] +name = "powershell" +source = { git = "https://github.com/airbus-cert/tree-sitter-powershell", rev = "c9316be0faca5d5b9fd3b57350de650755f42dc0" } diff --git a/runtime/queries/powershell/highlights.scm b/runtime/queries/powershell/highlights.scm new file mode 100644 index 000000000..c62c72814 --- /dev/null +++ b/runtime/queries/powershell/highlights.scm @@ -0,0 +1,174 @@ +[ + "if" + "elseif" + "else" + "switch" +] @keyword.control.conditional + +[ + "foreach" + "for" + "while" + "do" + "until" +] @keyword.control.repeat + +[ + "break" + "continue" + "return" +] @keyword.control.return + +"in" @keyword.operator + +"function" @keyword.function + +[ + "class" + "enum" +] @keyword.storage.type + +[ + "param" + "dynamicparam" + "begin" + "process" + "end" + "filter" + "workflow" + "throw" + "exit" + "trap" + "try" + "catch" + "finally" + "data" + "inlinescript" + "parallel" + "sequence" +] @keyword + +[ + "-as" + "-ccontains" + "-ceq" + "-cge" + "-cgt" + "-cle" + "-clike" + "-clt" + "-cmatch" + "-cne" + "-cnotcontains" + "-cnotlike" + "-cnotmatch" + "-contains" + "-creplace" + "-csplit" + "-eq" + "-ge" + "-gt" + "-icontains" + "-ieq" + "-ige" + "-igt" + "-ile" + "-ilike" + "-ilt" + "-imatch" + "-in" + "-ine" + "-inotcontains" + "-inotlike" + "-inotmatch" + "-ireplace" + "-is" + "-isnot" + "-isplit" + "-join" + "-le" + "-like" + "-lt" + "-match" + "-ne" + "-not" + "-notcontains" + "-notin" + "-notlike" + "-notmatch" + "-replace" + "-shl" + "-shr" + "-split" + "-and" + "-or" + "-xor" + "-band" + "-bor" + "-bxor" + "+" + "-" + "*" + "/" + "%" + "++" + "--" + "!" + "\\" + ".." + "|" +] @operator + +(assignement_operator) @operator + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +[ + ";" + "," + "::" +] @punctuation.delimiter + +(string_literal) @string + +(integer_literal) @constant.numeric +(real_literal) @constant.numeric + +(command + command_name: (command_name) @function) + +(function_name) @function + +(invokation_expression + (member_name) @function) + +(member_access + (member_name) @variable.other.member) + +(command_invokation_operator) @operator + +(type_spec) @type + +(variable) @variable + +(comment) @comment + +(array_expression) @punctuation.bracket + +(assignment_expression + value: (pipeline) @variable) + +(format_operator) @operator + +(command_parameter) @variable.parameter + +(command_elements) @variable.builtin + +(generic_token) @variable diff --git a/runtime/queries/powershell/injections.scm b/runtime/queries/powershell/injections.scm new file mode 100644 index 000000000..321c90add --- /dev/null +++ b/runtime/queries/powershell/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) From fd89c3c8335399e344e038f1141ea0657653a591 Mon Sep 17 00:00:00 2001 From: Alexander Brevig Date: Fri, 8 Mar 2024 02:54:17 +0100 Subject: [PATCH 004/336] fix: close #9771 fix comments with `(` and `)` (#9800) * fix: close #9771 update OCaml * fix: no longer match on ( ) as the underlying grammar handles these * fix: implement excellent corrections from review * fix: module -> namespace to match theme scopes --- languages.toml | 4 +- runtime/queries/comment/highlights.scm | 5 - runtime/queries/ocaml/highlights.scm | 141 ++++++++++++------------- 3 files changed, 67 insertions(+), 83 deletions(-) diff --git a/languages.toml b/languages.toml index 70953b990..e96f06183 100644 --- a/languages.toml +++ b/languages.toml @@ -1095,7 +1095,7 @@ indent = { tab-width = 2, unit = " " } [[grammar]] name = "ocaml" -source = { git = "https://github.com/tree-sitter/tree-sitter-ocaml", rev = "23d419ba45789c5a47d31448061557716b02750a", subpath = "ocaml" } +source = { git = "https://github.com/tree-sitter/tree-sitter-ocaml", rev = "9965d208337d88bbf1a38ad0b0fe49e5f5ec9677", subpath = "ocaml" } [[language]] name = "ocaml-interface" @@ -1115,7 +1115,7 @@ indent = { tab-width = 2, unit = " " } [[grammar]] name = "ocaml-interface" -source = { git = "https://github.com/tree-sitter/tree-sitter-ocaml", rev = "23d419ba45789c5a47d31448061557716b02750a", subpath = "interface" } +source = { git = "https://github.com/tree-sitter/tree-sitter-ocaml", rev = "9965d208337d88bbf1a38ad0b0fe49e5f5ec9677", subpath = "interface" } [[language]] name = "lua" diff --git a/runtime/queries/comment/highlights.scm b/runtime/queries/comment/highlights.scm index 4cefcdf74..ba26ca0bf 100644 --- a/runtime/queries/comment/highlights.scm +++ b/runtime/queries/comment/highlights.scm @@ -1,8 +1,3 @@ -[ - "(" - ")" -] @punctuation.bracket - ":" @punctuation.delimiter ; Hint level tags diff --git a/runtime/queries/ocaml/highlights.scm b/runtime/queries/ocaml/highlights.scm index 9d3bf4c8b..f2a4f0a4c 100644 --- a/runtime/queries/ocaml/highlights.scm +++ b/runtime/queries/ocaml/highlights.scm @@ -6,9 +6,12 @@ ; Types ;------ -[(class_name) (class_type_name) (type_constructor)] @type +( + (type_constructor) @type.builtin + (#match? @type.builtin "^(int|char|bytes|string|float|bool|unit|exn|array|list|option|int32|int64|nativeint|format6|lazy_t)$") +) -(type_variable) @type.parameter +[(class_name) (class_type_name) (type_constructor)] @type [(constructor_name) (tag)] @constructor @@ -29,27 +32,34 @@ (method_name) @function.method -; Variables -;---------- - -(value_pattern) @variable.parameter - ; Application ;------------ +( + (value_name) @function.builtin + (#match? @function.builtin "^(raise(_notrace)?|failwith|invalid_arg)$") +) + (infix_expression left: (value_path (value_name) @function) - (infix_operator) @operator + operator: (concat_operator) @operator (#eq? @operator "@@")) (infix_expression - (infix_operator) @operator + operator: (rel_operator) @operator right: (value_path (value_name) @function) (#eq? @operator "|>")) (application_expression function: (value_path (value_name) @function)) +; Variables +;---------- + +[(value_name) (type_variable)] @variable + +(value_pattern) @variable.parameter + ; Properties ;----------- @@ -58,55 +68,68 @@ ; Constants ;---------- -[(boolean) (unit)] @constant - -[(number) (signed_number)] @constant.numeric.integer +(boolean) @constant.builtin.boolean -(character) @constant.character +[(number) (signed_number)] @constant.numeric -(string) @string +[(string) (character)] @string (quoted_string "{" @string "}" @string) @string (escape_sequence) @constant.character.escape +(conversion_specification) @string.special + +; Operators +;---------- + +(match_expression (match_operator) @keyword) + +(value_definition [(let_operator) (let_and_operator)] @keyword) + [ - (conversion_specification) - (pretty_printing_indication) -] @punctuation.special + (prefix_operator) + (sign_operator) + (pow_operator) + (mult_operator) + (add_operator) + (concat_operator) + (rel_operator) + (and_operator) + (or_operator) + (assign_operator) + (hash_operator) + (indexing_operator) + (let_operator) + (let_and_operator) + (match_operator) +] @operator + +["*" "#" "::" "<-"] @operator ; Keywords ;--------- [ - "and" "as" "assert" "begin" "class" "constraint" - "end" "external" "in" - "inherit" "initializer" "lazy" "let" "match" "method" "module" - "mutable" "new" "nonrec" "object" "of" "private" "rec" "sig" "struct" - "type" "val" "virtual" "when" "with" + "and" "as" "assert" "begin" "class" "constraint" "do" "done" "downto" "else" + "end" "exception" "external" "for" "fun" "function" "functor" "if" "in" + "include" "inherit" "initializer" "lazy" "let" "match" "method" "module" + "mutable" "new" "nonrec" "object" "of" "open" "private" "rec" "sig" "struct" + "then" "to" "try" "type" "val" "virtual" "when" "while" "with" ] @keyword -["fun" "function" "functor"] @keyword.function - -["if" "then" "else"] @keyword.control.conditional - -["exception" "try"] @keyword.control.exception - -["include" "open"] @keyword.control.import - -["for" "to" "downto" "while" "do" "done"] @keyword.control.repeat +; Punctuation +;------------ -; Macros -;------- +(attribute ["[@" "]"] @punctuation.special) +(item_attribute ["[@@" "]"] @punctuation.special) +(floating_attribute ["[@@@" "]"] @punctuation.special) +(extension ["[%" "]"] @punctuation.special) +(item_extension ["[%%" "]"] @punctuation.special) +(quoted_extension ["{%" "}"] @punctuation.special) +(quoted_item_extension ["{%%" "}"] @punctuation.special) -(attribute ["[@" "]"] @attribute) -(item_attribute ["[@@" "]"] @attribute) -(floating_attribute ["[@@@" "]"] @attribute) -(extension ["[%" "]"] @function.macro) -(item_extension ["[%%" "]"] @function.macro) -(quoted_extension ["{%" "}"] @function.macro) -(quoted_item_extension ["{%%" "}"] @function.macro) -"%" @function.macro +"%" @punctuation.special ["(" ")" "[" "]" "{" "}" "[|" "|]" "[<" "[>"] @punctuation.bracket @@ -117,46 +140,12 @@ "->" ";;" ":>" "+=" ":=" ".." ] @punctuation.delimiter -; Operators -;---------- - -[ - (prefix_operator) - (sign_operator) - (infix_operator) - (hash_operator) - (indexing_operator) - (let_operator) - (and_operator) - (match_operator) -] @operator - -(match_expression (match_operator) @keyword) - -(value_definition [(let_operator) (and_operator)] @keyword) - -;; TODO: this is an error now -;(prefix_operator "!" @operator) - -(infix_operator ["&" "+" "-" "=" ">" "|" "%"] @operator) - -(signed_number ["+" "-"] @operator) - -["*" "#" "::" "<-"] @operator - ; Attributes ;----------- -(attribute_id) @variable.other.member +(attribute_id) @tag ; Comments ;--------- [(comment) (line_number_directive) (directive) (shebang)] @comment - -(ERROR) @error - -; Blanket highlights -; ------------------ - -[(value_name) (type_variable)] @variable From e3c6c82828299f1728f16a8d8fcfa5c3603a3d47 Mon Sep 17 00:00:00 2001 From: Matthew Toohey Date: Sat, 9 Mar 2024 02:59:56 -0500 Subject: [PATCH 005/336] add linker script language (#9835) --- book/src/generated/lang-support.md | 1 + languages.toml | 12 ++ runtime/queries/ld/highlights.scm | 173 +++++++++++++++++++++++++++++ runtime/queries/ld/indents.scm | 12 ++ runtime/queries/ld/injections.scm | 2 + 5 files changed, 200 insertions(+) create mode 100644 runtime/queries/ld/highlights.scm create mode 100644 runtime/queries/ld/indents.scm create mode 100644 runtime/queries/ld/injections.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 9149acadf..7792bf594 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -94,6 +94,7 @@ | kdl | ✓ | ✓ | ✓ | | | kotlin | ✓ | | | `kotlin-language-server` | | latex | ✓ | ✓ | | `texlab` | +| ld | ✓ | | ✓ | | | lean | ✓ | | | `lean` | | ledger | ✓ | | | | | llvm | ✓ | ✓ | ✓ | | diff --git a/languages.toml b/languages.toml index e96f06183..2e9f5d195 100644 --- a/languages.toml +++ b/languages.toml @@ -3273,3 +3273,15 @@ indent = { tab-width = 4, unit = " " } [[grammar]] name = "powershell" source = { git = "https://github.com/airbus-cert/tree-sitter-powershell", rev = "c9316be0faca5d5b9fd3b57350de650755f42dc0" } + +[[language]] +name = "ld" +scope = "source.ld" +injection-regex = "ld" +file-types = ["ld"] +block-comment-tokens = { start = "/*", end = "*/" } +indent = { tab-width = 2, unit = " " } + +[[grammar]] +name = "ld" +source = { git = "https://github.com/mtoohey31/tree-sitter-ld", rev = "81978cde3844bfc199851e39c80a20ec6444d35e" } diff --git a/runtime/queries/ld/highlights.scm b/runtime/queries/ld/highlights.scm new file mode 100644 index 000000000..4f935e753 --- /dev/null +++ b/runtime/queries/ld/highlights.scm @@ -0,0 +1,173 @@ +; Identifiers + +(section + . + (NAME) @namespace) + +(NAME) @variable + +; Operators + +[ + "=" + "+=" + "-=" + "*=" + "/=" + "<<=" + ">>=" + "&=" + "|=" + "^=" + "*" + "/" + "%" + "+" + "-" + "<<" + ">>" + "==" + "!=" + "<=" + ">=" + "<" + ">" + "&" + "^" + "|" + "&&" + "||" + "?" +] @operator + +; Keywords + +[ + "ABSOLUTE" + "ADDR" + "ALIGNOF" + "ASSERT" + "BYTE" + "CONSTANT" + "DATA_SEGMENT_ALIGN" + "DATA_SEGMENT_END" + "DATA_SEGMENT_RELRO_END" + "DEFINED" + "LOADADDR" + "LOG2CEIL" + "LONG" + "MAX" + "MIN" + "NEXT" + "QUAD" + "SHORT" + "SIZEOF" + "SQUAD" + "FILL" + "SEGMENT_START" +] @function.builtin + +[ + "CONSTRUCTORS" + "CREATE_OBJECT_SYMBOLS" + "LINKER_VERSION" + "SIZEOF_HEADERS" +] @constant.builtin + +[ + "AFTER" + "ALIGN" + "ALIGN_WITH_INPUT" + "ASCIZ" + "AS_NEEDED" + "AT" + "BEFORE" + "BIND" + "BLOCK" + "COPY" + "DSECT" + "ENTRY" + "EXCLUDE_FILE" + "EXTERN" + "extern" + "FLOAT" + "FORCE_COMMON_ALLOCATION" + "FORCE_GROUP_ALLOCATION" + "global" + "GROUP" + "HIDDEN" + "HLL" + "INCLUDE" + "INFO" + "INHIBIT_COMMON_ALLOCATION" + "INPUT" + "INPUT_SECTION_FLAGS" + "KEEP" + "l" + "LD_FEATURE" + "len" + "LENGTH" + "local" + "MAP" + "MEMORY" + "NOCROSSREFS" + "NOCROSSREFS_TO" + "NOFLOAT" + "NOLOAD" + "o" + "ONLY_IF_RO" + "ONLY_IF_RW" + "org" + "ORIGIN" + "OUTPUT" + "OUTPUT_ARCH" + "OUTPUT_FORMAT" + "OVERLAY" + "PHDRS" + "PROVIDE" + "PROVIDE_HIDDEN" + "READONLY" + "REGION_ALIAS" + "REVERSE" + "SEARCH_DIR" + "SECTIONS" + "SORT" + "SORT_BY_ALIGNMENT" + "SORT_BY_INIT_PRIORITY" + "SORT_BY_NAME" + "SORT_NONE" + "SPECIAL" + "STARTUP" + "SUBALIGN" + "SYSLIB" + "TARGET" + "TYPE" + "VERSION" +] @keyword + +; Delimiters + +[ + "," + ";" + "&" + ":" + ">" +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +; Literals + +(INT) @constant.numeric.integer + +; Comment + +(comment) @comment diff --git a/runtime/queries/ld/indents.scm b/runtime/queries/ld/indents.scm new file mode 100644 index 000000000..2e2928b5d --- /dev/null +++ b/runtime/queries/ld/indents.scm @@ -0,0 +1,12 @@ +[ + (sections) + (memory) + (section) + (phdrs) + (overlay_section) + (version) + (vers_node) + (vers_defns) +] @indent + +"}" @outdent @extend.prevent-once diff --git a/runtime/queries/ld/injections.scm b/runtime/queries/ld/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/ld/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) From 0dc67ff8852ce99d40ad4464062ebe212b0b03a1 Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Sat, 9 Mar 2024 09:02:43 +0100 Subject: [PATCH 006/336] helix-term: allow to backspace out-of the command prompt (#9828) --- helix-term/src/ui/prompt.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index a6ee7f05d..d46c13138 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -544,6 +544,10 @@ impl Component for Prompt { (self.callback_fn)(cx, &self.line, PromptEvent::Update); } ctrl!('h') | key!(Backspace) | shift!(Backspace) => { + if self.line.is_empty() { + (self.callback_fn)(cx, &self.line, PromptEvent::Abort); + return close_fn; + } self.delete_char_backwards(cx.editor); (self.callback_fn)(cx, &self.line, PromptEvent::Update); } From 3bd493299fe632a7ff09fbd4c92c702ba3d0853f Mon Sep 17 00:00:00 2001 From: Aidan Gauland Date: Sun, 10 Mar 2024 16:22:04 +1300 Subject: [PATCH 007/336] Use Nu language for NUON files (#9839) --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index 2e9f5d195..bf726e349 100644 --- a/languages.toml +++ b/languages.toml @@ -1934,7 +1934,7 @@ source = { git = "https://github.com/PrestonKnopp/tree-sitter-godot-resource", r name = "nu" scope = "source.nu" injection-regex = "nu" -file-types = ["nu"] +file-types = ["nu", "nuon"] shebangs = ["nu"] comment-token = "#" indent = { tab-width = 2, unit = " " } From c145999bff81f763a9e2d20d28c79f32bbd1306b Mon Sep 17 00:00:00 2001 From: Kalpaj Chaudhari Date: Sun, 10 Mar 2024 08:53:33 +0530 Subject: [PATCH 008/336] treesitter: Add textobjects for native funcs and constructors (#9806) This allows native functions and constructors to be accessible as part of goto_{next,prev}_func. Change-Id: Ia1234004e8b38e1c5871331a38fcf4f267da935e --- runtime/queries/java/textobjects.scm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runtime/queries/java/textobjects.scm b/runtime/queries/java/textobjects.scm index a932c7934..b0e73a0a7 100644 --- a/runtime/queries/java/textobjects.scm +++ b/runtime/queries/java/textobjects.scm @@ -1,4 +1,7 @@ (method_declaration + body: (_)? @function.inside) @function.around + +(constructor_declaration body: (_) @function.inside) @function.around (interface_declaration From 2d589e74f057188d113c34a6e52cc614134b5f31 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 14:38:19 +0900 Subject: [PATCH 009/336] build(deps): bump cachix/install-nix-action from 25 to 26 (#9851) Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 25 to 26. - [Release notes](https://github.com/cachix/install-nix-action/releases) - [Commits](https://github.com/cachix/install-nix-action/compare/v25...v26) --- updated-dependencies: - dependency-name: cachix/install-nix-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/cachix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cachix.yml b/.github/workflows/cachix.yml index 57f0a0db4..9638137b8 100644 --- a/.github/workflows/cachix.yml +++ b/.github/workflows/cachix.yml @@ -14,7 +14,7 @@ jobs: uses: actions/checkout@v4 - name: Install nix - uses: cachix/install-nix-action@v25 + uses: cachix/install-nix-action@v26 - name: Authenticate with Cachix uses: cachix/cachix-action@v14 From 2e2a1d6f613eb964dfea655a1e377cb12d1d7b48 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 14:41:40 +0900 Subject: [PATCH 010/336] build(deps): bump open from 5.0.1 to 5.1.2 (#9854) Bumps [open](https://github.com/Byron/open-rs) from 5.0.1 to 5.1.2. - [Release notes](https://github.com/Byron/open-rs/releases) - [Changelog](https://github.com/Byron/open-rs/blob/main/changelog.md) - [Commits](https://github.com/Byron/open-rs/compare/v5.0.1...v5.1.2) --- updated-dependencies: - dependency-name: open dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- helix-term/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fd74140a5..b67796aba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1767,9 +1767,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "open" -version = "5.0.1" +version = "5.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90878fb664448b54c4e592455ad02831e23a3f7e157374a8b95654731aac7349" +checksum = "449f0ff855d85ddbf1edd5b646d65249ead3f5e422aaa86b7d2d0b049b103e32" dependencies = [ "is-wsl", "libc", diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml index accde567e..bc3117d20 100644 --- a/helix-term/Cargo.toml +++ b/helix-term/Cargo.toml @@ -58,7 +58,7 @@ pulldown-cmark = { version = "0.10", default-features = false } content_inspector = "0.2.4" # opening URLs -open = "5.0.1" +open = "5.1.2" url = "2.5.0" # config From ab61874efb9e53c55f44741b2455c4c08602bec9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 14:41:48 +0900 Subject: [PATCH 011/336] build(deps): bump cc from 1.0.88 to 1.0.90 (#9855) Bumps [cc](https://github.com/rust-lang/cc-rs) from 1.0.88 to 1.0.90. - [Release notes](https://github.com/rust-lang/cc-rs/releases) - [Commits](https://github.com/rust-lang/cc-rs/compare/1.0.88...1.0.90) --- updated-dependencies: - dependency-name: cc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b67796aba..6fe238fe0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -145,9 +145,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" [[package]] name = "cc" -version = "1.0.88" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02f341c093d19155a6e41631ce5971aac4e9a868262212153124c15fa22d1cdc" +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" [[package]] name = "cfg-if" From 2d15acdf6029fd9b418bf4797c2947d6004dddbd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 14:45:44 +0900 Subject: [PATCH 012/336] build(deps): bump libloading from 0.8.2 to 0.8.3 (#9857) Bumps [libloading](https://github.com/nagisa/rust_libloading) from 0.8.2 to 0.8.3. - [Commits](https://github.com/nagisa/rust_libloading/compare/0.8.2...0.8.3) --- updated-dependencies: - dependency-name: libloading dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6fe238fe0..22b78986e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1603,9 +1603,9 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libloading" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2caa5afb8bf9f3a2652760ce7d4f62d21c4d5a423e68466fca30df82f2330164" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", "windows-targets 0.52.0", From 3915b04bd91084477b3076952e6ad6cfdd414e72 Mon Sep 17 00:00:00 2001 From: fnuttens Date: Wed, 13 Mar 2024 05:47:55 +0100 Subject: [PATCH 013/336] fix(themes-catppuccin): make inlay hints more legible (#9859) --- runtime/themes/catppuccin_mocha.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/themes/catppuccin_mocha.toml b/runtime/themes/catppuccin_mocha.toml index 1ea57e960..65ba76e4b 100644 --- a/runtime/themes/catppuccin_mocha.toml +++ b/runtime/themes/catppuccin_mocha.toml @@ -88,7 +88,7 @@ "ui.virtual" = "overlay0" "ui.virtual.ruler" = { bg = "surface0" } "ui.virtual.indent-guide" = "surface0" -"ui.virtual.inlay-hint" = { fg = "surface1", bg = "mantle" } +"ui.virtual.inlay-hint" = { fg = "overlay0", bg = "base" } "ui.selection" = { bg = "surface1" } From e01a5582942ef96d0de9c369d2b9408c6355cd1b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Mar 2024 14:13:36 +0900 Subject: [PATCH 014/336] build(deps): bump log from 0.4.20 to 0.4.21 (#9856) Bumps [log](https://github.com/rust-lang/log) from 0.4.20 to 0.4.21. - [Release notes](https://github.com/rust-lang/log/releases) - [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/log/compare/0.4.20...0.4.21) --- updated-dependencies: - dependency-name: log dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 22b78986e..9bea99ac5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1638,9 +1638,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "lsp-types" From b44b627b1403f8a3e23251bc79558d482346c4b0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 23:37:10 +0000 Subject: [PATCH 015/336] build(deps): bump chrono from 0.4.34 to 0.4.35 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.34 to 0.4.35. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.34...v0.4.35) --- updated-dependencies: - dependency-name: chrono dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9bea99ac5..8628d002f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -168,9 +168,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.34" +version = "0.4.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" +checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" dependencies = [ "android-tzdata", "iana-time-zone", From 6c4d986c1b1ac4e350dced513b6608ba4464cde3 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Tue, 12 Mar 2024 09:58:33 -0400 Subject: [PATCH 016/336] Use non-deprecated chrono Duration functions --- helix-core/src/increment/date_time.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/helix-core/src/increment/date_time.rs b/helix-core/src/increment/date_time.rs index 2980bb58b..04cff6b47 100644 --- a/helix-core/src/increment/date_time.rs +++ b/helix-core/src/increment/date_time.rs @@ -27,7 +27,7 @@ pub fn increment(selected_text: &str, amount: i64) -> Option { let date_time = NaiveDateTime::parse_from_str(date_time, format.fmt).ok()?; Some( date_time - .checked_add_signed(Duration::minutes(amount))? + .checked_add_signed(Duration::try_minutes(amount)?)? .format(format.fmt) .to_string(), ) @@ -35,14 +35,15 @@ pub fn increment(selected_text: &str, amount: i64) -> Option { (true, false) => { let date = NaiveDate::parse_from_str(date_time, format.fmt).ok()?; Some( - date.checked_add_signed(Duration::days(amount))? + date.checked_add_signed(Duration::try_days(amount)?)? .format(format.fmt) .to_string(), ) } (false, true) => { let time = NaiveTime::parse_from_str(date_time, format.fmt).ok()?; - let (adjusted_time, _) = time.overflowing_add_signed(Duration::minutes(amount)); + let (adjusted_time, _) = + time.overflowing_add_signed(Duration::try_minutes(amount)?); Some(adjusted_time.format(format.fmt).to_string()) } (false, false) => None, From 0c51ab16d0c65505705297b89ebb1147f3cc8fee Mon Sep 17 00:00:00 2001 From: Kirawi <67773714+kirawi@users.noreply.github.com> Date: Fri, 15 Mar 2024 12:38:22 -0400 Subject: [PATCH 017/336] Add a yank diagnostic command (#9640) * yank diagnostic command * improve success message * move to a typed command * docgen --- book/src/generated/typable-cmd.md | 1 + helix-term/src/commands/typed.rs | 47 +++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/book/src/generated/typable-cmd.md b/book/src/generated/typable-cmd.md index f4fcb6f62..dbb8b5f38 100644 --- a/book/src/generated/typable-cmd.md +++ b/book/src/generated/typable-cmd.md @@ -86,3 +86,4 @@ | `:clear-register` | Clear given register. If no argument is provided, clear all registers. | | `:redraw` | Clear and re-render the whole UI | | `:move` | Move the current buffer and its corresponding file to a different path | +| `:yank-diagnostic` | Yank diagnostic(s) under primary cursor to register, or clipboard by default | diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 3d7ea3fc8..384db4ac3 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -2414,6 +2414,46 @@ fn move_buffer( Ok(()) } +fn yank_diagnostic( + cx: &mut compositor::Context, + args: &[Cow], + event: PromptEvent, +) -> anyhow::Result<()> { + if event != PromptEvent::Validate { + return Ok(()); + } + + let (view, doc) = current_ref!(cx.editor); + let primary = doc.selection(view.id).primary(); + + // Look only for diagnostics that intersect with the primary selection + let diag: Vec<_> = doc + .diagnostics() + .iter() + .filter(|d| primary.overlaps(&helix_core::Range::new(d.range.start, d.range.end))) + .map(|d| d.message.clone()) + .collect(); + let n = diag.len(); + if n == 0 { + bail!("No diagnostics under primary selection"); + } + + let reg = match args.get(0) { + Some(s) => { + ensure!(s.chars().count() == 1, format!("Invalid register {s}")); + s.chars().next().unwrap() + } + None => '+', + }; + + cx.editor.registers.write(reg, diag)?; + cx.editor.set_status(format!( + "Yanked {n} diagnostic{} to register {reg}", + if n == 1 { "" } else { "s" } + )); + Ok(()) +} + pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[ TypableCommand { name: "quit", @@ -3021,6 +3061,13 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[ fun: move_buffer, signature: CommandSignature::positional(&[completers::filename]), }, + TypableCommand { + name: "yank-diagnostic", + aliases: &[], + doc: "Yank diagnostic(s) under primary cursor to register, or clipboard by default", + fun: yank_diagnostic, + signature: CommandSignature::none(), + }, ]; pub static TYPABLE_COMMAND_MAP: Lazy> = From b961acf74601f0ede754d595f52ed4cba300e37f Mon Sep 17 00:00:00 2001 From: Mike Trinkala Date: Fri, 15 Mar 2024 12:44:08 -0700 Subject: [PATCH 018/336] Update regex-cursor (#9891) --- Cargo.lock | 4 ++-- helix-stdx/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8628d002f..7b73b1b1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1950,9 +1950,9 @@ dependencies = [ [[package]] name = "regex-cursor" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a43718aa0040434d45728c43f56bd53bda75a91c46954cdf0f2ff4dbc8aabbe7" +checksum = "ae4327b5fde3ae6fda0152128d3d59b95a5aad7be91c405869300091720f7169" dependencies = [ "log", "memchr", diff --git a/helix-stdx/Cargo.toml b/helix-stdx/Cargo.toml index 5ac7c011f..ed23f4e4f 100644 --- a/helix-stdx/Cargo.toml +++ b/helix-stdx/Cargo.toml @@ -16,7 +16,7 @@ dunce = "1.0" etcetera = "0.8" ropey = { version = "1.6.1", default-features = false } which = "6.0" -regex-cursor = "0.1.3" +regex-cursor = "0.1.4" [dev-dependencies] tempfile = "3.10" From 9282f1b8e546583d9e461cd78bed7d2f21dd1770 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Fri, 15 Mar 2024 19:52:57 -0400 Subject: [PATCH 019/336] Handle starting and continuing the count separately (#9887) --- helix-term/src/ui/editor.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index f3bba5d1c..c1e36bbdd 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -916,13 +916,15 @@ impl EditorView { fn command_mode(&mut self, mode: Mode, cxt: &mut commands::Context, event: KeyEvent) { match (event, cxt.editor.count) { - // count handling - (key!(i @ '0'), Some(_)) | (key!(i @ '1'..='9'), _) - if !self.keymaps.contains_key(mode, event) => - { + // If the count is already started and the input is a number, always continue the count. + (key!(i @ '0'..='9'), Some(count)) => { + let i = i.to_digit(10).unwrap() as usize; + cxt.editor.count = NonZeroUsize::new(count.get() * 10 + i); + } + // A non-zero digit will start the count if that number isn't used by a keymap. + (key!(i @ '1'..='9'), None) if !self.keymaps.contains_key(mode, event) => { let i = i.to_digit(10).unwrap() as usize; - cxt.editor.count = - std::num::NonZeroUsize::new(cxt.editor.count.map_or(i, |c| c.get() * 10 + i)); + cxt.editor.count = NonZeroUsize::new(i); } // special handling for repeat operator (key!('.'), _) if self.keymaps.pending().is_empty() => { From 6fea7876a47df8627a4b40361a6fc0f692c6601f Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 16 Mar 2024 18:20:47 +0530 Subject: [PATCH 020/336] Fix comment key bind behaviour in OCaml (#9894) --- languages.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/languages.toml b/languages.toml index bf726e349..8fbb98e88 100644 --- a/languages.toml +++ b/languages.toml @@ -1083,7 +1083,6 @@ injection-regex = "ocaml" file-types = ["ml"] shebangs = ["ocaml", "ocamlrun", "ocamlscript"] block-comment-tokens = { start = "(*", end = "*)" } -comment-token = "(**)" language-servers = [ "ocamllsp" ] indent = { tab-width = 2, unit = " " } From 761df60077bf33cb1077eb4cb019885ea3dd6ae7 Mon Sep 17 00:00:00 2001 From: Emi <95967983+EmiOnGit@users.noreply.github.com> Date: Sun, 17 Mar 2024 23:06:24 +0100 Subject: [PATCH 021/336] Keybind for Extend/shrink selection up and down (#9080) * implement another selection modifying command * Selection feels more ergonomic in case of swapping the direction. This also fixes a problem when starting at an empty line. * rename select_line_up/down to select_line_above/below * apply clippy suggestion of using cmp instead of if-chain * revert `Extent` implementing `Clone/Copy` * move select_line functions below extend_line implementations * implement help add function, which saturates at the number of text lines --------- Co-authored-by: Emi --- helix-term/src/commands.rs | 57 +++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 4ac2496eb..133f2d540 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -57,6 +57,7 @@ use crate::{ use crate::job::{self, Jobs}; use std::{ + cmp::Ordering, collections::{HashMap, HashSet}, fmt, future::Future, @@ -300,6 +301,8 @@ impl MappableCommand { extend_line, "Select current line, if already selected, extend to another line based on the anchor", extend_line_below, "Select current line, if already selected, extend to next line", extend_line_above, "Select current line, if already selected, extend to previous line", + select_line_above, "Select current line, if already selected, extend or shrink line above based on the anchor", + select_line_below, "Select current line, if already selected, extend or shrink line below based on the anchor", extend_to_line_bounds, "Extend selection to line bounds", shrink_to_line_bounds, "Shrink selection to line bounds", delete_selection, "Delete selection", @@ -2435,7 +2438,6 @@ fn extend_line_below(cx: &mut Context) { fn extend_line_above(cx: &mut Context) { extend_line_impl(cx, Extend::Above); } - fn extend_line_impl(cx: &mut Context, extend: Extend) { let count = cx.count(); let (view, doc) = current!(cx.editor); @@ -2474,6 +2476,59 @@ fn extend_line_impl(cx: &mut Context, extend: Extend) { doc.set_selection(view.id, selection); } +fn select_line_below(cx: &mut Context) { + select_line_impl(cx, Extend::Below); +} +fn select_line_above(cx: &mut Context) { + select_line_impl(cx, Extend::Above); +} +fn select_line_impl(cx: &mut Context, extend: Extend) { + let mut count = cx.count(); + let (view, doc) = current!(cx.editor); + let text = doc.text(); + let saturating_add = |a: usize, b: usize| (a + b).min(text.len_lines()); + let selection = doc.selection(view.id).clone().transform(|range| { + let (start_line, end_line) = range.line_range(text.slice(..)); + let start = text.line_to_char(start_line); + let end = text.line_to_char(saturating_add(end_line, 1)); + let direction = range.direction(); + + // Extending to line bounds is counted as one step + if range.from() != start || range.to() != end { + count = count.saturating_sub(1) + } + let (anchor_line, head_line) = match (&extend, direction) { + (Extend::Above, Direction::Forward) => (start_line, end_line.saturating_sub(count)), + (Extend::Above, Direction::Backward) => (end_line, start_line.saturating_sub(count)), + (Extend::Below, Direction::Forward) => (start_line, saturating_add(end_line, count)), + (Extend::Below, Direction::Backward) => (end_line, saturating_add(start_line, count)), + }; + let (anchor, head) = match anchor_line.cmp(&head_line) { + Ordering::Less => ( + text.line_to_char(anchor_line), + text.line_to_char(saturating_add(head_line, 1)), + ), + Ordering::Equal => match extend { + Extend::Above => ( + text.line_to_char(saturating_add(anchor_line, 1)), + text.line_to_char(head_line), + ), + Extend::Below => ( + text.line_to_char(head_line), + text.line_to_char(saturating_add(anchor_line, 1)), + ), + }, + + Ordering::Greater => ( + text.line_to_char(saturating_add(anchor_line, 1)), + text.line_to_char(head_line), + ), + }; + Range::new(anchor, head) + }); + + doc.set_selection(view.id, selection); +} fn extend_to_line_bounds(cx: &mut Context) { let (view, doc) = current!(cx.editor); From 61f7d9ce2f2d20f4b0bd2f21036eac1f11cb2c5c Mon Sep 17 00:00:00 2001 From: Arthur Deierlein <110528300+c0rydoras@users.noreply.github.com> Date: Sun, 17 Mar 2024 23:36:54 +0100 Subject: [PATCH 022/336] fix typo "braket" in jsx highlights (#9910) --- runtime/queries/_jsx/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/queries/_jsx/highlights.scm b/runtime/queries/_jsx/highlights.scm index 853254e5b..2a696641c 100644 --- a/runtime/queries/_jsx/highlights.scm +++ b/runtime/queries/_jsx/highlights.scm @@ -40,4 +40,4 @@ (jsx_closing_element [""] @punctuation.bracket) ; -(jsx_self_closing_element ["<" "/>"] @punctuation.braket) +(jsx_self_closing_element ["<" "/>"] @punctuation.bracket) From 9ec0271873ed484f96342489b4117391e88abcd3 Mon Sep 17 00:00:00 2001 From: Arthur Deierlein <110528300+c0rydoras@users.noreply.github.com> Date: Sun, 17 Mar 2024 23:53:30 +0100 Subject: [PATCH 023/336] Add support for hyprland config (#9899) * feat: add hyprland config language * adjust indents to helix * adjust highlights to helix --- book/src/generated/lang-support.md | 1 + languages.toml | 12 +++++ runtime/queries/hyprlang/highlights.scm | 58 +++++++++++++++++++++++++ runtime/queries/hyprlang/indents.scm | 6 +++ runtime/queries/hyprlang/injections.scm | 3 ++ 5 files changed, 80 insertions(+) create mode 100644 runtime/queries/hyprlang/highlights.scm create mode 100644 runtime/queries/hyprlang/indents.scm create mode 100644 runtime/queries/hyprlang/injections.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 7792bf594..2cb1e926c 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -77,6 +77,7 @@ | hosts | ✓ | | | | | html | ✓ | | | `vscode-html-language-server` | | hurl | ✓ | | ✓ | | +| hyprlang | ✓ | | ✓ | | | idris | | | | `idris2-lsp` | | iex | ✓ | | | | | ini | ✓ | | | | diff --git a/languages.toml b/languages.toml index 8fbb98e88..b01da144d 100644 --- a/languages.toml +++ b/languages.toml @@ -3284,3 +3284,15 @@ indent = { tab-width = 2, unit = " " } [[grammar]] name = "ld" source = { git = "https://github.com/mtoohey31/tree-sitter-ld", rev = "81978cde3844bfc199851e39c80a20ec6444d35e" } + +[[language]] +name = "hyprlang" +scope = "source.hyprlang" +roots = ["hyprland.conf"] +file-types = [ { glob = "hyprland.conf"} ] +comment-token = "#" +grammar = "hyprlang" + +[[grammar]] +name = "hyprlang" +source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-hyprlang", rev = "27af9b74acf89fa6bed4fb8cb8631994fcb2e6f3"} diff --git a/runtime/queries/hyprlang/highlights.scm b/runtime/queries/hyprlang/highlights.scm new file mode 100644 index 000000000..bf898c9cd --- /dev/null +++ b/runtime/queries/hyprlang/highlights.scm @@ -0,0 +1,58 @@ +(comment) @comment + +[ + "source" + "exec" + "exec-once" +] @function.builtin + +(keyword + (name) @keyword) + +(assignment + (name) @variable.other.member) + +(section + (name) @namespace) + +(section + device: (device_name) @type) + +(variable) @variable + +"$" @punctuation.special + +(boolean) @constant.builtin.boolean + +(string) @string + +(mod) @constant + +[ + "rgb" + "rgba" +] @function.builtin + +[ + (number) + (legacy_hex) + (angle) + (hex) +] @constant.numeric + +"deg" @type + +"," @punctuation.delimiter + +[ + "(" + ")" + "{" + "}" +] @punctuation.bracket + +[ + "=" + "-" + "+" +] @operator diff --git a/runtime/queries/hyprlang/indents.scm b/runtime/queries/hyprlang/indents.scm new file mode 100644 index 000000000..88bfe7434 --- /dev/null +++ b/runtime/queries/hyprlang/indents.scm @@ -0,0 +1,6 @@ +(section) @indent + +(section + "}" @outdent) + +"}" @extend diff --git a/runtime/queries/hyprlang/injections.scm b/runtime/queries/hyprlang/injections.scm new file mode 100644 index 000000000..1f0199ed8 --- /dev/null +++ b/runtime/queries/hyprlang/injections.scm @@ -0,0 +1,3 @@ +(exec + (string) @injection.content + (#set! injection.language "bash")) From e36774c2c8f967c16ce2e10f2ba074838b324ec6 Mon Sep 17 00:00:00 2001 From: "George \"Riye\" Hollister" Date: Sun, 17 Mar 2024 22:54:05 +0000 Subject: [PATCH 024/336] Add Support for JSONC (#9906) * Added `jsonc` language with support for comments The `vscode-json-language-server` accepts `jsonc` as a language id. Allowing the use of comments within JSON files. * fix: Update `injdection-rejex` to be unique * fix: use includes to remove redundant queries * ci: Generate language-support docs --- book/src/generated/lang-support.md | 1 + languages.toml | 10 +++++++++- runtime/queries/jsonc/highlights.scm | 2 ++ runtime/queries/jsonc/indents.scm | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 runtime/queries/jsonc/highlights.scm create mode 100644 runtime/queries/jsonc/indents.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 2cb1e926c..40029657f 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -88,6 +88,7 @@ | jsdoc | ✓ | | | | | json | ✓ | | ✓ | `vscode-json-language-server` | | json5 | ✓ | | | | +| jsonc | ✓ | | ✓ | `vscode-json-language-server` | | jsonnet | ✓ | | | `jsonnet-language-server` | | jsx | ✓ | ✓ | ✓ | `typescript-language-server` | | julia | ✓ | ✓ | ✓ | `julia` | diff --git a/languages.toml b/languages.toml index b01da144d..4018fbe0e 100644 --- a/languages.toml +++ b/languages.toml @@ -367,7 +367,6 @@ scope = "source.json" injection-regex = "json" file-types = [ "json", - "jsonc", "arb", "ipynb", "geojson", @@ -396,6 +395,15 @@ indent = { tab-width = 2, unit = " " } name = "json" source = { git = "https://github.com/tree-sitter/tree-sitter-json", rev = "73076754005a460947cafe8e03a8cf5fa4fa2938" } +[[language]] +name = "jsonc" +scope = "source.json" +injection-regex = "jsonc" +file-types = ["jsonc"] +grammar = "json" +language-servers = [ "vscode-json-language-server" ] +auto-format = true +indent = { tab-width = 2, unit = " " } [[language]] name = "json5" diff --git a/runtime/queries/jsonc/highlights.scm b/runtime/queries/jsonc/highlights.scm new file mode 100644 index 000000000..0164321b6 --- /dev/null +++ b/runtime/queries/jsonc/highlights.scm @@ -0,0 +1,2 @@ +; inherits: json +(comment) @comment diff --git a/runtime/queries/jsonc/indents.scm b/runtime/queries/jsonc/indents.scm new file mode 100644 index 000000000..41269219e --- /dev/null +++ b/runtime/queries/jsonc/indents.scm @@ -0,0 +1 @@ +; inherits: json From 3890376a23e84d5bcdac31cb9d0f6913abe0fc7f Mon Sep 17 00:00:00 2001 From: Dan Cardamore Date: Sun, 17 Mar 2024 18:55:49 -0400 Subject: [PATCH 025/336] add 'file-absolute-path' to statusline (#4535) * feat: add 'file-abs-path' to statusline (#4434) * cleanup implementation * rename to be non-abbreviated names --------- Co-authored-by: Michael Davis --- book/src/configuration.md | 1 + helix-term/src/ui/statusline.rs | 17 +++++++++++++++++ helix-view/src/editor.rs | 3 +++ 3 files changed, 21 insertions(+) diff --git a/book/src/configuration.md b/book/src/configuration.md index d87936457..8857af82a 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -108,6 +108,7 @@ The following statusline elements can be configured: | `mode` | The current editor mode (`mode.normal`/`mode.insert`/`mode.select`) | | `spinner` | A progress spinner indicating LSP activity | | `file-name` | The path/name of the opened file | +| `file-absolute-path` | The absolute path/name of the opened file | | `file-base-name` | The basename of the opened file | | `file-modification-indicator` | The indicator to show whether the file is modified (a `[+]` appears when there are unsaved changes) | | `file-encoding` | The encoding of the opened file if it differs from UTF-8 | diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index 9871828ee..c3464067f 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -142,6 +142,7 @@ where helix_view::editor::StatusLineElement::Spinner => render_lsp_spinner, helix_view::editor::StatusLineElement::FileBaseName => render_file_base_name, helix_view::editor::StatusLineElement::FileName => render_file_name, + helix_view::editor::StatusLineElement::FileAbsolutePath => render_file_absolute_path, helix_view::editor::StatusLineElement::FileModificationIndicator => { render_file_modification_indicator } @@ -430,6 +431,22 @@ where write(context, title, None); } +fn render_file_absolute_path(context: &mut RenderContext, write: F) +where + F: Fn(&mut RenderContext, String, Option