Skip to content

Add tree-sitter HCL/Terraform grammar support for .tf filesΒ #6869

@connelldave

Description

@connelldave

Summary

The code tool's tree-sitter-based operations (get_document_symbols, search_symbols, lookup_symbols, pattern_search, pattern_rewrite) don't support Terraform/HCL (.tf, .tfvars) files.

Steps to Reproduce

  1. Open a workspace containing .tf files
  2. Ask the assistant to get document symbols from a .tf file
  3. The code tool returns: "Failed to get document symbols: Unsupported file extension: tf"

Expected Behavior

Tree-sitter operations should work with .tf files. A tree-sitter HCL grammar already exists: https://github.com/tree-sitter-grammars/tree-sitter-hcl

Current Behavior

The built-in tree-sitter support is limited to 18 languages with no way to add custom grammars. The only extensibility point is custom LSP servers via lsp.json, which covers LSP operations but not tree-sitter-based ones (symbol search, pattern matching, etc.).

Suggestion

Either:

  1. Bundle tree-sitter-hcl as a 19th built-in grammar, or
  2. Provide a plugin mechanism to load custom tree-sitter grammars (similar to how lsp.json allows custom language servers)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions