From 0683f0a20ae1c1ce3e7788e303c468767381e6fd Mon Sep 17 00:00:00 2001 From: Oliver Hechtl Date: Sat, 18 Dec 2021 05:40:34 +0100 Subject: Add scala syntax highlights (#1278) * add partial scala syntax highlights * ran cargo xtask docgen * updated tree-sitter-scala, fixed highlights * fix comments * move identifier to the end of the highlights * add indents--- book/src/generated/lang-support.md | 1 + 1 file changed, 1 insertion(+) (limited to 'book/src/generated') diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 80989e63..b7babd8c 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -31,6 +31,7 @@ | racket | | | | `racket` | | ruby | ✓ | | | `solargraph` | | rust | ✓ | ✓ | ✓ | `rust-analyzer` | +| scala | ✓ | | | `metals` | | svelte | ✓ | | ✓ | `svelteserver` | | toml | ✓ | | | | | tsq | ✓ | | | | -- cgit v1.2.3-70-g09d2 From a66833590c7dc87b5e015266bace900d46b98b34 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Sat, 18 Dec 2021 13:42:41 +0900 Subject: cargo xtask docgen --- book/src/generated/lang-support.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'book/src/generated') diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index b7babd8c..3255b9af 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -6,6 +6,7 @@ | cmake | ✓ | | | `cmake-language-server` | | cpp | ✓ | | | `clangd` | | css | ✓ | | | | +| dart | ✓ | | ✓ | `dart` | | elixir | ✓ | | | `elixir-ls` | | glsl | ✓ | | ✓ | | | go | ✓ | ✓ | ✓ | `gopls` | @@ -31,7 +32,7 @@ | racket | | | | `racket` | | ruby | ✓ | | | `solargraph` | | rust | ✓ | ✓ | ✓ | `rust-analyzer` | -| scala | ✓ | | | `metals` | +| scala | ✓ | | ✓ | `metals` | | svelte | ✓ | | ✓ | `svelteserver` | | toml | ✓ | | | | | tsq | ✓ | | | | -- cgit v1.2.3-70-g09d2 From e72786df8eae5684c0330be18f190a33f516da76 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sun, 19 Dec 2021 08:56:56 -0600 Subject: Add tree-sitter-comment (#1300) * Add tree-sitter-comment Fix #1164 * fix precedence in tree-sitter-comment highlights connects https://github.com/helix-editor/helix/pull/1170 * set injection-regex for comment language * remove comment filetype * fix comment injections for neovim-style injections tags * add comment injections for elixir * remove f.comment * fix spacing in .gitmodules * run 'cargo xtask docgen' Co-authored-by: Ivan Tham --- .gitmodules | 4 ++++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-comment | 1 + languages.toml | 9 ++++++++- runtime/queries/comment/highlights.scm | 30 ++++++++++++++++++++++++++++++ runtime/queries/elixir/injections.scm | 2 ++ runtime/queries/glsl/injections.scm | 6 ++++-- runtime/queries/julia/injections.scm | 8 +++++--- runtime/queries/ledger/injections.scm | 4 ++-- runtime/queries/python/injections.scm | 2 ++ runtime/queries/rust/injections.scm | 3 +++ runtime/queries/svelte/injections.scm | 4 ++-- runtime/queries/tsq/injections.scm | 2 ++ 13 files changed, 66 insertions(+), 10 deletions(-) create mode 160000 helix-syntax/languages/tree-sitter-comment create mode 100644 runtime/queries/comment/highlights.scm create mode 100644 runtime/queries/elixir/injections.scm create mode 100644 runtime/queries/python/injections.scm create mode 100644 runtime/queries/tsq/injections.scm (limited to 'book/src/generated') diff --git a/.gitmodules b/.gitmodules index a899c778..c7b81336 100644 --- a/.gitmodules +++ b/.gitmodules @@ -142,6 +142,10 @@ path = helix-syntax/languages/tree-sitter-perl url = https://github.com/ganezdragon/tree-sitter-perl shallow = true +[submodule "helix-syntax/languages/tree-sitter-comment"] + path = helix-syntax/languages/tree-sitter-comment + url = https://github.com/stsewd/tree-sitter-comment + shallow = true [submodule "helix-syntax/languages/tree-sitter-wgsl"] path = helix-syntax/languages/tree-sitter-wgsl url = https://github.com/szebniok/tree-sitter-wgsl diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 3255b9af..cb91872b 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -4,6 +4,7 @@ | c | ✓ | | | `clangd` | | c-sharp | ✓ | | | | | cmake | ✓ | | | `cmake-language-server` | +| comment | ✓ | | | | | cpp | ✓ | | | `clangd` | | css | ✓ | | | | | dart | ✓ | | ✓ | `dart` | diff --git a/helix-syntax/languages/tree-sitter-comment b/helix-syntax/languages/tree-sitter-comment new file mode 160000 index 00000000..5dd3c62f --- /dev/null +++ b/helix-syntax/languages/tree-sitter-comment @@ -0,0 +1 @@ +Subproject commit 5dd3c62f1bbe378b220fe16b317b85247898639e diff --git a/languages.toml b/languages.toml index 5c2bc8bb..0695022e 100644 --- a/languages.toml +++ b/languages.toml @@ -406,6 +406,13 @@ shebangs = ["racket"] comment-token = ";" language-server = { command = "racket", args = ["-l", "racket-langserver"] } +[[language]] +name = "comment" +scope = "scope.comment" +roots = [] +file-types = [] +injection-regex = "comment" + [[language]] name = "wgsl" scope = "source.wgsl" @@ -448,4 +455,4 @@ roots = ["build.sbt"] file-types = ["scala", "sbt"] comment-token = "//" indent = { tab-width = 2, unit = " " } -language-server = { command = "metals" } \ No newline at end of file +language-server = { command = "metals" } diff --git a/runtime/queries/comment/highlights.scm b/runtime/queries/comment/highlights.scm new file mode 100644 index 00000000..88685d59 --- /dev/null +++ b/runtime/queries/comment/highlights.scm @@ -0,0 +1,30 @@ +[ + "(" + ")" +] @punctuation.bracket + +":" @punctuation.delimiter + +((tag (name) @warning) + (#match? @warning "^(TODO|HACK|WARNING)$")) + +("text" @warning + (#match? @warning "^(TODO|HACK|WARNING)$")) + +((tag (name) @error) + (match? @error "^(FIXME|XXX|BUG)$")) + +("text" @error + (match? @error "^(FIXME|XXX|BUG)$")) + +(tag + (name) @ui.text + (user)? @constant) + +; Issue number (#123) +("text" @constant.numeric + (#match? @constant.numeric "^#[0-9]+$")) + +; User mention (@user) +("text" @tag + (#match? @tag "^[@][a-zA-Z0-9_-]+$")) diff --git a/runtime/queries/elixir/injections.scm b/runtime/queries/elixir/injections.scm new file mode 100644 index 00000000..321c90ad --- /dev/null +++ b/runtime/queries/elixir/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/glsl/injections.scm b/runtime/queries/glsl/injections.scm index 7d3323b1..b01b8b4b 100644 --- a/runtime/queries/glsl/injections.scm +++ b/runtime/queries/glsl/injections.scm @@ -1,3 +1,5 @@ -(preproc_arg) @glsl +((preproc_arg) @injection.content + (#set! injection.language "glsl")) -(comment) @comment +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/julia/injections.scm b/runtime/queries/julia/injections.scm index be2412c0..3cf7339f 100644 --- a/runtime/queries/julia/injections.scm +++ b/runtime/queries/julia/injections.scm @@ -1,5 +1,7 @@ ; TODO: re-add when markdown is added. -; ((triple_string) @markdown -; (#offset! @markdown 0 3 0 -3)) +; ((triple_string) @injection.content +; (#offset! @injection.content 0 3 0 -3) +; (#set! injection.language "markdown")) -(comment) @comment +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/ledger/injections.scm b/runtime/queries/ledger/injections.scm index 2d948141..c1714786 100644 --- a/runtime/queries/ledger/injections.scm +++ b/runtime/queries/ledger/injections.scm @@ -1,2 +1,2 @@ -(comment) @comment -(note) @comment +([(comment) (note)] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/python/injections.scm b/runtime/queries/python/injections.scm new file mode 100644 index 00000000..321c90ad --- /dev/null +++ b/runtime/queries/python/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/rust/injections.scm b/runtime/queries/rust/injections.scm index 6035d418..d8382e49 100644 --- a/runtime/queries/rust/injections.scm +++ b/runtime/queries/rust/injections.scm @@ -1,3 +1,6 @@ +([(line_comment) (block_comment)] @injection.content + (#set! injection.language "comment")) + ((macro_invocation (token_tree) @injection.content) (#set! injection.language "rust") diff --git a/runtime/queries/svelte/injections.scm b/runtime/queries/svelte/injections.scm index 266f4701..04e860cf 100644 --- a/runtime/queries/svelte/injections.scm +++ b/runtime/queries/svelte/injections.scm @@ -26,5 +26,5 @@ (#set! injection.language "typescript") ) -(comment) @comment - +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/tsq/injections.scm b/runtime/queries/tsq/injections.scm new file mode 100644 index 00000000..321c90ad --- /dev/null +++ b/runtime/queries/tsq/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) -- cgit v1.2.3-70-g09d2 From 205dc8776b6ff4f5ab331df9c33b33e44caab12c Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Tue, 21 Dec 2021 03:02:53 +0100 Subject: Add fish highlighting (#1308) The highlights were copied and modified from https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/fish/highlights.scm--- .gitmodules | 4 + book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-fish | 1 + languages.toml | 11 +++ runtime/queries/fish/highlights.scm | 156 ++++++++++++++++++++++++++++++++ runtime/queries/fish/indents.toml | 12 +++ runtime/queries/fish/injections.scm | 2 + runtime/queries/fish/textobjects.scm | 1 + 8 files changed, 188 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-fish create mode 100644 runtime/queries/fish/highlights.scm create mode 100644 runtime/queries/fish/indents.toml create mode 100644 runtime/queries/fish/injections.scm create mode 100644 runtime/queries/fish/textobjects.scm (limited to 'book/src/generated') diff --git a/.gitmodules b/.gitmodules index c7b81336..dcec2813 100644 --- a/.gitmodules +++ b/.gitmodules @@ -162,3 +162,7 @@ path = helix-syntax/languages/tree-sitter-dart url = https://github.com/UserNobody14/tree-sitter-dart.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-fish"] + path = helix-syntax/languages/tree-sitter-fish + url = https://github.com/ram02z/tree-sitter-fish + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index cb91872b..24b75b64 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -9,6 +9,7 @@ | css | ✓ | | | | | dart | ✓ | | ✓ | `dart` | | elixir | ✓ | | | `elixir-ls` | +| fish | ✓ | ✓ | ✓ | | | glsl | ✓ | | ✓ | | | go | ✓ | ✓ | ✓ | `gopls` | | html | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-fish b/helix-syntax/languages/tree-sitter-fish new file mode 160000 index 00000000..04e54ab6 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-fish @@ -0,0 +1 @@ +Subproject commit 04e54ab6585dfd4fee6ddfe5849af56f101b6d4f diff --git a/languages.toml b/languages.toml index 0695022e..61eb47ec 100644 --- a/languages.toml +++ b/languages.toml @@ -45,6 +45,17 @@ comment-token = "#" language-server = { command = "elixir-ls" } indent = { tab-width = 2, unit = " " } +[[language]] +name = "fish" +scope = "source.fish" +injection-regex = "fish" +file-types = ["fish"] +shebangs = ["fish"] +roots = [] +comment-token = "#" + +indent = { tab-width = 4, unit = " " } + [[language]] name = "mint" scope = "source.mint" diff --git a/runtime/queries/fish/highlights.scm b/runtime/queries/fish/highlights.scm new file mode 100644 index 00000000..def53931 --- /dev/null +++ b/runtime/queries/fish/highlights.scm @@ -0,0 +1,156 @@ +;; Operators + +[ + "&&" + "||" + "|" + "&" + "=" + "!=" + ".." + "!" + (direction) + (stream_redirect) + (test_option) +] @operator + +[ + "not" + "and" + "or" +] @keyword.operator + +;; Conditionals + +(if_statement +[ + "if" + "end" +] @keyword.control.conditional) + +(switch_statement +[ + "switch" + "end" +] @keyword.control.conditional) + +(case_clause +[ + "case" +] @keyword.control.conditional) + +(else_clause +[ + "else" +] @keyword.control.conditional) + +(else_if_clause +[ + "else" + "if" +] @keyword.control.conditional) + +;; Loops/Blocks + +(while_statement +[ + "while" + "end" +] @keyword.control.repeat) + +(for_statement +[ + "for" + "end" +] @keyword.control.repeat) + +(begin_statement +[ + "begin" + "end" +] @keyword.control.repeat) + +;; Keywords + +[ + "in" + (break) + (continue) +] @keyword + +"return" @keyword.control.return + +;; Punctuation + +[ + "[" + "]" + "{" + "}" + "(" + ")" +] @punctuation.bracket + +"," @punctuation.delimiter + +;; Commands + +(command + argument: [ + (word) @variable.parameter (#match? @variable.parameter "^-") + ] +) + +; non-bultin command names +(command name: (word) @function) + +; derived from builtin -n (fish 3.2.2) +(command + name: [ + (word) @function.builtin + (#match? @function.builtin "^(\.|:|_|alias|argparse|bg|bind|block|breakpoint|builtin|cd|command|commandline|complete|contains|count|disown|echo|emit|eval|exec|exit|fg|functions|history|isatty|jobs|math|printf|pwd|random|read|realpath|set|set_color|source|status|string|test|time|type|ulimit|wait)$") + ] +) + +(test_command "test" @function.builtin) + +;; Functions + +(function_definition ["function" "end"] @keyword.function) + +(function_definition + name: [ + (word) (concatenation) + ] +@function) + +(function_definition + option: [ + (word) + (concatenation (word)) + ] @variable.parameter (#match? @variable.parameter "^-") +) + +;; Strings + +[(double_quote_string) (single_quote_string)] @string +(escape_sequence) @constant.character.escape + +;; Variables + +(variable_name) @variable +(variable_expansion) @constant + +;; Nodes + +(integer) @constant.numeric.integer +(float) @constant.numeric.float +(comment) @comment +(test_option) @string + +((word) @constant.builtin.boolean +(#match? @constant.builtin.boolean "^(true|false)$")) + +;; Error + +(ERROR) @error diff --git a/runtime/queries/fish/indents.toml b/runtime/queries/fish/indents.toml new file mode 100644 index 00000000..6f1e563a --- /dev/null +++ b/runtime/queries/fish/indents.toml @@ -0,0 +1,12 @@ +indent = [ + "function_definition", + "while_statement", + "for_statement", + "if_statement", + "begin_statement", + "switch_statement", +] + +outdent = [ + "end" +] diff --git a/runtime/queries/fish/injections.scm b/runtime/queries/fish/injections.scm new file mode 100644 index 00000000..321c90ad --- /dev/null +++ b/runtime/queries/fish/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/fish/textobjects.scm b/runtime/queries/fish/textobjects.scm new file mode 100644 index 00000000..67fd6614 --- /dev/null +++ b/runtime/queries/fish/textobjects.scm @@ -0,0 +1 @@ +(function_definition) @function.around -- cgit v1.2.3-70-g09d2 From dba22c60ed7fc336ad619b1246333f0116b47bcd Mon Sep 17 00:00:00 2001 From: Midnight Exigent Date: Tue, 21 Dec 2021 10:22:15 +0100 Subject: Support dockerfiles (#1303) * allow language.config (in languages.toml) to be passed in as a toml object * Change config field for languages from json string to toml object * remove indents on languages.toml config * fix: remove patch version from serde_json import in helix-core * Use same tree-sitter-zig as upstream/master * fix(completion_popup): Fixes #1256 * Update helix-term/src/ui/completion.rs * feat(languages): Add support for `Dockerfile`s * docs(cargo-xtask-docgen): * improvement(langs-dockerfile): Add `injection-regex` to `languages.toml` for `Dockerfile` * improvement(langs-dockerfile): Add injections.scm * Update .gitmodules Co-authored-by: Blaž Hrastnik --- .gitmodules | 4 +++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-dockerfile | 1 + languages.toml | 11 ++++++ runtime/queries/dockerfile/highlights.scm | 51 +++++++++++++++++++++++++++ runtime/queries/dockerfile/injections.scm | 6 ++++ 6 files changed, 74 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-dockerfile create mode 100644 runtime/queries/dockerfile/highlights.scm create mode 100644 runtime/queries/dockerfile/injections.scm (limited to 'book/src/generated') diff --git a/.gitmodules b/.gitmodules index dcec2813..edfe3c39 100644 --- a/.gitmodules +++ b/.gitmodules @@ -162,6 +162,10 @@ path = helix-syntax/languages/tree-sitter-dart url = https://github.com/UserNobody14/tree-sitter-dart.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-dockerfile"] + path = helix-syntax/languages/tree-sitter-dockerfile + url = https://github.com/camdencheek/tree-sitter-dockerfile.git + shallow = true [submodule "helix-syntax/languages/tree-sitter-fish"] path = helix-syntax/languages/tree-sitter-fish url = https://github.com/ram02z/tree-sitter-fish diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 24b75b64..c7054201 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -8,6 +8,7 @@ | cpp | ✓ | | | `clangd` | | css | ✓ | | | | | dart | ✓ | | ✓ | `dart` | +| dockerfile | ✓ | | | `docker-langserver` | | elixir | ✓ | | | `elixir-ls` | | fish | ✓ | ✓ | ✓ | | | glsl | ✓ | | ✓ | | diff --git a/helix-syntax/languages/tree-sitter-dockerfile b/helix-syntax/languages/tree-sitter-dockerfile new file mode 160000 index 00000000..7af32bc0 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-dockerfile @@ -0,0 +1 @@ +Subproject commit 7af32bc04a66ab196f5b9f92ac471f29372ae2ce diff --git a/languages.toml b/languages.toml index 61eb47ec..50c6f7f9 100644 --- a/languages.toml +++ b/languages.toml @@ -467,3 +467,14 @@ file-types = ["scala", "sbt"] comment-token = "//" indent = { tab-width = 2, unit = " " } language-server = { command = "metals" } + +[[language]] +name = "dockerfile" +scope = "source.dockerfile" +injection-regex = "docker|dockerfile" +roots = ["Dockerfile"] +file-types = ["Dockerfile"] +comment-token = "#" +indent = { tab-width = 2, unit = " " } +language-server = { command = "docker-langserver", args = ["--stdio"] } + diff --git a/runtime/queries/dockerfile/highlights.scm b/runtime/queries/dockerfile/highlights.scm new file mode 100644 index 00000000..5a945fb9 --- /dev/null +++ b/runtime/queries/dockerfile/highlights.scm @@ -0,0 +1,51 @@ +[ + "FROM" + "AS" + "RUN" + "CMD" + "LABEL" + "EXPOSE" + "ENV" + "ADD" + "COPY" + "ENTRYPOINT" + "VOLUME" + "USER" + "WORKDIR" + "ARG" + "ONBUILD" + "STOPSIGNAL" + "HEALTHCHECK" + "SHELL" + "MAINTAINER" + "CROSS_BUILD" +] @keyword + +[ + ":" + "@" +] @operator + +(comment) @comment + + +(image_spec + (image_tag + ":" @punctuation.special) + (image_digest + "@" @punctuation.special)) + +(double_quoted_string) @string + +(expansion + [ + "$" + "{" + "}" + ] @punctuation.special +) @none + +((variable) @constant + (#match? @constant "^[A-Z][A-Z_0-9]*$")) + + diff --git a/runtime/queries/dockerfile/injections.scm b/runtime/queries/dockerfile/injections.scm new file mode 100644 index 00000000..20396f1a --- /dev/null +++ b/runtime/queries/dockerfile/injections.scm @@ -0,0 +1,6 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +([(shell_command) (shell_fragment)] @injection.content + (#set! injection.language "bash")) + -- cgit v1.2.3-70-g09d2 From ec878e40114d8992c3ed1221f77271a4508d3cde Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Sat, 25 Dec 2021 16:10:19 +0100 Subject: Add textobjects and indents to cmake (#1307) --- book/src/generated/lang-support.md | 2 +- runtime/queries/cmake/indents.toml | 12 ++++++++++++ runtime/queries/cmake/textobjects.scm | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 runtime/queries/cmake/indents.toml create mode 100644 runtime/queries/cmake/textobjects.scm (limited to 'book/src/generated') diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index c7054201..2777dc4e 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -3,7 +3,7 @@ | bash | ✓ | | | `bash-language-server` | | c | ✓ | | | `clangd` | | c-sharp | ✓ | | | | -| cmake | ✓ | | | `cmake-language-server` | +| cmake | ✓ | ✓ | ✓ | `cmake-language-server` | | comment | ✓ | | | | | cpp | ✓ | | | `clangd` | | css | ✓ | | | | diff --git a/runtime/queries/cmake/indents.toml b/runtime/queries/cmake/indents.toml new file mode 100644 index 00000000..8b886a4f --- /dev/null +++ b/runtime/queries/cmake/indents.toml @@ -0,0 +1,12 @@ +indent = [ + "if_condition", + "foreach_loop", + "while_loop", + "function_def", + "macro_def", + "normal_command", +] + +outdent = [ + ")" +] diff --git a/runtime/queries/cmake/textobjects.scm b/runtime/queries/cmake/textobjects.scm new file mode 100644 index 00000000..b0d1b108 --- /dev/null +++ b/runtime/queries/cmake/textobjects.scm @@ -0,0 +1,3 @@ +(macro_def) @function.around + +(argument) @parameter.inside -- cgit v1.2.3-70-g09d2 From fd31662b70ee32d199950ba2873680fc9043c975 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Fri, 24 Dec 2021 12:44:45 -0600 Subject: add gitcommit grammar and language configuration --- .gitmodules | 6 +++++- book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-gitcommit | 1 + languages.toml | 8 ++++++++ 4 files changed, 15 insertions(+), 1 deletion(-) create mode 160000 helix-syntax/languages/tree-sitter-gitcommit (limited to 'book/src/generated') diff --git a/.gitmodules b/.gitmodules index edfe3c39..ad100a00 100644 --- a/.gitmodules +++ b/.gitmodules @@ -165,8 +165,12 @@ [submodule "helix-syntax/languages/tree-sitter-dockerfile"] path = helix-syntax/languages/tree-sitter-dockerfile url = https://github.com/camdencheek/tree-sitter-dockerfile.git - shallow = true + shallow = true [submodule "helix-syntax/languages/tree-sitter-fish"] path = helix-syntax/languages/tree-sitter-fish url = https://github.com/ram02z/tree-sitter-fish shallow = true +[submodule "helix-syntax/languages/tree-sitter-gitcommit"] + path = helix-syntax/languages/tree-sitter-gitcommit + url = https://github.com/the-mikedavis/tree-sitter-gitcommit.git + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 2777dc4e..d6e0d9af 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -11,6 +11,7 @@ | dockerfile | ✓ | | | `docker-langserver` | | elixir | ✓ | | | `elixir-ls` | | fish | ✓ | ✓ | ✓ | | +| gitcommit | ✓ | | | | | glsl | ✓ | | ✓ | | | go | ✓ | ✓ | ✓ | `gopls` | | html | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-gitcommit b/helix-syntax/languages/tree-sitter-gitcommit new file mode 160000 index 00000000..6a2ddbec --- /dev/null +++ b/helix-syntax/languages/tree-sitter-gitcommit @@ -0,0 +1 @@ +Subproject commit 6a2ddbecd49fa8e7e1fda24d43e363cfd9171ca0 diff --git a/languages.toml b/languages.toml index dd18fa19..f73011c8 100644 --- a/languages.toml +++ b/languages.toml @@ -473,3 +473,11 @@ file-types = ["Dockerfile", "dockerfile"] comment-token = "#" indent = { tab-width = 2, unit = " " } language-server = { command = "docker-langserver", args = ["--stdio"] } + +[[language]] +name = "gitcommit" +scope = "git.commitmsg" +roots = [] +file-types = ["COMMIT_EDITMSG"] +comment-token = "#" +indent = { tab-width = 2, unit = " " } -- cgit v1.2.3-70-g09d2 From c3fb86cbaa5c6973fe014a4401c4e0d6f663384d Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Fri, 24 Dec 2021 16:49:27 -0600 Subject: tree-sitter-gitcommit->tree-sitter-git-commit --- .gitmodules | 6 +++--- book/src/generated/lang-support.md | 2 +- helix-syntax/languages/tree-sitter-git-commit | 1 + helix-syntax/languages/tree-sitter-gitcommit | 1 - languages.toml | 2 +- runtime/queries/git-commit/highlights.scm | 18 ++++++++++++++++++ runtime/queries/git-commit/injections.scm | 15 +++++++++++++++ runtime/queries/gitcommit/highlights.scm | 18 ------------------ runtime/queries/gitcommit/injections.scm | 15 --------------- 9 files changed, 39 insertions(+), 39 deletions(-) create mode 160000 helix-syntax/languages/tree-sitter-git-commit delete mode 160000 helix-syntax/languages/tree-sitter-gitcommit create mode 100644 runtime/queries/git-commit/highlights.scm create mode 100644 runtime/queries/git-commit/injections.scm delete mode 100644 runtime/queries/gitcommit/highlights.scm delete mode 100644 runtime/queries/gitcommit/injections.scm (limited to 'book/src/generated') diff --git a/.gitmodules b/.gitmodules index ad100a00..d5bd61c9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -170,7 +170,7 @@ path = helix-syntax/languages/tree-sitter-fish url = https://github.com/ram02z/tree-sitter-fish shallow = true -[submodule "helix-syntax/languages/tree-sitter-gitcommit"] - path = helix-syntax/languages/tree-sitter-gitcommit - url = https://github.com/the-mikedavis/tree-sitter-gitcommit.git +[submodule "helix-syntax/languages/tree-sitter-git-commit"] + path = helix-syntax/languages/tree-sitter-git-commit + url = https://github.com/the-mikedavis/tree-sitter-git-commit.git shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index d6e0d9af..9c42005b 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -11,7 +11,7 @@ | dockerfile | ✓ | | | `docker-langserver` | | elixir | ✓ | | | `elixir-ls` | | fish | ✓ | ✓ | ✓ | | -| gitcommit | ✓ | | | | +| git-commit | ✓ | | | | | glsl | ✓ | | ✓ | | | go | ✓ | ✓ | ✓ | `gopls` | | html | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-git-commit b/helix-syntax/languages/tree-sitter-git-commit new file mode 160000 index 00000000..5cd4776c --- /dev/null +++ b/helix-syntax/languages/tree-sitter-git-commit @@ -0,0 +1 @@ +Subproject commit 5cd4776c86c82d9d6afdc8c73a47a08057aef618 diff --git a/helix-syntax/languages/tree-sitter-gitcommit b/helix-syntax/languages/tree-sitter-gitcommit deleted file mode 160000 index 6a2ddbec..00000000 --- a/helix-syntax/languages/tree-sitter-gitcommit +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6a2ddbecd49fa8e7e1fda24d43e363cfd9171ca0 diff --git a/languages.toml b/languages.toml index f73011c8..616ef234 100644 --- a/languages.toml +++ b/languages.toml @@ -475,7 +475,7 @@ indent = { tab-width = 2, unit = " " } language-server = { command = "docker-langserver", args = ["--stdio"] } [[language]] -name = "gitcommit" +name = "git-commit" scope = "git.commitmsg" roots = [] file-types = ["COMMIT_EDITMSG"] diff --git a/runtime/queries/git-commit/highlights.scm b/runtime/queries/git-commit/highlights.scm new file mode 100644 index 00000000..04d70416 --- /dev/null +++ b/runtime/queries/git-commit/highlights.scm @@ -0,0 +1,18 @@ +(subject) @markup.heading +(path) @string.special.path +(branch) @string.special.symbol +(commit) @constant +(item) @markup.link.url +(header) @tag + +(change kind: "new file" @diff.plus) +(change kind: "deleted" @diff.minus) +(change kind: "modified" @diff.delta) +(change kind: "renamed" @diff.delta.moved) + +[":" "->"] @punctuation.delimeter +(comment) @comment + +; once we have diff injections, @comment should become @none +((comment (scissors)) + (message)+ @comment) diff --git a/runtime/queries/git-commit/injections.scm b/runtime/queries/git-commit/injections.scm new file mode 100644 index 00000000..2837a586 --- /dev/null +++ b/runtime/queries/git-commit/injections.scm @@ -0,0 +1,15 @@ +; once a diff grammar is available, we can inject diff highlighting into the +; trailer after scissors (git commit --verbose) +; see https://github.com/helix-editor/helix/pull/1338#issuecomment-1000013539 +; +; ((comment (scissors)) +; (message) @injection.content +; (#set! injection.language "diff")) + +; --- + +; once a rebase grammar is available, we can inject rebase highlighting into +; interactive rebase summary sections like so: +; +; ((rebase_command) @injection.content +; (#set! injection.language "git-rebase")) diff --git a/runtime/queries/gitcommit/highlights.scm b/runtime/queries/gitcommit/highlights.scm deleted file mode 100644 index 04d70416..00000000 --- a/runtime/queries/gitcommit/highlights.scm +++ /dev/null @@ -1,18 +0,0 @@ -(subject) @markup.heading -(path) @string.special.path -(branch) @string.special.symbol -(commit) @constant -(item) @markup.link.url -(header) @tag - -(change kind: "new file" @diff.plus) -(change kind: "deleted" @diff.minus) -(change kind: "modified" @diff.delta) -(change kind: "renamed" @diff.delta.moved) - -[":" "->"] @punctuation.delimeter -(comment) @comment - -; once we have diff injections, @comment should become @none -((comment (scissors)) - (message)+ @comment) diff --git a/runtime/queries/gitcommit/injections.scm b/runtime/queries/gitcommit/injections.scm deleted file mode 100644 index 2837a586..00000000 --- a/runtime/queries/gitcommit/injections.scm +++ /dev/null @@ -1,15 +0,0 @@ -; once a diff grammar is available, we can inject diff highlighting into the -; trailer after scissors (git commit --verbose) -; see https://github.com/helix-editor/helix/pull/1338#issuecomment-1000013539 -; -; ((comment (scissors)) -; (message) @injection.content -; (#set! injection.language "diff")) - -; --- - -; once a rebase grammar is available, we can inject rebase highlighting into -; interactive rebase summary sections like so: -; -; ((rebase_command) @injection.content -; (#set! injection.language "git-rebase")) -- cgit v1.2.3-70-g09d2 From a306a1052a51c686b24a6f339190878b8029a894 Mon Sep 17 00:00:00 2001 From: Tamo Date: Sun, 26 Dec 2021 02:04:33 +0100 Subject: Update settings at runtime (#798) * feat: Update settings at runtime fix the clippy warning * update the documentation * use to_value instead of to_vec+from_value * drop the equal * remove an useless comment * apply suggestion--- book/src/generated/typable-cmd.md | 1 + helix-term/src/commands.rs | 37 +++++++++++++++++++++++++++++++++++++ helix-term/src/ui/mod.rs | 27 +++++++++++++++++++++++++++ helix-view/src/editor.rs | 20 ++++++++++++++++---- 4 files changed, 81 insertions(+), 4 deletions(-) (limited to 'book/src/generated') diff --git a/book/src/generated/typable-cmd.md b/book/src/generated/typable-cmd.md index bb21fd6b..f12082bb 100644 --- a/book/src/generated/typable-cmd.md +++ b/book/src/generated/typable-cmd.md @@ -41,3 +41,4 @@ | `:hsplit`, `:hs`, `:sp` | Open the file in a horizontal split. | | `:tutor` | Open the tutorial. | | `:goto`, `:g` | Go to line number. | +| `:set-option`, `:set` | Set a config option at runtime | diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index ee6a5989..7b1235f8 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2637,6 +2637,36 @@ pub mod cmd { let (view, doc) = current!(cx.editor); view.ensure_cursor_in_view(doc, line); + Ok(()) + } + + fn setting( + cx: &mut compositor::Context, + args: &[Cow], + _event: PromptEvent, + ) -> anyhow::Result<()> { + let runtime_config = &mut cx.editor.config; + + if args.len() != 2 { + anyhow::bail!("Bad arguments. Usage: `:set key field`"); + } + + let (key, arg) = (&args[0].to_lowercase(), &args[1]); + + match key.as_ref() { + "scrolloff" => runtime_config.scrolloff = arg.parse()?, + "scroll-lines" => runtime_config.scroll_lines = arg.parse()?, + "mouse" => runtime_config.mouse = arg.parse()?, + "line-number" => runtime_config.line_number = arg.parse()?, + "middle-click_paste" => runtime_config.middle_click_paste = arg.parse()?, + "smart-case" => runtime_config.smart_case = arg.parse()?, + "auto-pairs" => runtime_config.auto_pairs = arg.parse()?, + "auto-completion" => runtime_config.auto_completion = arg.parse()?, + "completion-trigger-len" => runtime_config.completion_trigger_len = arg.parse()?, + "auto-info" => runtime_config.auto_info = arg.parse()?, + "true-color" => runtime_config.true_color = arg.parse()?, + _ => anyhow::bail!("Unknown key `{}`.", args[0]), + } Ok(()) } @@ -2928,6 +2958,13 @@ pub mod cmd { doc: "Go to line number.", fun: goto_line_number, completer: None, + }, + TypableCommand { + name: "set-option", + aliases: &["set"], + doc: "Set a config option at runtime", + fun: setting, + completer: Some(completers::setting), } ]; diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index f57e2e2b..9e096311 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -174,7 +174,9 @@ pub mod completers { use crate::ui::prompt::Completion; use fuzzy_matcher::skim::SkimMatcherV2 as Matcher; use fuzzy_matcher::FuzzyMatcher; + use helix_view::editor::Config; use helix_view::theme; + use once_cell::sync::Lazy; use std::borrow::Cow; use std::cmp::Reverse; @@ -208,6 +210,31 @@ pub mod completers { names } + pub fn setting(input: &str) -> Vec { + static KEYS: Lazy> = Lazy::new(|| { + serde_json::to_value(Config::default()) + .unwrap() + .as_object() + .unwrap() + .keys() + .cloned() + .collect() + }); + + let matcher = Matcher::default(); + + let mut matches: Vec<_> = KEYS + .iter() + .filter_map(|name| matcher.fuzzy_match(name, input).map(|score| (name, score))) + .collect(); + + matches.sort_unstable_by_key(|(_file, score)| Reverse(*score)); + matches + .into_iter() + .map(|(name, _)| ((0..), name.into())) + .collect() + } + pub fn filename(input: &str) -> Vec { filename_impl(input, |entry| { let is_dir = entry.file_type().map_or(false, |entry| entry.is_dir()); diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index fd6eb4d5..f4b0f73e 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -27,7 +27,7 @@ pub use helix_core::register::Registers; use helix_core::syntax; use helix_core::{Position, Selection}; -use serde::Deserialize; +use serde::{Deserialize, Serialize}; fn deserialize_duration_millis<'de, D>(deserializer: D) -> Result where @@ -37,7 +37,7 @@ where Ok(Duration::from_millis(millis)) } -#[derive(Debug, Clone, PartialEq, Deserialize)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "kebab-case", default, deny_unknown_fields)] pub struct FilePickerConfig { /// IgnoreOptions @@ -77,7 +77,7 @@ impl Default for FilePickerConfig { } } -#[derive(Debug, Clone, PartialEq, Deserialize)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "kebab-case", default, deny_unknown_fields)] pub struct Config { /// Padding to keep between the edge of the screen and the cursor when scrolling. Defaults to 5. @@ -109,7 +109,7 @@ pub struct Config { pub true_color: bool, } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] pub enum LineNumber { /// Show absolute line number @@ -119,6 +119,18 @@ pub enum LineNumber { Relative, } +impl std::str::FromStr for LineNumber { + type Err = anyhow::Error; + + fn from_str(s: &str) -> Result { + match s.to_lowercase().as_str() { + "absolute" | "abs" => Ok(Self::Absolute), + "relative" | "rel" => Ok(Self::Relative), + _ => anyhow::bail!("Line number can only be `absolute` or `relative`."), + } + } +} + impl Default for Config { fn default() -> Self { Self { -- cgit v1.2.3-70-g09d2 From 7001665342ade12823fba4f358a7e8efc2245a2b Mon Sep 17 00:00:00 2001 From: Stuart Hinson Date: Sun, 26 Dec 2021 23:07:09 -0500 Subject: Add ruby indents (#1372) * Add ruby indents * Include ruby in generated docs--- book/src/generated/lang-support.md | 2 +- runtime/queries/ruby/indents.toml | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 runtime/queries/ruby/indents.toml (limited to 'book/src/generated') diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 9c42005b..28094484 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -34,7 +34,7 @@ | protobuf | ✓ | | ✓ | | | python | ✓ | ✓ | ✓ | `pylsp` | | racket | | | | `racket` | -| ruby | ✓ | | | `solargraph` | +| ruby | ✓ | | ✓ | `solargraph` | | rust | ✓ | ✓ | ✓ | `rust-analyzer` | | scala | ✓ | | ✓ | `metals` | | svelte | ✓ | | ✓ | `svelteserver` | diff --git a/runtime/queries/ruby/indents.toml b/runtime/queries/ruby/indents.toml new file mode 100644 index 00000000..b417751f --- /dev/null +++ b/runtime/queries/ruby/indents.toml @@ -0,0 +1,25 @@ +indent = [ + "argument_list", + "array", + "begin", + "block", + "call", + "class", + "case", + "do_block", + "elsif", + "if", + "hash", + "method", + "module", + "singleton_class", + "singleton_method", +] + +outdent = [ + ")", + "}", + "]", + "end", + "when", +] -- cgit v1.2.3-70-g09d2 From a4641a8613bcbe4ad01d28d3d2a6f4509fef96a9 Mon Sep 17 00:00:00 2001 From: Matouš Dzivjak Date: Mon, 27 Dec 2021 05:11:06 +0100 Subject: feat(commands): sort command (#1288) * feat(commands): sort/rsort command Add basic implementation of sort command. * Sort by selections instead, implement reverse sort * Generate docs * Rename sort! to rsort--- book/src/generated/typable-cmd.md | 2 ++ helix-term/src/commands.rs | 66 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 1 deletion(-) (limited to 'book/src/generated') diff --git a/book/src/generated/typable-cmd.md b/book/src/generated/typable-cmd.md index f12082bb..45129cc1 100644 --- a/book/src/generated/typable-cmd.md +++ b/book/src/generated/typable-cmd.md @@ -42,3 +42,5 @@ | `:tutor` | Open the tutorial. | | `:goto`, `:g` | Go to line number. | | `:set-option`, `:set` | Set a config option at runtime | +| `:sort` | Sort ranges in selection. | +| `:rsort` | Sort ranges in selection in reverse order. | diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 524c50ce..16a2cf35 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2671,6 +2671,56 @@ pub mod cmd { Ok(()) } + fn sort( + cx: &mut compositor::Context, + args: &[Cow], + _event: PromptEvent, + ) -> anyhow::Result<()> { + sort_impl(cx, args, false) + } + + fn sort_reverse( + cx: &mut compositor::Context, + args: &[Cow], + _event: PromptEvent, + ) -> anyhow::Result<()> { + sort_impl(cx, args, true) + } + + fn sort_impl( + cx: &mut compositor::Context, + _args: &[Cow], + reverse: bool, + ) -> anyhow::Result<()> { + let (view, doc) = current!(cx.editor); + let text = doc.text().slice(..); + + let selection = doc.selection(view.id); + + let mut fragments: Vec<_> = selection + .fragments(text) + .map(|fragment| Tendril::from_slice(&fragment)) + .collect(); + + fragments.sort_by(match reverse { + true => |a: &Tendril, b: &Tendril| b.cmp(a), + false => |a: &Tendril, b: &Tendril| a.cmp(b), + }); + + let transaction = Transaction::change( + doc.text(), + selection + .into_iter() + .zip(fragments) + .map(|(s, fragment)| (s.from(), s.to(), Some(fragment))), + ); + + doc.apply(&transaction, view.id); + doc.append_changes_to_history(view.id); + + Ok(()) + } + pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[ TypableCommand { name: "quit", @@ -2965,7 +3015,21 @@ pub mod cmd { doc: "Set a config option at runtime", fun: setting, completer: Some(completers::setting), - } + }, + TypableCommand { + name: "sort", + aliases: &[], + doc: "Sort ranges in selection.", + fun: sort, + completer: None, + }, + TypableCommand { + name: "rsort", + aliases: &[], + doc: "Sort ranges in selection in reverse order.", + fun: sort_reverse, + completer: None, + }, ]; pub static TYPABLE_COMMAND_MAP: Lazy> = -- cgit v1.2.3-70-g09d2 From 8c29b76bccc51c19c90f7c9ee156fe2cb6f52e2c Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Wed, 29 Dec 2021 10:30:44 +0100 Subject: Improve llvm highlighting and queries (#1388) * Improve llvm highlighting and queries The llvm tree-sitter parser was updated to support scopes and more accurate highlighting. * Group highlight expressions better--- book/src/generated/lang-support.md | 2 +- helix-syntax/languages/tree-sitter-llvm | 2 +- runtime/queries/llvm/highlights.scm | 162 ++++++++++++++++++++++++++++++-- runtime/queries/llvm/indents.toml | 8 ++ runtime/queries/llvm/locals.scm | 14 +++ runtime/queries/llvm/textobjects.scm | 16 ++++ 6 files changed, 193 insertions(+), 11 deletions(-) create mode 100644 runtime/queries/llvm/indents.toml create mode 100644 runtime/queries/llvm/locals.scm create mode 100644 runtime/queries/llvm/textobjects.scm (limited to 'book/src/generated') diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 28094484..5d172751 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -21,7 +21,7 @@ | julia | ✓ | | | `julia` | | latex | ✓ | | | | | ledger | ✓ | | | | -| llvm | ✓ | | | | +| llvm | ✓ | ✓ | ✓ | | | lua | ✓ | | ✓ | | | markdown | ✓ | | | | | mint | | | | `mint` | diff --git a/helix-syntax/languages/tree-sitter-llvm b/helix-syntax/languages/tree-sitter-llvm index d4f61bed..3b213925 160000 --- a/helix-syntax/languages/tree-sitter-llvm +++ b/helix-syntax/languages/tree-sitter-llvm @@ -1 +1 @@ -Subproject commit d4f61bed8ecb632addcd5e088c4f4cb9c1bf1c5b +Subproject commit 3b213925b9c4f42c1acfe2e10bfbb438d9c6834d diff --git a/runtime/queries/llvm/highlights.scm b/runtime/queries/llvm/highlights.scm index 73afe85e..cb705197 100644 --- a/runtime/queries/llvm/highlights.scm +++ b/runtime/queries/llvm/highlights.scm @@ -1,14 +1,158 @@ (type) @type -(statement) @keyword.operator +(type_keyword) @type.builtin + +(type [ + (local_var) + (global_var) + ] @type) + +(argument) @variable.parameter + +(_ inst_name: _ @keyword.operator) + +[ + "catch" + "filter" +] @keyword.operator + +[ + "to" + "nuw" + "nsw" + "exact" + "unwind" + "from" + "cleanup" + "swifterror" + "volatile" + "inbounds" + "inrange" + (icmp_cond) + (fcmp_cond) + (fast_math) +] @keyword.control + +(_ callee: _ @function) +(function_header name: _ @function) + +[ + "declare" + "define" + (calling_conv) +] @keyword.function + +[ + "target" + "triple" + "datalayout" + "source_filename" + "addrspace" + "blockaddress" + "align" + "syncscope" + "within" + "uselistorder" + "uselistorder_bb" + "module" + "asm" + "sideeffect" + "alignstack" + "inteldialect" + "unwind" + "type" + "global" + "constant" + "externally_initialized" + "alias" + "ifunc" + "section" + "comdat" + "thread_local" + "localdynamic" + "initialexec" + "localexec" + "any" + "exactmatch" + "largest" + "nodeduplicate" + "samesize" + "distinct" + "attributes" + "vscale" + "no_cfi" + (linkage_aux) + (dso_local) + (visibility) + (dll_storage_class) + (unnamed_addr) + (attribute_name) +] @keyword + + +(function_header [ + (linkage) + (calling_conv) + (unnamed_addr) + ] @keyword.function) + +[ + (string) + (cstring) +] @string + (number) @constant.numeric.integer (comment) @comment -(string) @string (label) @label -(keyword) @keyword -"ret" @keyword.control.return -(boolean) @constant.builtin.boolean +(_ inst_name: "ret" @keyword.control.return) (float) @constant.numeric.float -(constant) @constant -(identifier) @variable -(symbol) @punctuation.delimiter -(bracket) @punctuation.bracket + +[ + (local_var) + (global_var) +] @variable + +[ + (struct_value) + (array_value) + (vector_value) +] @constructor + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "<" + ">" + "<{" + "}>" +] @punctuation.bracket + +[ + "," + ":" +] @punctuation.delimiter + +[ + "=" + "|" + "x" + "..." +] @operator + +[ + "true" + "false" +] @constant.builtin.boolean + +[ + "undef" + "poison" + "null" + "none" + "zeroinitializer" +] @constant.builtin + +(ERROR) @error diff --git a/runtime/queries/llvm/indents.toml b/runtime/queries/llvm/indents.toml new file mode 100644 index 00000000..8cd603c8 --- /dev/null +++ b/runtime/queries/llvm/indents.toml @@ -0,0 +1,8 @@ +indent = [ + "function_body", + "instruction", +] + +outdent = [ + "}", +] diff --git a/runtime/queries/llvm/locals.scm b/runtime/queries/llvm/locals.scm new file mode 100644 index 00000000..1946c287 --- /dev/null +++ b/runtime/queries/llvm/locals.scm @@ -0,0 +1,14 @@ +; Scopes + +(function_body) @local.scope + +; Definitions + +(argument + (value (var (local_var) @local.definition))) + +(instruction + (local_var) @local.definition) + +; References +(local_var) @local.reference diff --git a/runtime/queries/llvm/textobjects.scm b/runtime/queries/llvm/textobjects.scm new file mode 100644 index 00000000..3738a3bb --- /dev/null +++ b/runtime/queries/llvm/textobjects.scm @@ -0,0 +1,16 @@ +(define + body: (_) @function.inside) @function.around + +(struct_type + (struct_body) @class.inside) @class.around + +(packed_struct_type + (struct_body) @class.inside) @class.around + +(array_type + (array_vector_body) @class.inside) @class.around + +(vector_type + (array_vector_body) @class.inside) @class.around + +(argument) @parameter.inside -- cgit v1.2.3-70-g09d2 From bcf3808e9763bfe1bbf70f6053f890c80639d7c9 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Wed, 29 Dec 2021 09:31:23 -0600 Subject: Add tree-sitter-git-diff (#1373) * add submodule on tree-sitter-git-diff * add git-diff highlights * inject git-diff into git-commit * update tree-sitter-git-commit with fix for bad diff case * add git-diff to language support docs * include-children in diff injections This ensures that children nodes of $.message are included in the injection, such as $.user or issue/pr numbers. Without this change, diffs containing '#' or '@' characters can trip up the injection and be parsed separately. See https://github.com/helix-editor/helix/pull/1373#issuecomment-1001215629 * set diff language's scope as source.diff--- .gitmodules | 4 ++++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-git-commit | 2 +- helix-syntax/languages/tree-sitter-git-diff | 1 + languages.toml | 9 +++++++++ runtime/queries/git-commit/highlights.scm | 4 ---- runtime/queries/git-commit/injections.scm | 13 ++++--------- runtime/queries/git-diff/highlights.scm | 6 ++++++ 8 files changed, 26 insertions(+), 14 deletions(-) create mode 160000 helix-syntax/languages/tree-sitter-git-diff create mode 100644 runtime/queries/git-diff/highlights.scm (limited to 'book/src/generated') diff --git a/.gitmodules b/.gitmodules index d5bd61c9..422671b4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -174,3 +174,7 @@ path = helix-syntax/languages/tree-sitter-git-commit url = https://github.com/the-mikedavis/tree-sitter-git-commit.git 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 + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 5d172751..91575c62 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -12,6 +12,7 @@ | elixir | ✓ | | | `elixir-ls` | | fish | ✓ | ✓ | ✓ | | | git-commit | ✓ | | | | +| git-diff | ✓ | | | | | glsl | ✓ | | ✓ | | | go | ✓ | ✓ | ✓ | `gopls` | | html | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-git-commit b/helix-syntax/languages/tree-sitter-git-commit index 5cd4776c..066e395e 160000 --- a/helix-syntax/languages/tree-sitter-git-commit +++ b/helix-syntax/languages/tree-sitter-git-commit @@ -1 +1 @@ -Subproject commit 5cd4776c86c82d9d6afdc8c73a47a08057aef618 +Subproject commit 066e395e1107df17183cf3ae4230f1a1406cc972 diff --git a/helix-syntax/languages/tree-sitter-git-diff b/helix-syntax/languages/tree-sitter-git-diff new file mode 160000 index 00000000..c12e6ecb --- /dev/null +++ b/helix-syntax/languages/tree-sitter-git-diff @@ -0,0 +1 @@ +Subproject commit c12e6ecb54485f764250556ffd7ccb18f8e2942b diff --git a/languages.toml b/languages.toml index 616ef234..c3ae9f62 100644 --- a/languages.toml +++ b/languages.toml @@ -481,3 +481,12 @@ roots = [] file-types = ["COMMIT_EDITMSG"] comment-token = "#" indent = { tab-width = 2, unit = " " } + +[[language]] +name = "git-diff" +scope = "source.diff" +roots = [] +file-types = ["diff"] +injection-regex = "diff" +comment-token = "#" +indent = { tab-width = 2, unit = " " } diff --git a/runtime/queries/git-commit/highlights.scm b/runtime/queries/git-commit/highlights.scm index a74bb381..ffcc31ae 100644 --- a/runtime/queries/git-commit/highlights.scm +++ b/runtime/queries/git-commit/highlights.scm @@ -13,7 +13,3 @@ [":" "->"] @punctuation.delimeter (comment) @comment - -; once we have diff injections, @comment should become @none -((comment (scissors)) - (message)+ @comment) diff --git a/runtime/queries/git-commit/injections.scm b/runtime/queries/git-commit/injections.scm index 2837a586..bd96f1de 100644 --- a/runtime/queries/git-commit/injections.scm +++ b/runtime/queries/git-commit/injections.scm @@ -1,12 +1,7 @@ -; once a diff grammar is available, we can inject diff highlighting into the -; trailer after scissors (git commit --verbose) -; see https://github.com/helix-editor/helix/pull/1338#issuecomment-1000013539 -; -; ((comment (scissors)) -; (message) @injection.content -; (#set! injection.language "diff")) - -; --- +((comment (scissors)) + (message) @injection.content + (#set! injection.include-children) + (#set! injection.language "diff")) ; once a rebase grammar is available, we can inject rebase highlighting into ; interactive rebase summary sections like so: diff --git a/runtime/queries/git-diff/highlights.scm b/runtime/queries/git-diff/highlights.scm new file mode 100644 index 00000000..1c1a8829 --- /dev/null +++ b/runtime/queries/git-diff/highlights.scm @@ -0,0 +1,6 @@ +[(addition) (new_file)] @diff.plus +[(deletion) (old_file)] @diff.minus + +(commit) @constant +(location) @attribute +(command) @markup.bold -- cgit v1.2.3-70-g09d2 From 8fda87af2bb0625c502a23ddbd78a7447ada7bcb Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Thu, 30 Dec 2021 16:58:47 -0600 Subject: add tree-sitter-git-rebase (#1402) * add submodule on tree-sitter-rebase, add to languages * add basic highlights query * inject bash in execute statements * update tree-sitter-rebase * tree-sitter-rebase->tree-sitter-git-rebase * get injection working with tree-sitter-git-commit * set scope under source.gitrebase * unset include-children on commit message injections * Revert "unset include-children on commit message injections" This reverts commit 2ecee155ea8e229651920b291062c2ee84b47944. * fix generated language docs * use rebase_command scopes from tree-sitter-git-commit--- .gitmodules | 4 ++++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-git-rebase | 1 + languages.toml | 9 +++++++++ runtime/queries/git-commit/highlights.scm | 1 - runtime/queries/git-commit/injections.scm | 8 +++----- runtime/queries/git-rebase/highlights.scm | 11 +++++++++++ runtime/queries/git-rebase/injections.scm | 4 ++++ 8 files changed, 33 insertions(+), 6 deletions(-) create mode 160000 helix-syntax/languages/tree-sitter-git-rebase create mode 100644 runtime/queries/git-rebase/highlights.scm create mode 100644 runtime/queries/git-rebase/injections.scm (limited to 'book/src/generated') diff --git a/.gitmodules b/.gitmodules index 422671b4..22f70c80 100644 --- a/.gitmodules +++ b/.gitmodules @@ -178,3 +178,7 @@ path = helix-syntax/languages/tree-sitter-git-diff url = https://github.com/the-mikedavis/tree-sitter-git-diff.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-git-rebase"] + path = helix-syntax/languages/tree-sitter-git-rebase + url = https://github.com/the-mikedavis/tree-sitter-git-rebase.git + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 91575c62..09284d46 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -13,6 +13,7 @@ | fish | ✓ | ✓ | ✓ | | | git-commit | ✓ | | | | | git-diff | ✓ | | | | +| git-rebase | ✓ | | | | | glsl | ✓ | | ✓ | | | go | ✓ | ✓ | ✓ | `gopls` | | html | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-git-rebase b/helix-syntax/languages/tree-sitter-git-rebase new file mode 160000 index 00000000..332dc528 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-git-rebase @@ -0,0 +1 @@ +Subproject commit 332dc528f27044bc4427024dbb33e6941fc131f2 diff --git a/languages.toml b/languages.toml index c3ae9f62..3d9bac7b 100644 --- a/languages.toml +++ b/languages.toml @@ -490,3 +490,12 @@ file-types = ["diff"] injection-regex = "diff" comment-token = "#" indent = { tab-width = 2, unit = " " } + +[[language]] +name = "git-rebase" +scope = "source.gitrebase" +roots = [] +file-types = ["git-rebase-todo"] +injection-regex = "git-rebase" +comment-token = "#" +indent = { tab-width = 2, unit = " " } diff --git a/runtime/queries/git-commit/highlights.scm b/runtime/queries/git-commit/highlights.scm index ffcc31ae..0b50d419 100644 --- a/runtime/queries/git-commit/highlights.scm +++ b/runtime/queries/git-commit/highlights.scm @@ -4,7 +4,6 @@ (commit) @constant (item) @markup.link.url (header) @tag -(rebase_command) @markup.raw (change kind: "new file" @diff.plus) (change kind: "deleted" @diff.minus) diff --git a/runtime/queries/git-commit/injections.scm b/runtime/queries/git-commit/injections.scm index bd96f1de..cf0657f7 100644 --- a/runtime/queries/git-commit/injections.scm +++ b/runtime/queries/git-commit/injections.scm @@ -3,8 +3,6 @@ (#set! injection.include-children) (#set! injection.language "diff")) -; once a rebase grammar is available, we can inject rebase highlighting into -; interactive rebase summary sections like so: -; -; ((rebase_command) @injection.content -; (#set! injection.language "git-rebase")) +((rebase_command) @injection.content + (#set! injection.include-children) + (#set! injection.language "git-rebase")) diff --git a/runtime/queries/git-rebase/highlights.scm b/runtime/queries/git-rebase/highlights.scm new file mode 100644 index 00000000..4f007037 --- /dev/null +++ b/runtime/queries/git-rebase/highlights.scm @@ -0,0 +1,11 @@ +(operation operator: ["p" "pick" "r" "reword" "e" "edit" "s" "squash" "m" "merge" "d" "drop" "b" "break" "x" "exec"] @keyword) +(operation operator: ["l" "label" "t" "reset"] @function) +(operation operator: ["f" "fixup"] @function.special) + +(option) @operator +(label) @string.special.symbol +(commit) @constant +"#" @punctuation.delimiter +(comment) @comment + +(ERROR) @error diff --git a/runtime/queries/git-rebase/injections.scm b/runtime/queries/git-rebase/injections.scm new file mode 100644 index 00000000..070129b6 --- /dev/null +++ b/runtime/queries/git-rebase/injections.scm @@ -0,0 +1,4 @@ +((operation + operator: ["x" "exec"] + (command) @injection.content) + (#set! injection.language "bash")) -- cgit v1.2.3-70-g09d2 From 8f2af713408b8b40cf71873bbc0ddc009a7b3da5 Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Mon, 3 Jan 2022 02:57:55 +0100 Subject: Add LLVM TableGen highlighting (#1409) Add a tree-sitter grammar and highlights for TableGen files. TableGen and its grammar are described here: https://llvm.org/docs/TableGen/index.html Co-authored-by: Blaž Hrastnik --- .gitmodules | 4 ++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-tablegen | 1 + languages.toml | 9 +++ runtime/queries/tablegen/highlights.scm | 90 +++++++++++++++++++++++++++++ runtime/queries/tablegen/indents.toml | 7 +++ runtime/queries/tablegen/injections.scm | 2 + runtime/queries/tablegen/textobjects.scm | 7 +++ 8 files changed, 121 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-tablegen create mode 100644 runtime/queries/tablegen/highlights.scm create mode 100644 runtime/queries/tablegen/indents.toml create mode 100644 runtime/queries/tablegen/injections.scm create mode 100644 runtime/queries/tablegen/textobjects.scm (limited to 'book/src/generated') diff --git a/.gitmodules b/.gitmodules index 22f70c80..b617e60c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -178,6 +178,10 @@ path = helix-syntax/languages/tree-sitter-git-diff url = https://github.com/the-mikedavis/tree-sitter-git-diff.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-tablegen"] + path = helix-syntax/languages/tree-sitter-tablegen + url = https://github.com/Flakebi/tree-sitter-tablegen + shallow = true [submodule "helix-syntax/languages/tree-sitter-git-rebase"] path = helix-syntax/languages/tree-sitter-git-rebase url = https://github.com/the-mikedavis/tree-sitter-git-rebase.git diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 09284d46..73712ff2 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -40,6 +40,7 @@ | rust | ✓ | ✓ | ✓ | `rust-analyzer` | | scala | ✓ | | ✓ | `metals` | | svelte | ✓ | | ✓ | `svelteserver` | +| tablegen | ✓ | ✓ | ✓ | | | toml | ✓ | | | | | tsq | ✓ | | | | | tsx | ✓ | | | `typescript-language-server` | diff --git a/helix-syntax/languages/tree-sitter-tablegen b/helix-syntax/languages/tree-sitter-tablegen new file mode 160000 index 00000000..568dd8a9 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-tablegen @@ -0,0 +1 @@ +Subproject commit 568dd8a937347175fd58db83d4c4cdaeb6069bd2 diff --git a/languages.toml b/languages.toml index f088a3aa..7a895a60 100644 --- a/languages.toml +++ b/languages.toml @@ -436,6 +436,15 @@ file-types = ["ll"] comment-token = ";" indent = { tab-width = 2, unit = " " } +[[language]] +name = "tablegen" +scope = "source.tablegen" +roots = [] +file-types = ["td"] +comment-token = "//" +indent = { tab-width = 2, unit = " " } +injection-regex = "tablegen" + [[language]] name = "markdown" scope = "source.md" diff --git a/runtime/queries/tablegen/highlights.scm b/runtime/queries/tablegen/highlights.scm new file mode 100644 index 00000000..8ade5ba9 --- /dev/null +++ b/runtime/queries/tablegen/highlights.scm @@ -0,0 +1,90 @@ +[ + (comment) + (multiline_comment) +] @comment + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "<" + ">" +] @punctuation.bracket + +[ + "," + ";" + "." +] @punctuation.delimiter + +[ + "#" + "-" + "..." + ":" +] @operator + +[ + "=" + "!cond" + (operator_keyword) +] @function + +[ + "true" + "false" +] @constant.builtin.boolean + +[ + "?" +] @constant.builtin + +(var) @variable + +(template_arg (identifier) @variable.parameter) + +(_ argument: (value (identifier) @variable.parameter)) + +(type) @type + +"code" @type.builtin + +(number) @constant.numeric.integer +[ + (string_string) + (code_string) +] @string + +(preprocessor) @keyword.directive + +[ + "class" + "field" + "let" + "defvar" + "def" + "defset" + "defvar" + "assert" +] @keyword + +[ + "let" + "in" + "foreach" + "if" + "then" + "else" +] @keyword.operator + +"include" @keyword.control.import + +[ + "multiclass" + "defm" +] @namespace + +(ERROR) @error diff --git a/runtime/queries/tablegen/indents.toml b/runtime/queries/tablegen/indents.toml new file mode 100644 index 00000000..43532f4d --- /dev/null +++ b/runtime/queries/tablegen/indents.toml @@ -0,0 +1,7 @@ +indent = [ + "statement", +] + +outdent = [ + "}", +] diff --git a/runtime/queries/tablegen/injections.scm b/runtime/queries/tablegen/injections.scm new file mode 100644 index 00000000..0b476f86 --- /dev/null +++ b/runtime/queries/tablegen/injections.scm @@ -0,0 +1,2 @@ +([ (comment) (multiline_comment)] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/tablegen/textobjects.scm b/runtime/queries/tablegen/textobjects.scm new file mode 100644 index 00000000..2cb80268 --- /dev/null +++ b/runtime/queries/tablegen/textobjects.scm @@ -0,0 +1,7 @@ +(class + body: (_) @class.inside) @class.around + +(multiclass + body: (_) @class.inside) @class.around + +(_ argument: _ @parameter.inside) -- cgit v1.2.3-70-g09d2 From ed97ecceb8d1f53bd192deeb38a1bde36a45edc2 Mon Sep 17 00:00:00 2001 From: Omnikar Date: Sun, 2 Jan 2022 21:31:24 -0500 Subject: Add `:cquit!` command and prevent `:cquit` from ignoring unsaved changes (#1414) * Add `:cquit!` command and prevent `:cquit` from ignoring unsaved changes * `cargo xtask docgen`--- book/src/generated/typable-cmd.md | 1 + helix-term/src/commands.rs | 45 ++++++++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 17 deletions(-) (limited to 'book/src/generated') diff --git a/book/src/generated/typable-cmd.md b/book/src/generated/typable-cmd.md index 45129cc1..65b2dc5f 100644 --- a/book/src/generated/typable-cmd.md +++ b/book/src/generated/typable-cmd.md @@ -20,6 +20,7 @@ | `:quit-all`, `:qa` | Close all views. | | `:quit-all!`, `:qa!` | Close all views forcefully (ignoring unsaved changes). | | `:cquit`, `:cq` | Quit with exit code (default 1). Accepts an optional integer exit code (:cq 2). | +| `:cquit!`, `:cq!` | Quit with exit code (default 1) forcefully (ignoring unsaved changes). Accepts an optional integer exit code (:cq! 2). | | `:theme` | Change the editor theme. | | `:clipboard-yank` | Yank main selection into system clipboard. | | `:clipboard-yank-join` | Yank joined selections into system clipboard. A separator can be provided as first argument. Default value is newline. | diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 842d8b60..ccc25c54 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2322,12 +2322,7 @@ pub mod cmd { write_all_impl(cx, args, event, true, true) } - fn quit_all_impl( - editor: &mut Editor, - _args: &[Cow], - _event: PromptEvent, - force: bool, - ) -> anyhow::Result<()> { + fn quit_all_impl(editor: &mut Editor, force: bool) -> anyhow::Result<()> { if !force { buffers_remaining_impl(editor)?; } @@ -2343,18 +2338,18 @@ pub mod cmd { fn quit_all( cx: &mut compositor::Context, - args: &[Cow], - event: PromptEvent, + _args: &[Cow], + _event: PromptEvent, ) -> anyhow::Result<()> { - quit_all_impl(cx.editor, args, event, false) + quit_all_impl(cx.editor, false) } fn force_quit_all( cx: &mut compositor::Context, - args: &[Cow], - event: PromptEvent, + _args: &[Cow], + _event: PromptEvent, ) -> anyhow::Result<()> { - quit_all_impl(cx.editor, args, event, true) + quit_all_impl(cx.editor, true) } fn cquit( @@ -2368,12 +2363,21 @@ pub mod cmd { .unwrap_or(1); cx.editor.exit_code = exit_code; - let views: Vec<_> = cx.editor.tree.views().map(|(view, _)| view.id).collect(); - for view_id in views { - cx.editor.close(view_id); - } + quit_all_impl(cx.editor, false) + } - Ok(()) + fn force_cquit( + cx: &mut compositor::Context, + args: &[Cow], + _event: PromptEvent, + ) -> anyhow::Result<()> { + let exit_code = args + .first() + .and_then(|code| code.parse::().ok()) + .unwrap_or(1); + cx.editor.exit_code = exit_code; + + quit_all_impl(cx.editor, true) } fn theme( @@ -2877,6 +2881,13 @@ pub mod cmd { fun: cquit, completer: None, }, + TypableCommand { + name: "cquit!", + aliases: &["cq!"], + doc: "Quit with exit code (default 1) forcefully (ignoring unsaved changes). Accepts an optional integer exit code (:cq! 2).", + fun: force_cquit, + completer: None, + }, TypableCommand { name: "theme", aliases: &[], -- cgit v1.2.3-70-g09d2 From 641255ccc83648d164bf6e8e8e4e93460591830b Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Tue, 4 Jan 2022 02:52:34 +0100 Subject: Add llvm-mir highlighting (#1398) * Add injection regex for more languages To support embedding them in other languages like markdown. * Add llvm-mir highlighting LLVM Machine IR is dumped as yaml files that can embed LLVM IR and Machine IR. To support this, add a llvm-mir-yaml language that uses the yaml parser, but uses different injections to highlight IR and MIR. * Update submodule with fixed multiline comments Co-authored-by: Blaž Hrastnik --- .gitmodules | 4 + book/src/generated/lang-support.md | 2 + helix-core/src/indent.rs | 1 + helix-core/src/syntax.rs | 13 ++- helix-syntax/languages/tree-sitter-llvm-mir | 1 + languages.toml | 22 +++++ runtime/queries/llvm-mir-yaml/highlights.scm | 1 + runtime/queries/llvm-mir-yaml/indents.toml | 3 + runtime/queries/llvm-mir-yaml/injections.scm | 9 ++ runtime/queries/llvm-mir/highlights.scm | 136 +++++++++++++++++++++++++++ runtime/queries/llvm-mir/indents.toml | 7 ++ runtime/queries/llvm-mir/injections.scm | 2 + runtime/queries/llvm-mir/textobjects.scm | 3 + runtime/queries/yaml/injections.scm | 2 + 14 files changed, 203 insertions(+), 3 deletions(-) create mode 160000 helix-syntax/languages/tree-sitter-llvm-mir create mode 100644 runtime/queries/llvm-mir-yaml/highlights.scm create mode 100644 runtime/queries/llvm-mir-yaml/indents.toml create mode 100644 runtime/queries/llvm-mir-yaml/injections.scm create mode 100644 runtime/queries/llvm-mir/highlights.scm create mode 100644 runtime/queries/llvm-mir/indents.toml create mode 100644 runtime/queries/llvm-mir/injections.scm create mode 100644 runtime/queries/llvm-mir/textobjects.scm create mode 100644 runtime/queries/yaml/injections.scm (limited to 'book/src/generated') diff --git a/.gitmodules b/.gitmodules index b617e60c..9297708a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -174,6 +174,10 @@ path = helix-syntax/languages/tree-sitter-git-commit url = https://github.com/the-mikedavis/tree-sitter-git-commit.git shallow = true +[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 [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 diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 73712ff2..ee719b56 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -24,6 +24,8 @@ | latex | ✓ | | | | | ledger | ✓ | | | | | llvm | ✓ | ✓ | ✓ | | +| llvm-mir | ✓ | ✓ | ✓ | | +| llvm-mir-yaml | ✓ | | ✓ | | | lua | ✓ | | ✓ | | | markdown | ✓ | | | | | mint | | | | `mint` | diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs index 28066aa6..1fc2b8a5 100644 --- a/helix-core/src/indent.rs +++ b/helix-core/src/indent.rs @@ -436,6 +436,7 @@ where comment_token: None, auto_format: false, diagnostic_severity: Severity::Warning, + tree_sitter_library: None, language_server: None, indent: Some(IndentationConfiguration { tab_width: 4, diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index cdae0210..5d37c219 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -67,6 +67,8 @@ pub struct LanguageConfiguration { #[serde(default)] pub diagnostic_severity: Severity, + pub tree_sitter_library: Option, // tree-sitter library name, defaults to language_id + // content_regex #[serde(default, skip_serializing, deserialize_with = "deserialize_regex")] pub injection_regex: Option, @@ -192,9 +194,14 @@ impl LanguageConfiguration { if highlights_query.is_empty() { None } else { - let language = get_language(&crate::RUNTIME_DIR, &self.language_id) - .map_err(|e| log::info!("{}", e)) - .ok()?; + let language = get_language( + &crate::RUNTIME_DIR, + self.tree_sitter_library + .as_deref() + .unwrap_or(&self.language_id), + ) + .map_err(|e| log::info!("{}", e)) + .ok()?; let config = HighlightConfiguration::new( language, &highlights_query, diff --git a/helix-syntax/languages/tree-sitter-llvm-mir b/helix-syntax/languages/tree-sitter-llvm-mir new file mode 160000 index 00000000..06fabca1 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-llvm-mir @@ -0,0 +1 @@ +Subproject commit 06fabca19454b2dc00c1b211a7cb7ad0bc2585f1 diff --git a/languages.toml b/languages.toml index 7a895a60..e8329fe7 100644 --- a/languages.toml +++ b/languages.toml @@ -334,6 +334,7 @@ file-types = ["yml", "yaml"] roots = [] comment-token = "#" indent = { tab-width = 2, unit = " " } +injection-regex = "yml|yaml" # [[language]] # name = "haskell" @@ -386,6 +387,7 @@ roots = [] comment-token = "#" indent = { tab-width = 2, unit = " " } language-server = { command = "cmake-language-server" } +injection-regex = "cmake" [[language]] name = "glsl" @@ -394,6 +396,7 @@ file-types = ["glsl", "vert", "tesc", "tese", "geom", "frag", "comp" ] roots = [] comment-token = "//" indent = { tab-width = 4, unit = " " } +injection-regex = "glsl" [[language]] name = "perl" @@ -435,6 +438,25 @@ roots = [] file-types = ["ll"] comment-token = ";" indent = { tab-width = 2, unit = " " } +injection-regex = "llvm" + +[[language]] +name = "llvm-mir" +scope = "source.llvm_mir" +roots = [] +file-types = [] +comment-token = ";" +indent = { tab-width = 2, unit = " " } +injection-regex = "mir" + +[[language]] +name = "llvm-mir-yaml" +tree-sitter-library = "yaml" +scope = "source.yaml" +roots = [] +file-types = ["mir"] +comment-token = "#" +indent = { tab-width = 2, unit = " " } [[language]] name = "tablegen" diff --git a/runtime/queries/llvm-mir-yaml/highlights.scm b/runtime/queries/llvm-mir-yaml/highlights.scm new file mode 100644 index 00000000..4ba254e8 --- /dev/null +++ b/runtime/queries/llvm-mir-yaml/highlights.scm @@ -0,0 +1 @@ +; inherits: yaml diff --git a/runtime/queries/llvm-mir-yaml/indents.toml b/runtime/queries/llvm-mir-yaml/indents.toml new file mode 100644 index 00000000..ddc3578b --- /dev/null +++ b/runtime/queries/llvm-mir-yaml/indents.toml @@ -0,0 +1,3 @@ +indent = [ + "block_mapping_pair", +] diff --git a/runtime/queries/llvm-mir-yaml/injections.scm b/runtime/queries/llvm-mir-yaml/injections.scm new file mode 100644 index 00000000..b3243022 --- /dev/null +++ b/runtime/queries/llvm-mir-yaml/injections.scm @@ -0,0 +1,9 @@ +; inherits: yaml + +((document (block_node (block_scalar) @injection.content)) + (#set! injection.language "llvm")) + +((document (block_node (block_mapping (block_mapping_pair + key: (flow_node (plain_scalar (string_scalar))) ; "body" + value: (block_node (block_scalar) @injection.content))))) + (#set! injection.language "mir")) diff --git a/runtime/queries/llvm-mir/highlights.scm b/runtime/queries/llvm-mir/highlights.scm new file mode 100644 index 00000000..79234612 --- /dev/null +++ b/runtime/queries/llvm-mir/highlights.scm @@ -0,0 +1,136 @@ +[ + (label) + (bb_ref) +] @label + +[ + (comment) + (multiline_comment) +] @comment + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "<" + ">" +] @punctuation.bracket + +[ + "," + ":" + "|" + "*" +] @punctuation.delimiter + +[ + "=" + "x" +] @operator + +[ + "true" + "false" +] @constant.builtin.boolean + +[ + "null" + "_" + "unknown-address" +] @constant.builtin + +[ + (stack_object) + (constant_pool_index) + (jump_table_index) + (var) + (physical_register) + (ir_block) + (external_symbol) + (global_var) + (ir_local_var) + (metadata_ref) + (mnemonic) +] @variable + +(low_level_type) @type + +[ + (immediate_type) + (primitive_type) +] @type.builtin + +(number) @constant.numeric.integer +(float) @constant.numeric.float +(string) @string + +(instruction name: _ @keyword.operator) + +[ + "successors" + "liveins" + "pre-instr-symbol" + "post-instr-symbol" + "heap-alloc-marker" + "debug-instr-number" + "debug-location" + "mcsymbol" + "tied-def" + "target-flags" + "CustomRegMask" + "same_value" + "def_cfa_register" + "restore" + "undefined" + "offset" + "rel_offset" + "def_cfa" + "llvm_def_aspace_cfa" + "register" + "escape" + "remember_state" + "restore_state" + "window_save" + "negate_ra_sign_state" + "intpred" + "floatpred" + "shufflemask" + "liveout" + "target-index" + "blockaddress" + "intrinsic" + "load" + "store" + "unknown-size" + "on" + "from" + "into" + "align" + "basealign" + "addrspace" + "call-entry" + "custom" + "constant-pool" + "stack" + "got" + "jump-table" + "syncscope" + "address-taken" + "landing-pad" + "inlineasm-br-indirect-target" + "ehfunclet-entry" + "bbsections" + + (intpred) + (floatpred) + (memory_operand_flag) + (atomic_ordering) + (register_flag) + (instruction_flag) + (float_keyword) +] @keyword + +(ERROR) @error diff --git a/runtime/queries/llvm-mir/indents.toml b/runtime/queries/llvm-mir/indents.toml new file mode 100644 index 00000000..6a70e5ad --- /dev/null +++ b/runtime/queries/llvm-mir/indents.toml @@ -0,0 +1,7 @@ +indent = [ + "basic_block", +] + +outdent = [ + "label", +] diff --git a/runtime/queries/llvm-mir/injections.scm b/runtime/queries/llvm-mir/injections.scm new file mode 100644 index 00000000..0b476f86 --- /dev/null +++ b/runtime/queries/llvm-mir/injections.scm @@ -0,0 +1,2 @@ +([ (comment) (multiline_comment)] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/llvm-mir/textobjects.scm b/runtime/queries/llvm-mir/textobjects.scm new file mode 100644 index 00000000..73f6f772 --- /dev/null +++ b/runtime/queries/llvm-mir/textobjects.scm @@ -0,0 +1,3 @@ +(basic_block) @function.around + +(argument) @parameter.inside diff --git a/runtime/queries/yaml/injections.scm b/runtime/queries/yaml/injections.scm new file mode 100644 index 00000000..39bda293 --- /dev/null +++ b/runtime/queries/yaml/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) -- cgit v1.2.3-70-g09d2 From 5b1a628e81b7d2f198ef401d442ca7967c5a0135 Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Tue, 4 Jan 2022 02:53:04 +0100 Subject: Add textobjects and indents to c and cpp (#1293) Indentation of single line statements doesn't work, i.e. for (;;) leads to for(;;) Only blocks with curly braces are indented.--- book/src/generated/lang-support.md | 4 ++-- runtime/queries/c/indents.toml | 16 ++++++++++++++++ runtime/queries/c/textobjects.scm | 13 +++++++++++++ runtime/queries/cpp/indents.toml | 17 +++++++++++++++++ runtime/queries/cpp/textobjects.scm | 7 +++++++ 5 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 runtime/queries/c/indents.toml create mode 100644 runtime/queries/c/textobjects.scm create mode 100644 runtime/queries/cpp/indents.toml create mode 100644 runtime/queries/cpp/textobjects.scm (limited to 'book/src/generated') diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index ee719b56..a1fbf172 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -1,11 +1,11 @@ | Language | Syntax Highlighting | Treesitter Textobjects | Auto Indent | Default LSP | | --- | --- | --- | --- | --- | | bash | ✓ | | | `bash-language-server` | -| c | ✓ | | | `clangd` | +| c | ✓ | ✓ | ✓ | `clangd` | | c-sharp | ✓ | | | | | cmake | ✓ | ✓ | ✓ | `cmake-language-server` | | comment | ✓ | | | | -| cpp | ✓ | | | `clangd` | +| cpp | ✓ | ✓ | ✓ | `clangd` | | css | ✓ | | | | | dart | ✓ | | ✓ | `dart` | | dockerfile | ✓ | | | `docker-langserver` | diff --git a/runtime/queries/c/indents.toml b/runtime/queries/c/indents.toml new file mode 100644 index 00000000..f4076e17 --- /dev/null +++ b/runtime/queries/c/indents.toml @@ -0,0 +1,16 @@ +indent = [ + "compound_statement", + "field_declaration_list", + "enumerator_list", + "parameter_list", + "init_declarator", + "case_statement", + "condition_clause", + "expression_statement", +] + +outdent = [ + "case", + "}", + "]", +] diff --git a/runtime/queries/c/textobjects.scm b/runtime/queries/c/textobjects.scm new file mode 100644 index 00000000..b0f03668 --- /dev/null +++ b/runtime/queries/c/textobjects.scm @@ -0,0 +1,13 @@ +(function_definition + body: (_) @function.inside) @function.around + +(struct_specifier + body: (_) @class.inside) @class.around + +(enum_specifier + body: (_) @class.inside) @class.around + +(union_specifier + body: (_) @class.inside) @class.around + +(parameter_declaration) @parameter.inside diff --git a/runtime/queries/cpp/indents.toml b/runtime/queries/cpp/indents.toml new file mode 100644 index 00000000..0ca2ed8b --- /dev/null +++ b/runtime/queries/cpp/indents.toml @@ -0,0 +1,17 @@ +indent = [ + "compound_statement", + "field_declaration_list", + "enumerator_list", + "parameter_list", + "init_declarator", + "case_statement", + "condition_clause", + "expression_statement", +] + +outdent = [ + "case", + "access_specifier", + "}", + "]", +] diff --git a/runtime/queries/cpp/textobjects.scm b/runtime/queries/cpp/textobjects.scm new file mode 100644 index 00000000..6e3de1a2 --- /dev/null +++ b/runtime/queries/cpp/textobjects.scm @@ -0,0 +1,7 @@ +; inherits: c + +(lambda_expression + body: (_) @function.inside) @function.around + +(class_specifier + body: (_) @class.inside) @class.around -- cgit v1.2.3-70-g09d2