aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGaƫtan Lehmann <glehmann@users.noreply.github.com>2024-04-11 23:06:52 +0200
committerGitHub <noreply@github.com>2024-04-11 23:06:52 +0200
commit6ae470fd8fdab6ea391ae1999bcaee0529408a50 (patch)
tree67f48e9af72d46683f444b802258c0ac9f0efa1b
parentfix(textproto): use 'pbtxt' filetype (#6427) (diff)
downloadnvim-treesitter-6ae470fd8fdab6ea391ae1999bcaee0529408a50.tar
nvim-treesitter-6ae470fd8fdab6ea391ae1999bcaee0529408a50.tar.gz
nvim-treesitter-6ae470fd8fdab6ea391ae1999bcaee0529408a50.tar.bz2
nvim-treesitter-6ae470fd8fdab6ea391ae1999bcaee0529408a50.tar.lz
nvim-treesitter-6ae470fd8fdab6ea391ae1999bcaee0529408a50.tar.xz
nvim-treesitter-6ae470fd8fdab6ea391ae1999bcaee0529408a50.tar.zst
nvim-treesitter-6ae470fd8fdab6ea391ae1999bcaee0529408a50.zip
feat: add earthfile parser (#6395)
--------- Co-authored-by: ObserverOfTime <chronobserver@disroot.org>
-rw-r--r--lockfile.json3
-rw-r--r--lua/nvim-treesitter/parsers.lua8
-rw-r--r--queries/earthfile/highlights.scm129
-rw-r--r--queries/earthfile/injections.scm9
4 files changed, 149 insertions, 0 deletions
diff --git a/lockfile.json b/lockfile.json
index 34cb87b21..536f1a36e 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -131,6 +131,9 @@
"dtd": {
"revision": "2282ad5cb8e815523e70d5c82404620bd9a1494c"
},
+ "earthfile": {
+ "revision": "2a6ab191f5f962562e495a818aa4e7f45f8a556a"
+ },
"ebnf": {
"revision": "8e635b0b723c620774dfb8abf382a7f531894b40"
},
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 255efe570..39c3b1875 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -443,6 +443,14 @@ list.dtd = {
maintainers = { "@ObserverOfTime" },
}
+list.earthfile = {
+ install_info = {
+ url = "https://github.com/glehmann/tree-sitter-earthfile",
+ files = { "src/parser.c", "src/scanner.c" },
+ },
+ maintainers = { "@glehmann" },
+}
+
list.ebnf = {
install_info = {
url = "https://github.com/RubixDev/ebnf",
diff --git a/queries/earthfile/highlights.scm b/queries/earthfile/highlights.scm
new file mode 100644
index 000000000..cc7dce298
--- /dev/null
+++ b/queries/earthfile/highlights.scm
@@ -0,0 +1,129 @@
+(string_array
+ "," @punctuation.delimiter)
+
+(string_array
+ [
+ "["
+ "]"
+ ] @punctuation.bracket)
+
+[
+ "ARG"
+ "AS LOCAL"
+ "BUILD"
+ "CACHE"
+ "CMD"
+ "COPY"
+ "DO"
+ "ENTRYPOINT"
+ "ENV"
+ "EXPOSE"
+ "FROM DOCKERFILE"
+ "FROM"
+ "FUNCTION"
+ "GIT CLONE"
+ "HOST"
+ "IMPORT"
+ "LABEL"
+ "LET"
+ "PROJECT"
+ "RUN"
+ "SAVE ARTIFACT"
+ "SAVE IMAGE"
+ "SET"
+ "USER"
+ "VERSION"
+ "VOLUME"
+ "WORKDIR"
+] @keyword
+
+(for_command
+ [
+ "FOR"
+ "IN"
+ "END"
+ ] @keyword.repeat)
+
+(if_command
+ [
+ "IF"
+ "END"
+ ] @keyword.conditional)
+
+(elif_block
+ "ELSE IF" @keyword.conditional)
+
+(else_block
+ "ELSE" @keyword.conditional)
+
+(import_command
+ [
+ "IMPORT"
+ "AS"
+ ] @keyword.import)
+
+(try_command
+ [
+ "TRY"
+ "FINALLY"
+ "END"
+ ] @keyword.exception)
+
+(wait_command
+ [
+ "WAIT"
+ "END"
+ ] @keyword)
+
+(with_docker_command
+ [
+ "WITH DOCKER"
+ "END"
+ ] @keyword)
+
+[
+ (comment)
+ (line_continuation_comment)
+] @comment @spell
+
+[
+ (target_ref)
+ (target_artifact)
+ (function_ref)
+] @function
+
+(target
+ (identifier) @function)
+
+[
+ (double_quoted_string)
+ (single_quoted_string)
+] @string
+
+(unquoted_string) @string.special
+
+(escape_sequence) @string.escape
+
+(variable) @variable
+
+(expansion
+ [
+ "$"
+ "{"
+ "}"
+ "("
+ ")"
+ ] @punctuation.special)
+
+(build_arg
+ [
+ "--"
+ (variable)
+ ] @variable.parameter)
+
+(options
+ (_) @property)
+
+"=" @operator
+
+(line_continuation) @operator
diff --git a/queries/earthfile/injections.scm b/queries/earthfile/injections.scm
new file mode 100644
index 000000000..7435a400e
--- /dev/null
+++ b/queries/earthfile/injections.scm
@@ -0,0 +1,9 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))
+
+((line_continuation_comment) @injection.content
+ (#set! injection.language "comment"))
+
+((shell_fragment) @injection.content
+ (#set! injection.language "bash")
+ (#set! injection.include-children))