on master help sign in
languages: added elvish (#2948)
commit4c30a3609aa8fbcca97609d281f5df449c234674 authorrsteube <rsteube@users.noreply.github.com> dateSun 3 Jul 2022, 23:19 (4 years ago) parent9f43dbc
4 files changed+93
book/src/generated/lang-support.md+1 languages.toml+14 runtime/queries/elvish/highlights.scm+76 runtime/queries/elvish/injections.scm+2
book/src/generated/lang-support.md+1
@@ -18,6 +18,7 @@
1818| ejs | ✓ | | | |
1919| elixir | ✓ | ✓ | | `elixir-ls` |
2020| elm | ✓ | | | `elm-language-server` |
21+| elvish | ✓ | | | `elvish` |
2122| erb | ✓ | | | |
2223| erlang | ✓ | ✓ | | `erlang_ls` |
2324| fish | ✓ | ✓ | ✓ | |
languages.toml+14
@@ -1489,3 +1489,17 @@ roots = []
14891489comment-token = "#"
14901490indent = { tab-width = 4, unit = " " }
14911491grammar = "python"
1492+
1493+[[language]]
1494+name = "elvish"
1495+scope = "source.elvish"
1496+file-types = ["elv"]
1497+roots = []
1498+comment-token = "#"
1499+indent = { tab-width = 2, unit = " " }
1500+language-server = { command = "elvish", args = ["-lsp"] }
1501+grammar = "elvish"
1502+
1503+[[grammar]]
1504+name = "elvish"
1505+source = { git = "https://github.com/ckafi/tree-sitter-elvish", rev = "e50787cadd3bc54f6d9c0704493a79078bb8a4e5" }
runtime/queries/elvish/highlights.scmnew file+76
@@ -0,0 +1,76 @@
1+;; SPDX-License-Identifier: 0BSD
2+;; SPDX-FileCopyrightText: 2022 Tobias Frilling
3+
4+(comment) @comment
5+
6+(if "if" @keyword.control.conditional)
7+(if (elif "elif" @keyword.control.conditional))
8+(if (else "else" @keyword.control.conditional))
9+
10+(while "while" @keyword.control.repeat)
11+(while (else "else" @keyword.control.repeat))
12+(for "for" @keyword.control.repeat)
13+(for (else "else" @keyword.control.repeat))
14+
15+(try "try" @keyword.control.exception)
16+(try (catch "catch" @keyword.control.exception))
17+(try (else "else" @keyword.control.exception))
18+(try (finally "finally" @keyword.control.exception))
19+
20+(import "use" @keyword.control.import)
21+(import (bareword) @string.special)
22+
23+(wildcard ["*" "**" "?"] @string.special)
24+
25+(command argument: (bareword) @variable.parameter)
26+(command head: (identifier) @function)
27+((command head: (identifier) @keyword.control.return)
28+ (#eq? @keyword.control.return "return"))
29+((command (identifier) @keyword.operator)
30+ (#match? @keyword.operator "(and|or|coalesce)"))
31+((command head: _ @function)
32+ (#match? @function "([+]|[-]|[*]|[/]|[%]|[<]|[<][=]|[=][=]|[!][=]|[>]|[>][=]|[<][s]|[<][=][s]|[=][=][s]|[!][=][s]|[>][s]|[>][=][s])"))
33+
34+(pipeline "|" @operator)
35+(redirection [">" "<" ">>" "<>"] @operator)
36+
37+(io_port) @constant.numeric
38+
39+(function_definition
40+ "fn" @keyword.function
41+ (identifier) @function)
42+
43+(parameter_list) @variable.parameter
44+(parameter_list "|" @punctuation.bracket)
45+
46+(variable_declaration
47+ "var" @keyword
48+ (lhs (identifier) @variable))
49+
50+(variable_assignment
51+ "set" @keyword
52+ (lhs (identifier) @variable))
53+
54+(temporary_assignment
55+ "tmp" @keyword
56+ (lhs (identifier) @variable))
57+
58+(variable_deletion
59+ "del" @keyword
60+ (identifier) @variable)
61+
62+
63+(number) @constant.numeric
64+(string) @string
65+
66+((variable (identifier) @function)
67+ (#match? @function ".+\\~$"))
68+((variable (identifier) @constant.builtin.boolean)
69+ (#match? @constant.builtin.boolean "(true|false)"))
70+((variable (identifier) @constant.builtin)
71+ (#match? @constant.builtin "(_|after-chdir|args|before-chdir|buildinfo|nil|notify-bg-job-success|num-bg-jobs|ok|paths|pid|pwd|value-out-indicator|version)"))
72+(variable (identifier) @variable)
73+
74+["$" "@"] @punctuation.special
75+["(" ")" "[" "]" "{" "}"] @punctuation.bracket
76+";" @punctuation.delimiter
runtime/queries/elvish/injections.scmnew file+2
@@ -0,0 +1,2 @@
1+((comment) @injection.content
2+ (#set! injection.language "comment"))