Skip to content

Commit

Permalink
languages: added elvish (#2948)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube authored Jul 3, 2022
1 parent 9f43dbc commit 4c30a36
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 0 deletions.
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
| ejs || | | |
| elixir ||| | `elixir-ls` |
| elm || | | `elm-language-server` |
| elvish || | | `elvish` |
| erb || | | |
| erlang ||| | `erlang_ls` |
| fish |||| |
Expand Down
14 changes: 14 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1489,3 +1489,17 @@ roots = []
comment-token = "#"
indent = { tab-width = 4, unit = " " }
grammar = "python"

[[language]]
name = "elvish"
scope = "source.elvish"
file-types = ["elv"]
roots = []
comment-token = "#"
indent = { tab-width = 2, unit = " " }
language-server = { command = "elvish", args = ["-lsp"] }
grammar = "elvish"

[[grammar]]
name = "elvish"
source = { git = "https://github.com/ckafi/tree-sitter-elvish", rev = "e50787cadd3bc54f6d9c0704493a79078bb8a4e5" }
76 changes: 76 additions & 0 deletions runtime/queries/elvish/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
;; SPDX-License-Identifier: 0BSD
;; SPDX-FileCopyrightText: 2022 Tobias Frilling

(comment) @comment

(if "if" @keyword.control.conditional)
(if (elif "elif" @keyword.control.conditional))
(if (else "else" @keyword.control.conditional))

(while "while" @keyword.control.repeat)
(while (else "else" @keyword.control.repeat))
(for "for" @keyword.control.repeat)
(for (else "else" @keyword.control.repeat))

(try "try" @keyword.control.exception)
(try (catch "catch" @keyword.control.exception))
(try (else "else" @keyword.control.exception))
(try (finally "finally" @keyword.control.exception))

(import "use" @keyword.control.import)
(import (bareword) @string.special)

(wildcard ["*" "**" "?"] @string.special)

(command argument: (bareword) @variable.parameter)
(command head: (identifier) @function)
((command head: (identifier) @keyword.control.return)
(#eq? @keyword.control.return "return"))
((command (identifier) @keyword.operator)
(#match? @keyword.operator "(and|or|coalesce)"))
((command head: _ @function)
(#match? @function "([+]|[-]|[*]|[/]|[%]|[<]|[<][=]|[=][=]|[!][=]|[>]|[>][=]|[<][s]|[<][=][s]|[=][=][s]|[!][=][s]|[>][s]|[>][=][s])"))

(pipeline "|" @operator)
(redirection [">" "<" ">>" "<>"] @operator)

(io_port) @constant.numeric

(function_definition
"fn" @keyword.function
(identifier) @function)

(parameter_list) @variable.parameter
(parameter_list "|" @punctuation.bracket)

(variable_declaration
"var" @keyword
(lhs (identifier) @variable))

(variable_assignment
"set" @keyword
(lhs (identifier) @variable))

(temporary_assignment
"tmp" @keyword
(lhs (identifier) @variable))

(variable_deletion
"del" @keyword
(identifier) @variable)


(number) @constant.numeric
(string) @string

((variable (identifier) @function)
(#match? @function ".+\\~$"))
((variable (identifier) @constant.builtin.boolean)
(#match? @constant.builtin.boolean "(true|false)"))
((variable (identifier) @constant.builtin)
(#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)"))
(variable (identifier) @variable)

["$" "@"] @punctuation.special
["(" ")" "[" "]" "{" "}"] @punctuation.bracket
";" @punctuation.delimiter
2 changes: 2 additions & 0 deletions runtime/queries/elvish/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
((comment) @injection.content
(#set! injection.language "comment"))

0 comments on commit 4c30a36

Please sign in to comment.