From 5db6568dcedd3ced7aa33d730f0f6a00d72e2ebc Mon Sep 17 00:00:00 2001 From: Arthur Deierlein Date: Sat, 16 Mar 2024 20:43:30 +0100 Subject: [PATCH 1/3] feat: add hyprland config language --- book/src/generated/lang-support.md | 1 + languages.toml | 12 ++++++ runtime/queries/hyprlang/highlights.scm | 56 +++++++++++++++++++++++++ runtime/queries/hyprlang/indents.scm | 6 +++ runtime/queries/hyprlang/injections.scm | 3 ++ 5 files changed, 78 insertions(+) create mode 100644 runtime/queries/hyprlang/highlights.scm create mode 100644 runtime/queries/hyprlang/indents.scm create mode 100644 runtime/queries/hyprlang/injections.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 7792bf594181..2cb1e926ce31 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -77,6 +77,7 @@ | hosts | ✓ | | | | | html | ✓ | | | `vscode-html-language-server` | | hurl | ✓ | | ✓ | | +| hyprlang | ✓ | | ✓ | | | idris | | | | `idris2-lsp` | | iex | ✓ | | | | | ini | ✓ | | | | diff --git a/languages.toml b/languages.toml index 8fbb98e883d1..b01da144d52f 100644 --- a/languages.toml +++ b/languages.toml @@ -3284,3 +3284,15 @@ indent = { tab-width = 2, unit = " " } [[grammar]] name = "ld" source = { git = "https://github.com/mtoohey31/tree-sitter-ld", rev = "81978cde3844bfc199851e39c80a20ec6444d35e" } + +[[language]] +name = "hyprlang" +scope = "source.hyprlang" +roots = ["hyprland.conf"] +file-types = [ { glob = "hyprland.conf"} ] +comment-token = "#" +grammar = "hyprlang" + +[[grammar]] +name = "hyprlang" +source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-hyprlang", rev = "27af9b74acf89fa6bed4fb8cb8631994fcb2e6f3"} diff --git a/runtime/queries/hyprlang/highlights.scm b/runtime/queries/hyprlang/highlights.scm new file mode 100644 index 000000000000..d76993d12511 --- /dev/null +++ b/runtime/queries/hyprlang/highlights.scm @@ -0,0 +1,56 @@ +(comment) @comment @spell + +[ + "source" + "exec" + "exec-once" +] @keyword + +(keyword + (name) @keyword) + +(assignment + (name) @property) + +(section + (name) @module) + +(section + device: (device_name) @type) + +(variable) @variable + +"$" @punctuation.special + +(boolean) @boolean + +(mod) @constant + +[ + "rgb" + "rgba" +] @function.builtin + +[ + (number) + (legacy_hex) + (angle) + (hex) +] @number + +"deg" @type + +"," @punctuation.delimiter + +[ + "(" + ")" + "{" + "}" +] @punctuation.bracket + +[ + "=" + "-" + "+" +] @operator diff --git a/runtime/queries/hyprlang/indents.scm b/runtime/queries/hyprlang/indents.scm new file mode 100644 index 000000000000..731ae9a611eb --- /dev/null +++ b/runtime/queries/hyprlang/indents.scm @@ -0,0 +1,6 @@ +(section) @indent.begin + +(section + "}" @indent.end) + +"}" @indent.branch diff --git a/runtime/queries/hyprlang/injections.scm b/runtime/queries/hyprlang/injections.scm new file mode 100644 index 000000000000..1f0199ed807d --- /dev/null +++ b/runtime/queries/hyprlang/injections.scm @@ -0,0 +1,3 @@ +(exec + (string) @injection.content + (#set! injection.language "bash")) From 8d799a1e9da0c58ecd97a0a796534489fd17e2a9 Mon Sep 17 00:00:00 2001 From: Arthur Deierlein Date: Sun, 17 Mar 2024 17:13:31 +0100 Subject: [PATCH 2/3] adjust indents to helix --- runtime/queries/hyprlang/indents.scm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/queries/hyprlang/indents.scm b/runtime/queries/hyprlang/indents.scm index 731ae9a611eb..88bfe7434276 100644 --- a/runtime/queries/hyprlang/indents.scm +++ b/runtime/queries/hyprlang/indents.scm @@ -1,6 +1,6 @@ -(section) @indent.begin +(section) @indent (section - "}" @indent.end) + "}" @outdent) -"}" @indent.branch +"}" @extend From 949ca1bd810cd17b78875d180f65503b39f1c68b Mon Sep 17 00:00:00 2001 From: Arthur Deierlein Date: Sun, 17 Mar 2024 17:32:31 +0100 Subject: [PATCH 3/3] adjust highlights to helix --- runtime/queries/hyprlang/highlights.scm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/runtime/queries/hyprlang/highlights.scm b/runtime/queries/hyprlang/highlights.scm index d76993d12511..bf898c9cdd22 100644 --- a/runtime/queries/hyprlang/highlights.scm +++ b/runtime/queries/hyprlang/highlights.scm @@ -1,19 +1,19 @@ -(comment) @comment @spell +(comment) @comment [ "source" "exec" "exec-once" -] @keyword +] @function.builtin (keyword (name) @keyword) (assignment - (name) @property) + (name) @variable.other.member) (section - (name) @module) + (name) @namespace) (section device: (device_name) @type) @@ -22,7 +22,9 @@ "$" @punctuation.special -(boolean) @boolean +(boolean) @constant.builtin.boolean + +(string) @string (mod) @constant @@ -36,7 +38,7 @@ (legacy_hex) (angle) (hex) -] @number +] @constant.numeric "deg" @type