From 6ccd9db1c0a353bffe66c41b42cb1f00bb06295f Mon Sep 17 00:00:00 2001 From: Jonathan Lundholm Date: Wed, 5 Oct 2022 22:14:20 +0200 Subject: [PATCH 1/2] Add bicep language server Closes #4374 --- book/src/generated/lang-support.md | 1 + languages.toml | 14 ++++++ runtime/queries/bicep/highlights.scm | 71 ++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 runtime/queries/bicep/highlights.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 086cd3c68f43..1c2ffdc62b8c 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -5,6 +5,7 @@ | bash | ✓ | | | `bash-language-server` | | bass | ✓ | | | `bass` | | beancount | ✓ | | | | +| bicep | ✓ | | | `bicep-langserver` | | c | ✓ | ✓ | ✓ | `clangd` | | c-sharp | ✓ | ✓ | | `OmniSharp` | | cairo | ✓ | | | | diff --git a/languages.toml b/languages.toml index 839b6223af99..78e3a35d999a 100644 --- a/languages.toml +++ b/languages.toml @@ -1966,3 +1966,17 @@ roots = [] [[grammar]] name = "ini" source = { git = "https://github.com/justinmk/tree-sitter-ini", rev = "4d247fb876b4ae6b347687de4a179511bf67fcbc" } + +[[language]] +name = "bicep" +scope = "source.bicep" +file-types = ["bicep"] +roots = [] +auto-format = true +comment-token = "//" +indent = { tab-width = 2, unit = " "} +language-server = { command = "bicep-langserver" } + +[[grammar]] +name = "bicep" +source = { git = "https://github.com/Sjord/tree-sitter-bicep", rev = "60795d3a1b493e064b263a64cb4f7f758a3394d7" } diff --git a/runtime/queries/bicep/highlights.scm b/runtime/queries/bicep/highlights.scm new file mode 100644 index 000000000000..3ae7bf6f80b9 --- /dev/null +++ b/runtime/queries/bicep/highlights.scm @@ -0,0 +1,71 @@ +; Keywords + +[ + "module" + "var" + "param" + "import" + "resource" + "existing" + "if" + "targetScope" + "output" +] @keyword + +; Functions + +(decorator) @function.builtin +(functionCall) @function.call +(functionCall + (functionArgument + (variableAccess) @variable)) + +; Literals/Types + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(resourceDeclaration + (string + (stringLiteral) @string.special)) + +(moduleDeclaration + (string + (stringLiteral) @string.special)) + +[ + (string) + (stringLiteral) +] @string + +(nullLiteral) @keyword +(booleanLiteral) @constant.builtin.boolean +(integerLiteral) @constant.numeric.integer +(comment) @comment + +(string + (variableAccess + (identifier) @variable)) + +(type) @type + +; Variables + +(localVariable) @variable + +; Statements + +(object + (objectProperty + (identifier) @identifier)) + +(propertyAccess + (identifier) @identifier) + +(ifCondition) @conditional From 196f92af7888b093a0f7a72a0738569bf029f839 Mon Sep 17 00:00:00 2001 From: Jonathan Lundholm Date: Mon, 14 Nov 2022 09:50:50 +0100 Subject: [PATCH 2/2] fix: highlight captures --- runtime/queries/bicep/highlights.scm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/runtime/queries/bicep/highlights.scm b/runtime/queries/bicep/highlights.scm index 3ae7bf6f80b9..b6f928726333 100644 --- a/runtime/queries/bicep/highlights.scm +++ b/runtime/queries/bicep/highlights.scm @@ -15,7 +15,9 @@ ; Functions (decorator) @function.builtin -(functionCall) @function.call + +(functionCall) @function + (functionCall (functionArgument (variableAccess) @variable)) @@ -68,4 +70,4 @@ (propertyAccess (identifier) @identifier) -(ifCondition) @conditional +(ifCondition) @keyword.control.conditional