{"id":28416,"library":"tree-sitter-scala","title":"tree-sitter-scala","description":"Scala grammar for tree-sitter, providing incremental parsing, syntax tree queries, and syntax highlighting for Scala 2 and Scala 3. The current version is 0.26.0, which requires tree-sitter >=0.26.8 and Python >=3.9. The library is actively maintained with regular releases.","status":"active","version":"0.26.0","language":"python","source_language":"en","source_url":"https://github.com/tree-sitter/tree-sitter-scala","tags":["tree-sitter","scala","grammar","parsing"],"install":[{"cmd":"pip install tree-sitter-scala","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"Required runtime dependency.","package":"tree-sitter","optional":false}],"imports":[{"note":"Do not import Language from the base tree_sitter package; the grammar-specific bindings are in tree_sitter_scala.","wrong":"from tree_sitter import Language","symbol":"Language","correct":"from tree_sitter_scala import Language"},{"note":"The function that returns the compiled language.","wrong":null,"symbol":"language","correct":"from tree_sitter_scala import language"}],"quickstart":{"code":"from tree_sitter import Language, Parser\nfrom tree_sitter_scala import language\n\n# Get the Scala language object\nSCALA_LANGUAGE = language()\n\n# Initialize a parser with the Scala language\nparser = Parser()\nparser.set_language(SCALA_LANGUAGE)\n\n# Parse some Scala code\ntree = parser.parse(bytes(\"object Hello extends App { println(\\\"Hello, world!\\\") }\", \"utf8\"))\nprint(tree.root_node.sexp())","lang":"python","description":"Initialize a tree-sitter parser for Scala and parse a simple code snippet."},"warnings":[{"fix":"Upgrade tree-sitter to 0.26.8 or later: pip install --upgrade tree-sitter","message":"Version 0.26.0 requires tree-sitter >=0.26.8. Older tree-sitter versions will cause import errors.","severity":"breaking","affected_versions":"<0.26.0"},{"fix":"Always use from tree_sitter_scala import ...","message":"The Python package is named 'tree-sitter-scala' on PyPI, but the import module is 'tree_sitter_scala' (underscores, not hyphens).","severity":"gotcha","affected_versions":"all"},{"fix":"Use from tree_sitter_scala import language and then language()","message":"The old method of obtaining language via Language('scala') from tree_sitter is deprecated and may be removed.","severity":"deprecated","affected_versions":">=0.20.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Run: pip install tree-sitter","cause":"The base tree-sitter library is not installed.","error":"ModuleNotFoundError: No module named 'tree_sitter'"},{"fix":"Upgrade tree-sitter: pip install --upgrade tree-sitter","cause":"Old tree-sitter version (<0.26) does not expose Language directly.","error":"ImportError: cannot import name 'Language' from 'tree_sitter'"},{"fix":"Use from tree_sitter_scala import language and then language()","cause":"Using Language('scala') without the proper grammar binding or with an outdated tree-sitter version.","error":"tree_sitter.binding.LanguageError: Unknown language 'scala'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}