From efdb769f9b06907d334157892bea703222d1fd1b Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Tue, 11 Mar 2025 15:10:51 -0400 Subject: [PATCH] terraform: Extract to zed-extensions/terraform repository (#26475) This PR extracts the Terraform extension to the [zed-extensions/terraform](https://github.com/zed-extensions/terraform) repository. Release Notes: - N/A --- Cargo.lock | 7 - Cargo.toml | 1 - docs/src/languages/terraform.md | 2 +- extensions/terraform/Cargo.toml | 16 -- extensions/terraform/LICENSE-APACHE | 1 - extensions/terraform/extension.toml | 19 --- .../terraform/languages/hcl/brackets.scm | 5 - .../terraform/languages/hcl/config.toml | 15 -- .../terraform/languages/hcl/highlights.scm | 117 ------------- .../terraform/languages/hcl/indents.scm | 13 -- .../terraform/languages/hcl/injections.scm | 6 - .../terraform/languages/hcl/outline.scm | 74 -------- .../languages/terraform-vars/brackets.scm | 5 - .../languages/terraform-vars/config.toml | 15 -- .../languages/terraform-vars/highlights.scm | 159 ------------------ .../languages/terraform-vars/indents.scm | 16 -- .../languages/terraform-vars/injections.scm | 9 - .../languages/terraform/brackets.scm | 5 - .../terraform/languages/terraform/config.toml | 15 -- .../languages/terraform/highlights.scm | 159 ------------------ .../terraform/languages/terraform/indents.scm | 16 -- .../languages/terraform/injections.scm | 9 - .../terraform/languages/terraform/outline.scm | 76 --------- extensions/terraform/src/terraform.rs | 102 ----------- 24 files changed, 1 insertion(+), 861 deletions(-) delete mode 100644 extensions/terraform/Cargo.toml delete mode 120000 extensions/terraform/LICENSE-APACHE delete mode 100644 extensions/terraform/extension.toml delete mode 100644 extensions/terraform/languages/hcl/brackets.scm delete mode 100644 extensions/terraform/languages/hcl/config.toml delete mode 100644 extensions/terraform/languages/hcl/highlights.scm delete mode 100644 extensions/terraform/languages/hcl/indents.scm delete mode 100644 extensions/terraform/languages/hcl/injections.scm delete mode 100644 extensions/terraform/languages/hcl/outline.scm delete mode 100644 extensions/terraform/languages/terraform-vars/brackets.scm delete mode 100644 extensions/terraform/languages/terraform-vars/config.toml delete mode 100644 extensions/terraform/languages/terraform-vars/highlights.scm delete mode 100644 extensions/terraform/languages/terraform-vars/indents.scm delete mode 100644 extensions/terraform/languages/terraform-vars/injections.scm delete mode 100644 extensions/terraform/languages/terraform/brackets.scm delete mode 100644 extensions/terraform/languages/terraform/config.toml delete mode 100644 extensions/terraform/languages/terraform/highlights.scm delete mode 100644 extensions/terraform/languages/terraform/indents.scm delete mode 100644 extensions/terraform/languages/terraform/injections.scm delete mode 100644 extensions/terraform/languages/terraform/outline.scm delete mode 100644 extensions/terraform/src/terraform.rs diff --git a/Cargo.lock b/Cargo.lock index 311c386af4..d8d63e77bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17212,13 +17212,6 @@ dependencies = [ "zed_extension_api 0.1.0", ] -[[package]] -name = "zed_terraform" -version = "0.1.2" -dependencies = [ - "zed_extension_api 0.1.0", -] - [[package]] name = "zed_test_extension" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 6148919020..fde4d68d59 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -178,7 +178,6 @@ members = [ "extensions/ruff", "extensions/slash-commands-example", "extensions/snippets", - "extensions/terraform", "extensions/test-extension", "extensions/toml", "extensions/uiua", diff --git a/docs/src/languages/terraform.md b/docs/src/languages/terraform.md index bbafa9f203..401526f169 100644 --- a/docs/src/languages/terraform.md +++ b/docs/src/languages/terraform.md @@ -1,6 +1,6 @@ # Terraform -Terraform support is available through the [Terraform extension](https://github.com/zed-industries/zed/tree/main/extensions/terraform). +Terraform support is available through the [Terraform extension](https://github.com/zed-extensions/terraform). - Tree-sitter: [MichaHoffmann/tree-sitter-hcl](https://github.com/MichaHoffmann/tree-sitter-hcl) - Language Server: [hashicorp/terraform-ls](https://github.com/hashicorp/terraform-ls) diff --git a/extensions/terraform/Cargo.toml b/extensions/terraform/Cargo.toml deleted file mode 100644 index ecf1b86fa9..0000000000 --- a/extensions/terraform/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "zed_terraform" -version = "0.1.2" -edition.workspace = true -publish.workspace = true -license = "Apache-2.0" - -[lints] -workspace = true - -[lib] -path = "src/terraform.rs" -crate-type = ["cdylib"] - -[dependencies] -zed_extension_api = "0.1.0" diff --git a/extensions/terraform/LICENSE-APACHE b/extensions/terraform/LICENSE-APACHE deleted file mode 120000 index 1cd601d0a3..0000000000 --- a/extensions/terraform/LICENSE-APACHE +++ /dev/null @@ -1 +0,0 @@ -../../LICENSE-APACHE \ No newline at end of file diff --git a/extensions/terraform/extension.toml b/extensions/terraform/extension.toml deleted file mode 100644 index 38e412715a..0000000000 --- a/extensions/terraform/extension.toml +++ /dev/null @@ -1,19 +0,0 @@ -id = "terraform" -name = "Terraform" -description = "Terraform support." -version = "0.1.2" -schema_version = 1 -authors = ["Caius Durling ", "Daniel Banck "] -repository = "https://github.com/zed-industries/zed" - -[language_servers.terraform-ls] -name = "Terraform Language Server" -languages = ["Terraform", "Terraform Vars"] -language_ids = { Terraform = "terraform", "Terraform Vars" = "terraform-vars" } -# TODO: file issue for server supported code actions -# TODO: reenable default actions / delete override -code_action_kinds = [] - -[grammars.hcl] -repository = "https://github.com/MichaHoffmann/tree-sitter-hcl" -commit = "e936d3fef8bac884661472dce71ad82284761eb1" diff --git a/extensions/terraform/languages/hcl/brackets.scm b/extensions/terraform/languages/hcl/brackets.scm deleted file mode 100644 index eff2faad54..0000000000 --- a/extensions/terraform/languages/hcl/brackets.scm +++ /dev/null @@ -1,5 +0,0 @@ -("(" @open ")" @close) -("[" @open "]" @close) -("{" @open "}" @close) -((block_start) @open (block_end) @close) -((tuple_start) @open (tuple_end) @close) diff --git a/extensions/terraform/languages/hcl/config.toml b/extensions/terraform/languages/hcl/config.toml deleted file mode 100644 index be7e601e01..0000000000 --- a/extensions/terraform/languages/hcl/config.toml +++ /dev/null @@ -1,15 +0,0 @@ -name = "HCL" -grammar = "hcl" -path_suffixes = ["hcl"] -line_comments = ["# ", "// "] -block_comment = ["/*", "*/"] -autoclose_before = ",}])" -brackets = [ - { start = "{", end = "}", close = true, newline = true }, - { start = "[", end = "]", close = true, newline = true }, - { start = "(", end = ")", close = true, newline = true }, - { start = "\"", end = "\"", close = true, newline = false, not_in = ["comment", "string"] }, - { start = "'", end = "'", close = true, newline = false, not_in = ["comment", "string"] }, - { start = "/*", end = " */", close = true, newline = false, not_in = ["comment", "string"] }, -] -tab_size = 2 diff --git a/extensions/terraform/languages/hcl/highlights.scm b/extensions/terraform/languages/hcl/highlights.scm deleted file mode 100644 index a1713b3e3f..0000000000 --- a/extensions/terraform/languages/hcl/highlights.scm +++ /dev/null @@ -1,117 +0,0 @@ -; https://github.com/nvim-treesitter/nvim-treesitter/blob/cb79d2446196d25607eb1d982c96939abdf67b8e/queries/hcl/highlights.scm -; highlights.scm -[ - "!" - "\*" - "/" - "%" - "\+" - "-" - ">" - ">=" - "<" - "<=" - "==" - "!=" - "&&" - "||" -] @operator - -[ - "{" - "}" - "[" - "]" - "(" - ")" -] @punctuation.bracket - -[ - "." - ".*" - "," - "[*]" -] @punctuation.delimiter - -[ - (ellipsis) - "\?" - "=>" -] @punctuation.special - -[ - ":" - "=" -] @punctuation - -[ - "for" - "endfor" - "in" - "if" - "else" - "endif" -] @keyword - -[ - (quoted_template_start) ; " - (quoted_template_end) ; " - (template_literal) ; non-interpolation/directive content -] @string - -[ - (heredoc_identifier) ; END - (heredoc_start) ; << or <<- -] @punctuation.delimiter - -[ - (template_interpolation_start) ; ${ - (template_interpolation_end) ; } - (template_directive_start) ; %{ - (template_directive_end) ; } - (strip_marker) ; ~ -] @punctuation.special - -(numeric_lit) @number - -(bool_lit) @boolean - -(null_lit) @constant - -(comment) @comment - -(identifier) @variable - -(body - (block - (identifier) @keyword)) - -(body - (block - (body - (block - (identifier) @type)))) - -(function_call - (identifier) @function) - -(attribute - (identifier) @variable) - -; { key: val } -; -; highlight identifier keys as though they were block attributes -(object_elem - key: - (expression - (variable_expr - (identifier) @variable))) - -; var.foo, data.bar -; -; first element in get_attr is a variable.builtin or a reference to a variable.builtin -(expression - (variable_expr - (identifier) @variable) - (get_attr - (identifier) @variable)) diff --git a/extensions/terraform/languages/hcl/indents.scm b/extensions/terraform/languages/hcl/indents.scm deleted file mode 100644 index be12af1d0c..0000000000 --- a/extensions/terraform/languages/hcl/indents.scm +++ /dev/null @@ -1,13 +0,0 @@ -; https://github.com/nvim-treesitter/nvim-treesitter/blob/ce4adf11cfe36fc5b0e5bcdce0c7c6e8fbc9798a/queries/hcl/indents.scm -[ - (block) - (object) - (tuple) - (function_call) -] @indent - -[ - "]" - "}" - ")" -] @outdent diff --git a/extensions/terraform/languages/hcl/injections.scm b/extensions/terraform/languages/hcl/injections.scm deleted file mode 100644 index f06f6b970c..0000000000 --- a/extensions/terraform/languages/hcl/injections.scm +++ /dev/null @@ -1,6 +0,0 @@ -; https://github.com/nvim-treesitter/nvim-treesitter/blob/ce4adf11cfe36fc5b0e5bcdce0c7c6e8fbc9798a/queries/hcl/injections.scm - -(heredoc_template - (template_literal) @injection.content - (heredoc_identifier) @injection.language - (#downcase! @injection.language)) diff --git a/extensions/terraform/languages/hcl/outline.scm b/extensions/terraform/languages/hcl/outline.scm deleted file mode 100644 index 0dc3abc93d..0000000000 --- a/extensions/terraform/languages/hcl/outline.scm +++ /dev/null @@ -1,74 +0,0 @@ -; HCL Outline Scheme -; Comments -(comment) @annotation - -; Block with and without string_lit -; Example: -; terraform { ... } -; module "vpc" { ... } -; resource "resource" "name" { ... } -(config_file - (body - (block - (identifier) @context - ) @item - ) -) - -; Inside block with identifier -(config_file - (body - (block - (identifier) - (body - (attribute - (identifier) @context - ) @item - ) - ) - ) -) - -; Inside block with identifier and string_lit -(config_file - (body - (block - (identifier) - (body - (block - (identifier) @context - (string_lit)? @name - ) @item - ) - ) - ) -) - -; Root Attribute block -; Example: -; inputs = { ... } -(config_file - (body - (attribute - (identifier) @context - ) @item - ) -) - -; Inside Root Attribute block -(config_file - (body - (attribute - (identifier) - (expression - (collection_value - (object - (object_elem - key: (expression (variable_expr (identifier) @context)) - ) @item - ) - ) - ) - ) - ) -) diff --git a/extensions/terraform/languages/terraform-vars/brackets.scm b/extensions/terraform/languages/terraform-vars/brackets.scm deleted file mode 100644 index eff2faad54..0000000000 --- a/extensions/terraform/languages/terraform-vars/brackets.scm +++ /dev/null @@ -1,5 +0,0 @@ -("(" @open ")" @close) -("[" @open "]" @close) -("{" @open "}" @close) -((block_start) @open (block_end) @close) -((tuple_start) @open (tuple_end) @close) diff --git a/extensions/terraform/languages/terraform-vars/config.toml b/extensions/terraform/languages/terraform-vars/config.toml deleted file mode 100644 index 4d803ee36e..0000000000 --- a/extensions/terraform/languages/terraform-vars/config.toml +++ /dev/null @@ -1,15 +0,0 @@ -name = "Terraform Vars" -grammar = "hcl" -path_suffixes = ["tfvars"] -line_comments = ["# ", "// "] -block_comment = ["/*", "*/"] -autoclose_before = ",}])" -brackets = [ - { start = "{", end = "}", close = true, newline = true }, - { start = "[", end = "]", close = true, newline = true }, - { start = "(", end = ")", close = true, newline = true }, - { start = "\"", end = "\"", close = true, newline = false, not_in = ["comment", "string"] }, - { start = "'", end = "'", close = true, newline = false, not_in = ["comment", "string"] }, - { start = "/*", end = " */", close = true, newline = false, not_in = ["comment", "string"] }, -] -tab_size = 2 diff --git a/extensions/terraform/languages/terraform-vars/highlights.scm b/extensions/terraform/languages/terraform-vars/highlights.scm deleted file mode 100644 index ca39758ba6..0000000000 --- a/extensions/terraform/languages/terraform-vars/highlights.scm +++ /dev/null @@ -1,159 +0,0 @@ -; https://github.com/nvim-treesitter/nvim-treesitter/blob/cb79d2446196d25607eb1d982c96939abdf67b8e/queries/hcl/highlights.scm -; highlights.scm -[ - "!" - "\*" - "/" - "%" - "\+" - "-" - ">" - ">=" - "<" - "<=" - "==" - "!=" - "&&" - "||" -] @operator - -[ - "{" - "}" - "[" - "]" - "(" - ")" -] @punctuation.bracket - -[ - "." - ".*" - "," - "[*]" -] @punctuation.delimiter - -[ - (ellipsis) - "\?" - "=>" -] @punctuation.special - -[ - ":" - "=" -] @punctuation - -[ - "for" - "endfor" - "in" - "if" - "else" - "endif" -] @keyword - -[ - (quoted_template_start) ; " - (quoted_template_end) ; " - (template_literal) ; non-interpolation/directive content -] @string - -[ - (heredoc_identifier) ; END - (heredoc_start) ; << or <<- -] @punctuation.delimiter - -[ - (template_interpolation_start) ; ${ - (template_interpolation_end) ; } - (template_directive_start) ; %{ - (template_directive_end) ; } - (strip_marker) ; ~ -] @punctuation.special - -(numeric_lit) @number - -(bool_lit) @boolean - -(null_lit) @constant - -(comment) @comment - -(identifier) @variable - -(body - (block - (identifier) @keyword)) - -(body - (block - (body - (block - (identifier) @type)))) - -(function_call - (identifier) @function) - -(attribute - (identifier) @variable) - -; { key: val } -; -; highlight identifier keys as though they were block attributes -(object_elem - key: - (expression - (variable_expr - (identifier) @variable))) - -; var.foo, data.bar -; -; first element in get_attr is a variable.builtin or a reference to a variable.builtin -(expression - (variable_expr - (identifier) @variable) - (get_attr - (identifier) @variable)) - -; https://github.com/nvim-treesitter/nvim-treesitter/blob/cb79d2446196d25607eb1d982c96939abdf67b8e/queries/terraform/highlights.scm -; Terraform specific references -; -; -; local/module/data/var/output -(expression - (variable_expr - (identifier) @variable - (#any-of? @variable "data" "var" "local" "module" "output")) - (get_attr - (identifier) @variable)) - -; path.root/cwd/module -(expression - (variable_expr - (identifier) @type - (#eq? @type "path")) - (get_attr - (identifier) @variable - (#any-of? @variable "root" "cwd" "module"))) - -; terraform.workspace -(expression - (variable_expr - (identifier) @type - (#eq? @type "terraform")) - (get_attr - (identifier) @variable - (#any-of? @variable "workspace"))) - -; Terraform specific keywords -; TODO: ideally only for identifiers under a `variable` block to minimize false positives -((identifier) @type - (#any-of? @type "bool" "string" "number" "object" "tuple" "list" "map" "set" "any")) - -(object_elem - val: - (expression - (variable_expr - (identifier) @type - (#any-of? @type "bool" "string" "number" "object" "tuple" "list" "map" "set" "any")))) diff --git a/extensions/terraform/languages/terraform-vars/indents.scm b/extensions/terraform/languages/terraform-vars/indents.scm deleted file mode 100644 index b9ba0ad56a..0000000000 --- a/extensions/terraform/languages/terraform-vars/indents.scm +++ /dev/null @@ -1,16 +0,0 @@ -; https://github.com/nvim-treesitter/nvim-treesitter/blob/ce4adf11cfe36fc5b0e5bcdce0c7c6e8fbc9798a/queries/hcl/indents.scm -[ - (block) - (object) - (tuple) - (function_call) -] @indent - -[ - "]" - "}" - ")" -] @outdent - -; https://github.com/nvim-treesitter/nvim-treesitter/blob/ce4adf11cfe36fc5b0e5bcdce0c7c6e8fbc9798a/queries/terraform/indents.scm -; inherits: hcl diff --git a/extensions/terraform/languages/terraform-vars/injections.scm b/extensions/terraform/languages/terraform-vars/injections.scm deleted file mode 100644 index 49e7d8d325..0000000000 --- a/extensions/terraform/languages/terraform-vars/injections.scm +++ /dev/null @@ -1,9 +0,0 @@ -; https://github.com/nvim-treesitter/nvim-treesitter/blob/ce4adf11cfe36fc5b0e5bcdce0c7c6e8fbc9798a/queries/hcl/injections.scm - -(heredoc_template - (template_literal) @injection.content - (heredoc_identifier) @injection.language - (#downcase! @injection.language)) - -; https://github.com/nvim-treesitter/nvim-treesitter/blob/ce4adf11cfe36fc5b0e5bcdce0c7c6e8fbc9798a/queries/terraform/injections.scm -; inherits: hcl diff --git a/extensions/terraform/languages/terraform/brackets.scm b/extensions/terraform/languages/terraform/brackets.scm deleted file mode 100644 index eff2faad54..0000000000 --- a/extensions/terraform/languages/terraform/brackets.scm +++ /dev/null @@ -1,5 +0,0 @@ -("(" @open ")" @close) -("[" @open "]" @close) -("{" @open "}" @close) -((block_start) @open (block_end) @close) -((tuple_start) @open (tuple_end) @close) diff --git a/extensions/terraform/languages/terraform/config.toml b/extensions/terraform/languages/terraform/config.toml deleted file mode 100644 index cfb27f4cc2..0000000000 --- a/extensions/terraform/languages/terraform/config.toml +++ /dev/null @@ -1,15 +0,0 @@ -name = "Terraform" -grammar = "hcl" -path_suffixes = ["tf"] -line_comments = ["# ", "// "] -block_comment = ["/*", "*/"] -autoclose_before = ",}])" -brackets = [ - { start = "{", end = "}", close = true, newline = true }, - { start = "[", end = "]", close = true, newline = true }, - { start = "(", end = ")", close = true, newline = true }, - { start = "\"", end = "\"", close = true, newline = false, not_in = ["comment", "string"] }, - { start = "'", end = "'", close = true, newline = false, not_in = ["comment", "string"] }, - { start = "/*", end = " */", close = true, newline = false, not_in = ["comment", "string"] }, -] -tab_size = 2 diff --git a/extensions/terraform/languages/terraform/highlights.scm b/extensions/terraform/languages/terraform/highlights.scm deleted file mode 100644 index ca39758ba6..0000000000 --- a/extensions/terraform/languages/terraform/highlights.scm +++ /dev/null @@ -1,159 +0,0 @@ -; https://github.com/nvim-treesitter/nvim-treesitter/blob/cb79d2446196d25607eb1d982c96939abdf67b8e/queries/hcl/highlights.scm -; highlights.scm -[ - "!" - "\*" - "/" - "%" - "\+" - "-" - ">" - ">=" - "<" - "<=" - "==" - "!=" - "&&" - "||" -] @operator - -[ - "{" - "}" - "[" - "]" - "(" - ")" -] @punctuation.bracket - -[ - "." - ".*" - "," - "[*]" -] @punctuation.delimiter - -[ - (ellipsis) - "\?" - "=>" -] @punctuation.special - -[ - ":" - "=" -] @punctuation - -[ - "for" - "endfor" - "in" - "if" - "else" - "endif" -] @keyword - -[ - (quoted_template_start) ; " - (quoted_template_end) ; " - (template_literal) ; non-interpolation/directive content -] @string - -[ - (heredoc_identifier) ; END - (heredoc_start) ; << or <<- -] @punctuation.delimiter - -[ - (template_interpolation_start) ; ${ - (template_interpolation_end) ; } - (template_directive_start) ; %{ - (template_directive_end) ; } - (strip_marker) ; ~ -] @punctuation.special - -(numeric_lit) @number - -(bool_lit) @boolean - -(null_lit) @constant - -(comment) @comment - -(identifier) @variable - -(body - (block - (identifier) @keyword)) - -(body - (block - (body - (block - (identifier) @type)))) - -(function_call - (identifier) @function) - -(attribute - (identifier) @variable) - -; { key: val } -; -; highlight identifier keys as though they were block attributes -(object_elem - key: - (expression - (variable_expr - (identifier) @variable))) - -; var.foo, data.bar -; -; first element in get_attr is a variable.builtin or a reference to a variable.builtin -(expression - (variable_expr - (identifier) @variable) - (get_attr - (identifier) @variable)) - -; https://github.com/nvim-treesitter/nvim-treesitter/blob/cb79d2446196d25607eb1d982c96939abdf67b8e/queries/terraform/highlights.scm -; Terraform specific references -; -; -; local/module/data/var/output -(expression - (variable_expr - (identifier) @variable - (#any-of? @variable "data" "var" "local" "module" "output")) - (get_attr - (identifier) @variable)) - -; path.root/cwd/module -(expression - (variable_expr - (identifier) @type - (#eq? @type "path")) - (get_attr - (identifier) @variable - (#any-of? @variable "root" "cwd" "module"))) - -; terraform.workspace -(expression - (variable_expr - (identifier) @type - (#eq? @type "terraform")) - (get_attr - (identifier) @variable - (#any-of? @variable "workspace"))) - -; Terraform specific keywords -; TODO: ideally only for identifiers under a `variable` block to minimize false positives -((identifier) @type - (#any-of? @type "bool" "string" "number" "object" "tuple" "list" "map" "set" "any")) - -(object_elem - val: - (expression - (variable_expr - (identifier) @type - (#any-of? @type "bool" "string" "number" "object" "tuple" "list" "map" "set" "any")))) diff --git a/extensions/terraform/languages/terraform/indents.scm b/extensions/terraform/languages/terraform/indents.scm deleted file mode 100644 index b9ba0ad56a..0000000000 --- a/extensions/terraform/languages/terraform/indents.scm +++ /dev/null @@ -1,16 +0,0 @@ -; https://github.com/nvim-treesitter/nvim-treesitter/blob/ce4adf11cfe36fc5b0e5bcdce0c7c6e8fbc9798a/queries/hcl/indents.scm -[ - (block) - (object) - (tuple) - (function_call) -] @indent - -[ - "]" - "}" - ")" -] @outdent - -; https://github.com/nvim-treesitter/nvim-treesitter/blob/ce4adf11cfe36fc5b0e5bcdce0c7c6e8fbc9798a/queries/terraform/indents.scm -; inherits: hcl diff --git a/extensions/terraform/languages/terraform/injections.scm b/extensions/terraform/languages/terraform/injections.scm deleted file mode 100644 index 49e7d8d325..0000000000 --- a/extensions/terraform/languages/terraform/injections.scm +++ /dev/null @@ -1,9 +0,0 @@ -; https://github.com/nvim-treesitter/nvim-treesitter/blob/ce4adf11cfe36fc5b0e5bcdce0c7c6e8fbc9798a/queries/hcl/injections.scm - -(heredoc_template - (template_literal) @injection.content - (heredoc_identifier) @injection.language - (#downcase! @injection.language)) - -; https://github.com/nvim-treesitter/nvim-treesitter/blob/ce4adf11cfe36fc5b0e5bcdce0c7c6e8fbc9798a/queries/terraform/injections.scm -; inherits: hcl diff --git a/extensions/terraform/languages/terraform/outline.scm b/extensions/terraform/languages/terraform/outline.scm deleted file mode 100644 index b50e239afc..0000000000 --- a/extensions/terraform/languages/terraform/outline.scm +++ /dev/null @@ -1,76 +0,0 @@ -; HCL Outline Scheme -; Comments -(comment) @annotation - -; Block with and without string_lit -; Example: -; terraform { ... } -; module "vpc" { ... } -; resource "resource" "name" { ... } -(config_file - (body - (block - (identifier) @context - (string_lit)? @name - (string_lit)? @name - ) @item - ) -) - -; Inside block with identifier -(config_file - (body - (block - (identifier) - (body - (attribute - (identifier) @context - ) @item - ) - ) - ) -) - -; Inside block with identifier and string_lit -(config_file - (body - (block - (identifier) - (body - (block - (identifier) @context - (string_lit)? @name - ) @item - ) - ) - ) -) - -; Root Attribute block -; Example: -; inputs = { ... } -(config_file - (body - (attribute - (identifier) @context - ) @item - ) -) - -; Inside Root Attribute block -(config_file - (body - (attribute - (identifier) - (expression - (collection_value - (object - (object_elem - key: (expression (variable_expr (identifier) @context)) - ) @item - ) - ) - ) - ) - ) -) diff --git a/extensions/terraform/src/terraform.rs b/extensions/terraform/src/terraform.rs deleted file mode 100644 index 213a4392c6..0000000000 --- a/extensions/terraform/src/terraform.rs +++ /dev/null @@ -1,102 +0,0 @@ -use std::fs; -use zed::LanguageServerId; -use zed_extension_api::{self as zed, Result}; - -struct TerraformExtension { - cached_binary_path: Option, -} - -impl TerraformExtension { - fn language_server_binary_path( - &mut self, - language_server_id: &LanguageServerId, - worktree: &zed::Worktree, - ) -> Result { - if let Some(path) = worktree.which("terraform-ls") { - return Ok(path); - } - - if let Some(path) = &self.cached_binary_path { - if fs::metadata(path).map_or(false, |stat| stat.is_file()) { - return Ok(path.clone()); - } - } - - zed::set_language_server_installation_status( - language_server_id, - &zed::LanguageServerInstallationStatus::CheckingForUpdate, - ); - let release = zed::latest_github_release( - "hashicorp/terraform-ls", - zed::GithubReleaseOptions { - require_assets: false, - pre_release: false, - }, - )?; - - let (platform, arch) = zed::current_platform(); - let download_url = format!( - "https://releases.hashicorp.com/terraform-ls/{version}/terraform-ls_{version}_{os}_{arch}.zip", - version = release.version.strip_prefix('v').unwrap_or(&release.version), - os = match platform { - zed::Os::Mac => "darwin", - zed::Os::Linux => "linux", - zed::Os::Windows => "windows", - }, - arch = match arch { - zed::Architecture::Aarch64 => "arm64", - zed::Architecture::X86 => "386", - zed::Architecture::X8664 => "amd64", - }, - ); - - let version_dir = format!("terraform-ls-{}", release.version); - let binary_path = format!("{version_dir}/terraform-ls"); - - if !fs::metadata(&binary_path).map_or(false, |stat| stat.is_file()) { - zed::set_language_server_installation_status( - language_server_id, - &zed::LanguageServerInstallationStatus::Downloading, - ); - - zed::download_file(&download_url, &version_dir, zed::DownloadedFileType::Zip) - .map_err(|e| format!("failed to download file: {e}"))?; - - zed::make_file_executable(&binary_path)?; - - let entries = - fs::read_dir(".").map_err(|e| format!("failed to list working directory {e}"))?; - for entry in entries { - let entry = entry.map_err(|e| format!("failed to load directory entry {e}"))?; - if entry.file_name().to_str() != Some(&version_dir) { - fs::remove_dir_all(entry.path()).ok(); - } - } - } - - self.cached_binary_path = Some(binary_path.clone()); - Ok(binary_path) - } -} - -impl zed::Extension for TerraformExtension { - fn new() -> Self { - Self { - cached_binary_path: None, - } - } - - fn language_server_command( - &mut self, - language_server_id: &LanguageServerId, - worktree: &zed::Worktree, - ) -> Result { - Ok(zed::Command { - command: self.language_server_binary_path(language_server_id, worktree)?, - args: vec!["serve".to_string()], - env: Default::default(), - }) - } -} - -zed::register_extension!(TerraformExtension);