From a8fd33ac012a79069ef1409503a2edcf3a585153 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Thu, 6 Jan 2022 09:00:00 -0600 Subject: [PATCH 01/12] add tree-sitter-regex (#1362) * add tree-sitter-regex * adapt regex highlights from upstream * inject regex into elixir sigil_r/2 and sigil_R/2 * generate lang-support docs * capture interesting nodes in character-ranges * make $.character_class captures more consistent * fix fallthrough behavior for character classes * capture pattern characters as 'string' * use latest tree-sitter-regex * set elixir regex injections as combined * add link to upstream queries * inject regex in rust into 'Regex::new' raw string literals --- .gitmodules | 4 ++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-regex | 1 + languages.toml | 7 ++++ runtime/queries/elixir/injections.scm | 7 ++++ runtime/queries/regex/highlights.scm | 53 ++++++++++++++++++++++++ runtime/queries/rust/injections.scm | 14 +++++++ 7 files changed, 87 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-regex create mode 100644 runtime/queries/regex/highlights.scm diff --git a/.gitmodules b/.gitmodules index 9297708a..f6a0fdc4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -190,3 +190,7 @@ path = helix-syntax/languages/tree-sitter-git-rebase url = https://github.com/the-mikedavis/tree-sitter-git-rebase.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-regex"] + path = helix-syntax/languages/tree-sitter-regex + url = https://github.com/tree-sitter/tree-sitter-regex.git + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index a1fbf172..daf8b006 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -38,6 +38,7 @@ | protobuf | ✓ | | ✓ | | | python | ✓ | ✓ | ✓ | `pylsp` | | racket | | | | `racket` | +| regex | ✓ | | | | | ruby | ✓ | | ✓ | `solargraph` | | rust | ✓ | ✓ | ✓ | `rust-analyzer` | | scala | ✓ | | ✓ | `metals` | diff --git a/helix-syntax/languages/tree-sitter-regex b/helix-syntax/languages/tree-sitter-regex new file mode 160000 index 00000000..e1cfca3c --- /dev/null +++ b/helix-syntax/languages/tree-sitter-regex @@ -0,0 +1 @@ +Subproject commit e1cfca3c79896ff79842f057ea13e529b66af636 diff --git a/languages.toml b/languages.toml index e8329fe7..3e2e7b15 100644 --- a/languages.toml +++ b/languages.toml @@ -530,3 +530,10 @@ file-types = ["git-rebase-todo"] injection-regex = "git-rebase" comment-token = "#" indent = { tab-width = 2, unit = " " } + +[[language]] +name = "regex" +scope = "source.regex" +injection-regex = "regex" +file-types = ["regex"] +roots = [] diff --git a/runtime/queries/elixir/injections.scm b/runtime/queries/elixir/injections.scm index 321c90ad..8370a0d8 100644 --- a/runtime/queries/elixir/injections.scm +++ b/runtime/queries/elixir/injections.scm @@ -1,2 +1,9 @@ ((comment) @injection.content (#set! injection.language "comment")) + +((sigil + (sigil_name) @_sigil_name + (quoted_content) @injection.content) + (#match? @_sigil_name "^(r|R)$") + (#set! injection.language "regex") + (#set! injection.combined)) diff --git a/runtime/queries/regex/highlights.scm b/runtime/queries/regex/highlights.scm new file mode 100644 index 00000000..9376caa9 --- /dev/null +++ b/runtime/queries/regex/highlights.scm @@ -0,0 +1,53 @@ +; upstream: https://github.com/tree-sitter/tree-sitter-regex/blob/e1cfca3c79896ff79842f057ea13e529b66af636/queries/highlights.scm + +[ + "(" + ")" + "(?" + "(?:" + "(?<" + ">" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "*" + "+" + "|" + "=" + "<=" + "!" + " Date: Fri, 7 Jan 2022 19:14:31 +0100 Subject: [PATCH 02/12] Rework beginning of themes chapter The specifics of configuring themes has caused some confusion. Hopefully this will clarify things a little. --- book/src/themes.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/book/src/themes.md b/book/src/themes.md index 8eee334b..7474122f 100644 --- a/book/src/themes.md +++ b/book/src/themes.md @@ -1,14 +1,14 @@ # Themes -First you'll need to place selected themes in your `themes` directory (i.e `~/.config/helix/themes`), the directory might have to be created beforehand. - -To use a custom theme add `theme = ` to your [`config.toml`](./configuration.md) or override it during runtime using `:theme `. - -The default theme.toml can be found [here](https://github.com/helix-editor/helix/blob/master/theme.toml), and user submitted themes [here](https://github.com/helix-editor/helix/blob/master/runtime/themes). +To use a theme add `theme = ""` to your [`config.toml`](./configuration.md) at the very top of the file before the first section or select it during runtime using `:theme `. ## Creating a theme -First create a file with the name of your theme as file name (i.e `mytheme.toml`) and place it in your `themes` directory (i.e `~/.config/helix/themes`). +Create a file with the name of your theme as file name (i.e `mytheme.toml`) and place it in your `themes` directory (i.e `~/.config/helix/themes`). The directory might have to be created beforehand. + +The names "default" and "base16_default" are reserved for the builtin themes and cannot be overridden by user defined themes. + +The default theme.toml can be found [here](https://github.com/helix-editor/helix/blob/master/theme.toml), and user submitted themes [here](https://github.com/helix-editor/helix/blob/master/runtime/themes). Each line in the theme file is specified as below: From 5e2269486598645a6e9511ea25f87b3609511d77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Sj=C3=B6berg?= Date: Sat, 8 Jan 2022 16:27:10 +0100 Subject: [PATCH 03/12] Add default language server for JavaScript (#1457) * Add default language server for JavaScript * Update lang support documentation --- book/src/generated/lang-support.md | 2 +- languages.toml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index daf8b006..384ba96b 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -18,7 +18,7 @@ | go | ✓ | ✓ | ✓ | `gopls` | | html | ✓ | | | | | java | ✓ | | | | -| javascript | ✓ | | ✓ | | +| javascript | ✓ | | ✓ | `typescript-language-server` | | json | ✓ | | ✓ | | | julia | ✓ | | | `julia` | | latex | ✓ | | | | diff --git a/languages.toml b/languages.toml index 3e2e7b15..c8f9bab4 100644 --- a/languages.toml +++ b/languages.toml @@ -128,6 +128,7 @@ roots = [] comment-token = "//" # TODO: highlights-jsx, highlights-params +language-server = { command = "typescript-language-server", args = ["--stdio"] } indent = { tab-width = 2, unit = " " } [[language]] From b799b0d50e7848cc084d913afbdc0fb3a25c1b97 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sat, 8 Jan 2022 09:27:50 -0600 Subject: [PATCH 04/12] capture markdown link text as markup.link.text (#1456) --- book/src/themes.md | 5 +++-- runtime/queries/markdown/highlights.scm | 5 +++++ theme.toml | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/book/src/themes.md b/book/src/themes.md index 7474122f..29d3926e 100644 --- a/book/src/themes.md +++ b/book/src/themes.md @@ -171,8 +171,9 @@ We use a similar set of scopes as - `bold` - `italic` - `link` - - `url` - - `label` + - `url` - urls pointed to by links + - `label` - non-url link references + - `text` - url and image descriptions in links - `quote` - `raw` - `inline` diff --git a/runtime/queries/markdown/highlights.scm b/runtime/queries/markdown/highlights.scm index a0bd3462..f12254e9 100644 --- a/runtime/queries/markdown/highlights.scm +++ b/runtime/queries/markdown/highlights.scm @@ -21,6 +21,11 @@ (link_destination) @markup.link.url (link_label) @markup.link.label +[ + (link_text) + (image_description) +] @markup.link.text + [ (list_marker_plus) (list_marker_minus) diff --git a/theme.toml b/theme.toml index ca0b2805..d2c1fc32 100644 --- a/theme.toml +++ b/theme.toml @@ -32,6 +32,7 @@ label = "honey" "markup.bold" = { modifiers = ["bold"] } "markup.italic" = { modifiers = ["italic"] } "markup.link.url" = { fg = "silver", modifiers = ["underlined"] } +"markup.link.text" = "almond" "markup.raw" = "almond" "diff.plus" = "#35bf86" From 41ee45ce5498a070b782abe22dfdc33b5e372964 Mon Sep 17 00:00:00 2001 From: Owen Shepherd Date: Sat, 1 Jan 2022 19:20:10 +0000 Subject: [PATCH 05/12] Upgrade and reenable tree-sitter-haskell --- helix-syntax/build.rs | 1 - helix-syntax/languages/tree-sitter-haskell | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/helix-syntax/build.rs b/helix-syntax/build.rs index 28f85e74..fa8be8b3 100644 --- a/helix-syntax/build.rs +++ b/helix-syntax/build.rs @@ -175,7 +175,6 @@ fn build_dir(dir: &str, language: &str) { fn main() { let ignore = vec![ "tree-sitter-typescript".to_string(), - "tree-sitter-haskell".to_string(), // aarch64 failures: https://github.com/tree-sitter/tree-sitter-haskell/issues/34 "tree-sitter-ocaml".to_string(), ]; let dirs = collect_tree_sitter_dirs(&ignore).unwrap(); diff --git a/helix-syntax/languages/tree-sitter-haskell b/helix-syntax/languages/tree-sitter-haskell index 237f4eb4..b6ec26f1 160000 --- a/helix-syntax/languages/tree-sitter-haskell +++ b/helix-syntax/languages/tree-sitter-haskell @@ -1 +1 @@ -Subproject commit 237f4eb4417c28f643a29d795ed227246afb66f9 +Subproject commit b6ec26f181dd059eedd506fa5fbeae1b8e5556c8 From 9eacbc1887fd102a820c40add24f3a1cd2d994ed Mon Sep 17 00:00:00 2001 From: Owen Shepherd Date: Wed, 5 Jan 2022 17:53:37 +0000 Subject: [PATCH 06/12] Upgrade haskell queries --- runtime/queries/haskell/highlights.scm | 153 +++++++++++++++++++------ 1 file changed, 115 insertions(+), 38 deletions(-) diff --git a/runtime/queries/haskell/highlights.scm b/runtime/queries/haskell/highlights.scm index 8006cb07..3f5d6de5 100644 --- a/runtime/queries/haskell/highlights.scm +++ b/runtime/queries/haskell/highlights.scm @@ -1,45 +1,122 @@ -(variable) @variable -(operator) @operator -(exp_name (constructor) @constructor) -(constructor_operator) @operator -(module) @namespace -(type) @type -(type) @class -(constructor) @constructor -(pragma) @pragma -(comment) @comment -(signature name: (variable) @type) -(function name: (variable) @function) -(constraint class: (class_name (type)) @class) -(class (class_head class: (class_name (type)) @class)) -(instance (instance_head class: (class_name (type)) @class)) +;; ---------------------------------------------------------------------------- +;; Literals and comments + (integer) @constant.numeric.integer +(exp_negation) @constant.numeric.integer (exp_literal (float)) @constant.numeric.float (char) @constant.character -(con_unit) @literal -(con_list) @literal -(tycon_arrow) @operator -(where) @keyword -"module" @keyword -"let" @keyword -"in" @keyword -"class" @keyword -"instance" @keyword -"data" @keyword -"newtype" @keyword -"family" @keyword -"type" @keyword -"import" @keyword -"qualified" @keyword -"as" @keyword -"deriving" @keyword -"via" @keyword -"stock" @keyword -"anyclass" @keyword -"do" @keyword -"mdo" @keyword -"rec" @keyword +(string) @string + +(con_unit) @constant.builtin ; unit, as in () + +(comment) @comment + + +;; ---------------------------------------------------------------------------- +;; Punctuation + [ "(" ")" + "{" + "}" + "[" + "]" ] @punctuation.bracket + +[ + (comma) + ";" +] @punctuation.delimiter + + +;; ---------------------------------------------------------------------------- +;; Keywords, operators, includes + +(pragma) @constant.macro + +[ + "if" + "then" + "else" + "case" + "of" +] @keyword.control.conditional + +[ + "import" + "qualified" + "module" +] @keyword.control.import + +[ + (operator) + (constructor_operator) + (type_operator) + (tycon_arrow) + (qualified_module) ; grabs the `.` (dot), ex: import System.IO + (all_names) + (wildcard) + "=" + "|" + "::" + "=>" + "->" + "<-" + "\\" + "`" + "@" +] @operator + +(qualified_module (module) @constructor) +(qualified_type (module) @namespace) +(qualified_variable (module) @namespace) +(import (module) @namespace) + +[ + (where) + "let" + "in" + "class" + "instance" + "data" + "newtype" + "family" + "type" + "as" + "hiding" + "deriving" + "via" + "stock" + "anyclass" + "do" + "mdo" + "rec" + "forall" + "∀" +] @keyword + + +;; ---------------------------------------------------------------------------- +;; Functions and variables + +(signature name: (variable) @type) +(function name: (variable) @function) + +(variable) @variable +"_" @variable.builtin + +(exp_infix (variable) @operator) ; consider infix functions as operators + +("@" @namespace) ; "as" pattern operator, e.g. x@Constructor + + +;; ---------------------------------------------------------------------------- +;; Types + +(type) @type + +(constructor) @constructor + +; True or False +((constructor) @_bool (#match? @_bool "(True|False)")) @constant.builtin.boolean From c238f20e1d26e8a48997630f0f826d4633597bbf Mon Sep 17 00:00:00 2001 From: Owen Shepherd Date: Thu, 6 Jan 2022 21:05:29 +0000 Subject: [PATCH 07/12] Add fixity keywords to haskell's highlights.scm --- runtime/queries/haskell/highlights.scm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runtime/queries/haskell/highlights.scm b/runtime/queries/haskell/highlights.scm index 3f5d6de5..5009f3b5 100644 --- a/runtime/queries/haskell/highlights.scm +++ b/runtime/queries/haskell/highlights.scm @@ -94,6 +94,9 @@ "rec" "forall" "∀" + "infix" + "infixl" + "infixr" ] @keyword From 1c6bc6d455595aa5b8d7d2aa27d025722f57c351 Mon Sep 17 00:00:00 2001 From: Eric Crosson Date: Mon, 3 Jan 2022 19:17:06 -0600 Subject: [PATCH 08/12] feat: add tree-sitter-make This commit adds syntax highlighting for GNU Make[^1] makefiles via tree-sitter-make[^2]. [^1]: https://www.gnu.org/software/make/ [^2]: https://github.com/alemuller/tree-sitter-make --- .gitmodules | 6 +- book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-make | 1 + languages.toml | 7 + runtime/queries/make/highlights.scm | 170 ++++++++++++++++++++++++ 5 files changed, 184 insertions(+), 1 deletion(-) create mode 160000 helix-syntax/languages/tree-sitter-make create mode 100644 runtime/queries/make/highlights.scm diff --git a/.gitmodules b/.gitmodules index f6a0fdc4..e6d9d654 100644 --- a/.gitmodules +++ b/.gitmodules @@ -177,7 +177,7 @@ [submodule "helix-syntax/languages/tree-sitter-llvm-mir"] path = helix-syntax/languages/tree-sitter-llvm-mir url = https://github.com/Flakebi/tree-sitter-llvm-mir.git - shallow = true + shallow = true [submodule "helix-syntax/languages/tree-sitter-git-diff"] path = helix-syntax/languages/tree-sitter-git-diff url = https://github.com/the-mikedavis/tree-sitter-git-diff.git @@ -194,3 +194,7 @@ path = helix-syntax/languages/tree-sitter-regex url = https://github.com/tree-sitter/tree-sitter-regex.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-make"] + path = helix-syntax/languages/tree-sitter-make + url = https://github.com/alemuller/tree-sitter-make + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 384ba96b..c093144f 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -27,6 +27,7 @@ | llvm-mir | ✓ | ✓ | ✓ | | | llvm-mir-yaml | ✓ | | ✓ | | | lua | ✓ | | ✓ | | +| make | ✓ | | | | | markdown | ✓ | | | | | mint | | | | `mint` | | nix | ✓ | | ✓ | `rnix-lsp` | diff --git a/helix-syntax/languages/tree-sitter-make b/helix-syntax/languages/tree-sitter-make new file mode 160000 index 00000000..a4b91874 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-make @@ -0,0 +1 @@ +Subproject commit a4b9187417d6be349ee5fd4b6e77b4172c6827dd diff --git a/languages.toml b/languages.toml index c8f9bab4..afee20aa 100644 --- a/languages.toml +++ b/languages.toml @@ -390,6 +390,13 @@ indent = { tab-width = 2, unit = " " } language-server = { command = "cmake-language-server" } injection-regex = "cmake" +[[language]] +name = "make" +scope = "source.make" +file-types = ["Makefile", "makefile", "justfile", ".justfile"] +roots =[] +comment-token = "#" + [[language]] name = "glsl" scope = "source.glsl" diff --git a/runtime/queries/make/highlights.scm b/runtime/queries/make/highlights.scm new file mode 100644 index 00000000..50380baf --- /dev/null +++ b/runtime/queries/make/highlights.scm @@ -0,0 +1,170 @@ +[ + "(" + ")" + "{" + "}" +] @punctuation.bracket + +[ + ":" + "&:" + "::" + "|" + ";" + "\"" + "'" + "," +] @punctuation.delimiter + +[ + "$" + "$$" +] @punctuation.special + +(automatic_variable + [ "@" "%" "<" "?" "^" "+" "/" "*" "D" "F"] @punctuation.special) + +(automatic_variable + "/" @error . ["D" "F"]) + +[ + "=" + ":=" + "::=" + "?=" + "+=" + "!=" + "@" + "-" + "+" +] @operator + +[ + (text) + (string) + (raw_text) +] @string + +(variable_assignment (word) @string) + +[ + "ifeq" + "ifneq" + "ifdef" + "ifndef" + "else" + "endif" + "if" + "or" ; boolean functions are conditional in make grammar + "and" +] @keyword.control.conditional + +"foreach" @keyword.control.repeat + +[ + "define" + "endef" + "vpath" + "undefine" + "export" + "unexport" + "override" + "private" +; "load" +] @keyword + +[ + "include" + "sinclude" + "-include" +] @keyword.control.import + +[ + "subst" + "patsubst" + "strip" + "findstring" + "filter" + "filter-out" + "sort" + "word" + "words" + "wordlist" + "firstword" + "lastword" + "dir" + "notdir" + "suffix" + "basename" + "addsuffix" + "addprefix" + "join" + "wildcard" + "realpath" + "abspath" + "call" + "eval" + "file" + "value" + "shell" +] @keyword.function + +[ + "error" + "warning" + "info" +] @keyword.control.exception + +;; Variable +(variable_assignment + name: (word) @variable) + +(variable_reference + (word) @variable) + +(comment) @comment + +((word) @clean @string.regexp + (#match? @clean "[%\*\?]")) + +(function_call + function: "error" + (arguments (text) @error)) + +(function_call + function: "warning" + (arguments (text) @warning)) + +(function_call + function: "info" + (arguments (text) @info)) + +;; Install Command Categories +;; Others special variables +;; Variables Used by Implicit Rules +[ + "VPATH" + ".RECIPEPREFIX" +] @constant.builtin + +(variable_assignment + name: (word) @clean @constant.builtin + (#match? @clean "^(AR|AS|CC|CXX|CPP|FC|M2C|PC|CO|GET|LEX|YACC|LINT|MAKEINFO|TEX|TEXI2DVI|WEAVE|CWEAVE|TANGLE|CTANGLE|RM|ARFLAGS|ASFLAGS|CFLAGS|CXXFLAGS|COFLAGS|CPPFLAGS|FFLAGS|GFLAGS|LDFLAGS|LDLIBS|LFLAGS|YFLAGS|PFLAGS|RFLAGS|LINTFLAGS|PRE_INSTALL|POST_INSTALL|NORMAL_INSTALL|PRE_UNINSTALL|POST_UNINSTALL|NORMAL_UNINSTALL|MAKEFILE_LIST|MAKE_RESTARTS|MAKE_TERMOUT|MAKE_TERMERR|\.DEFAULT_GOAL|\.RECIPEPREFIX|\.EXTRA_PREREQS)$")) + +(variable_reference + (word) @clean @constant.builtin + (#match? @clean "^(AR|AS|CC|CXX|CPP|FC|M2C|PC|CO|GET|LEX|YACC|LINT|MAKEINFO|TEX|TEXI2DVI|WEAVE|CWEAVE|TANGLE|CTANGLE|RM|ARFLAGS|ASFLAGS|CFLAGS|CXXFLAGS|COFLAGS|CPPFLAGS|FFLAGS|GFLAGS|LDFLAGS|LDLIBS|LFLAGS|YFLAGS|PFLAGS|RFLAGS|LINTFLAGS|PRE_INSTALL|POST_INSTALL|NORMAL_INSTALL|PRE_UNINSTALL|POST_UNINSTALL|NORMAL_UNINSTALL|MAKEFILE_LIST|MAKE_RESTARTS|MAKE_TERMOUT|MAKE_TERMERR|\.DEFAULT_GOAL|\.RECIPEPREFIX|\.EXTRA_PREREQS\.VARIABLES|\.FEATURES|\.INCLUDE_DIRS|\.LOADED)$")) + +;; Standart targets +(targets + (word) @constant.macro + (#match? @constant.macro "^(all|install|install-html|install-dvi|install-pdf|install-ps|uninstall|install-strip|clean|distclean|mostlyclean|maintainer-clean|TAGS|info|dvi|html|pdf|ps|dist|check|installcheck|installdirs)$")) + +(targets + (word) @constant.macro + (#match? @constant.macro "^(all|install|install-html|install-dvi|install-pdf|install-ps|uninstall|install-strip|clean|distclean|mostlyclean|maintainer-clean|TAGS|info|dvi|html|pdf|ps|dist|check|installcheck|installdirs)$")) + +;; Builtin targets +(targets + (word) @constant.macro + (#match? @constant.macro "^\.(PHONY|SUFFIXES|DEFAULT|PRECIOUS|INTERMEDIATE|SECONDARY|SECONDEXPANSION|DELETE_ON_ERROR|IGNORE|LOW_RESOLUTION_TIME|SILENT|EXPORT_ALL_VARIABLES|NOTPARALLEL|ONESHELL|POSIX)$")) From 5b45bdd80f1b2bd456d247ed6d2d95e9efb9d304 Mon Sep 17 00:00:00 2001 From: Eric Crosson Date: Mon, 3 Jan 2022 20:31:17 -0600 Subject: [PATCH 09/12] docs: document @keyword.control.exception scope As identified in [this GitHub comment](https://github.com/helix-editor/helix/pull/1433#discussion_r777786140) --- book/src/themes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/book/src/themes.md b/book/src/themes.md index 29d3926e..1325de8c 100644 --- a/book/src/themes.md +++ b/book/src/themes.md @@ -147,6 +147,7 @@ We use a similar set of scopes as - `repeat` - `for`, `while`, `loop` - `import` - `import`, `export` - `return` + - `exception` - `operator` - `or`, `in` - `directive` - Preprocessor directives (`#if` in C) - `function` - `fn`, `func` From 939261fc078cea86d0e7f712222b9ae22785478c Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sat, 8 Jan 2022 09:31:05 -0600 Subject: [PATCH 10/12] expand_selection to current node with no children (#1454) --- helix-core/src/object.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helix-core/src/object.rs b/helix-core/src/object.rs index 21fa24fb..3363e20b 100644 --- a/helix-core/src/object.rs +++ b/helix-core/src/object.rs @@ -12,7 +12,7 @@ pub fn expand_selection(syntax: &Syntax, text: RopeSlice, selection: &Selection) .root_node() .descendant_for_byte_range(from, to) .and_then(|node| { - if node.child_count() == 0 || (node.start_byte() == from && node.end_byte() == to) { + if node.start_byte() == from && node.end_byte() == to { node.parent() } else { Some(node) From 05e5520ec0fba35316519dca233277761e8fd17f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Cortier?= Date: Sat, 8 Jan 2022 10:32:50 -0500 Subject: [PATCH 11/12] Put some tests behind #[cfg(test)] (#1459) It was missing in a few places. --- helix-term/src/config.rs | 49 +++++++++++---------- helix-view/src/theme.rs | 93 +++++++++++++++++++++------------------- 2 files changed, 76 insertions(+), 66 deletions(-) diff --git a/helix-term/src/config.rs b/helix-term/src/config.rs index 3745f871..6b8bbc1b 100644 --- a/helix-term/src/config.rs +++ b/helix-term/src/config.rs @@ -20,14 +20,18 @@ pub struct LspConfig { pub display_messages: bool, } -#[test] -fn parsing_keymaps_config_file() { - use crate::keymap; - use crate::keymap::Keymap; - use helix_core::hashmap; - use helix_view::document::Mode; +#[cfg(test)] +mod tests { + use super::*; - let sample_keymaps = r#" + #[test] + fn parsing_keymaps_config_file() { + use crate::keymap; + use crate::keymap::Keymap; + use helix_core::hashmap; + use helix_view::document::Mode; + + let sample_keymaps = r#" [keys.insert] y = "move_line_down" S-C-a = "delete_selection" @@ -36,19 +40,20 @@ fn parsing_keymaps_config_file() { A-F12 = "move_next_word_end" "#; - assert_eq!( - toml::from_str::(sample_keymaps).unwrap(), - Config { - keys: Keymaps(hashmap! { - Mode::Insert => Keymap::new(keymap!({ "Insert mode" - "y" => move_line_down, - "S-C-a" => delete_selection, - })), - Mode::Normal => Keymap::new(keymap!({ "Normal mode" - "A-F12" => move_next_word_end, - })), - }), - ..Default::default() - } - ); + assert_eq!( + toml::from_str::(sample_keymaps).unwrap(), + Config { + keys: Keymaps(hashmap! { + Mode::Insert => Keymap::new(keymap!({ "Insert mode" + "y" => move_line_down, + "S-C-a" => delete_selection, + })), + Mode::Normal => Keymap::new(keymap!({ "Normal mode" + "A-F12" => move_next_word_end, + })), + }), + ..Default::default() + } + ); + } } diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs index 4a2ecbba..00c1bbbd 100644 --- a/helix-view/src/theme.rs +++ b/helix-view/src/theme.rs @@ -296,53 +296,58 @@ impl TryFrom for ThemePalette { } } -#[test] -fn test_parse_style_string() { - let fg = Value::String("#ffffff".to_string()); +#[cfg(test)] +mod tests { + use super::*; - let mut style = Style::default(); - let palette = ThemePalette::default(); - palette.parse_style(&mut style, fg).unwrap(); + #[test] + fn test_parse_style_string() { + let fg = Value::String("#ffffff".to_string()); - assert_eq!(style, Style::default().fg(Color::Rgb(255, 255, 255))); -} + let mut style = Style::default(); + let palette = ThemePalette::default(); + palette.parse_style(&mut style, fg).unwrap(); -#[test] -fn test_palette() { - use helix_core::hashmap; - let fg = Value::String("my_color".to_string()); - - let mut style = Style::default(); - let palette = - ThemePalette::new(hashmap! { "my_color".to_string() => Color::Rgb(255, 255, 255) }); - palette.parse_style(&mut style, fg).unwrap(); - - assert_eq!(style, Style::default().fg(Color::Rgb(255, 255, 255))); -} - -#[test] -fn test_parse_style_table() { - let table = toml::toml! { - "keyword" = { - fg = "#ffffff", - bg = "#000000", - modifiers = ["bold"], - } - }; - - let mut style = Style::default(); - let palette = ThemePalette::default(); - if let Value::Table(entries) = table { - for (_name, value) in entries { - palette.parse_style(&mut style, value).unwrap(); - } + assert_eq!(style, Style::default().fg(Color::Rgb(255, 255, 255))); } - assert_eq!( - style, - Style::default() - .fg(Color::Rgb(255, 255, 255)) - .bg(Color::Rgb(0, 0, 0)) - .add_modifier(Modifier::BOLD) - ); + #[test] + fn test_palette() { + use helix_core::hashmap; + let fg = Value::String("my_color".to_string()); + + let mut style = Style::default(); + let palette = + ThemePalette::new(hashmap! { "my_color".to_string() => Color::Rgb(255, 255, 255) }); + palette.parse_style(&mut style, fg).unwrap(); + + assert_eq!(style, Style::default().fg(Color::Rgb(255, 255, 255))); + } + + #[test] + fn test_parse_style_table() { + let table = toml::toml! { + "keyword" = { + fg = "#ffffff", + bg = "#000000", + modifiers = ["bold"], + } + }; + + let mut style = Style::default(); + let palette = ThemePalette::default(); + if let Value::Table(entries) = table { + for (_name, value) in entries { + palette.parse_style(&mut style, value).unwrap(); + } + } + + assert_eq!( + style, + Style::default() + .fg(Color::Rgb(255, 255, 255)) + .bg(Color::Rgb(0, 0, 0)) + .add_modifier(Modifier::BOLD) + ); + } } From 97e12f5c5a26cbbc2eddffd91a2e506403d4d453 Mon Sep 17 00:00:00 2001 From: Cottser <327943+Cottser@users.noreply.github.com> Date: Sat, 8 Jan 2022 21:45:54 -0500 Subject: [PATCH 12/12] docs: editor.filepicker -> editor.file-picker (#1465) --- book/src/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/src/configuration.md b/book/src/configuration.md index 33a933b2..be1a0809 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -25,7 +25,7 @@ To override global configuration parameters, create a `config.toml` file located | `auto-info` | Whether to display infoboxes | `true` | | `true-color` | Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative. | `false` | -`[editor.filepicker]` section of the config. Sets options for file picker and global search. All but the last key listed in the default file-picker configuration below are IgnoreOptions: whether hidden files and files listed within ignore files are ignored by (not visible in) the helix file picker and global search. There is also one other key, `max-depth` available, which is not defined by default. +`[editor.file-picker]` section of the config. Sets options for file picker and global search. All but the last key listed in the default file-picker configuration below are IgnoreOptions: whether hidden files and files listed within ignore files are ignored by (not visible in) the helix file picker and global search. There is also one other key, `max-depth` available, which is not defined by default. | Key | Description | Default | |--|--|---------|