Skip to content

feat: add Erlang language support (tree-sitter + erlang_ls) #167

@jafreck

Description

@jafreck

Summary

Add Erlang support via tree-sitter + LSP enrichment, complementing existing Elixir support in the BEAM ecosystem.

Tooling

Component Tool Notes
Tree-sitter grammar tree-sitter-erlang WhatsApp/Meta-maintained, high quality
LSP server erlang_ls Active, well-maintained
Alternative LSP ELP WhatsApp-backed, newer
SCIP indexer None N/A

What to implement

  • Add tree-sitter-erlang as an npm dependency
  • Create src/indexer/extractors/erlang.ts:
    • Extract -module(Name) as module symbol
    • Extract function_name(Args) -> Body declarations as function symbols (include arity in signature)
    • Extract -record(Name, {Fields}) as type/struct symbols
    • Extract -type and -spec declarations
    • Extract function calls as call refs — both local foo(X) and remote module:foo(X)
    • Extract -import(Module, [Fun/Arity]) and -include("header.hrl") as imports
    • Extract -behaviour(gen_server) callback implementations as relationships
  • Register erlang in SourceIndexStage EXTRACTORS map and ParserPool LANG_PACKAGES
  • Add erlang_ls to src/indexer/lsp/registry.ts: { command: 'erlang_ls', args: [] }
  • Add file extensions .erl, .hrl to walker
  • Add test fixtures in tests/fixtures/erlang/
  • Add extractor tests

Language notes

  • Functions are identified by Module:Function/Arity (e.g., lists:map/2)
  • Pattern-matching clauses: one function name can have multiple clause bodies — use first clause's line as start, last clause's end
  • Header files (.hrl) contain macros and record definitions — should be indexed
  • OTP behaviours (gen_server, gen_statem, supervisor) define callback relationships

Context

Complements existing Elixir support. Erlang and Elixir share the BEAM VM and often co-exist in projects. Many Elixir projects call into Erlang libraries.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions