tree-sitter-lua
raw JSON → 0.5.0 verified Sat May 09 auth: no python
Lua grammar for tree-sitter, providing incremental parsing and syntax tree queries for Lua code. Current version 0.5.0 (2025), supports Python >=3.10. Regenerated with tree-sitter 0.26.6. Release cadence is irregular, roughly semiannual.
pip install tree-sitter-lua Common errors
error ModuleNotFoundError: No module named 'tree_sitter_lua' ↓
cause The package is not installed or the import path is wrong.
fix
Install: pip install tree-sitter-lua
error AttributeError: module 'tree_sitter_lua' has no attribute 'language' ↓
cause The function is named `language_lua`, not `language`.
fix
Use: from tree_sitter_lua import language_lua
Warnings
breaking Version 0.4.0 regenerated the parser with ABI 15, breaking compatibility with tree-sitter <=0.24. Make sure your tree-sitter library is at least 0.25. ↓
fix Upgrade tree-sitter: pip install --upgrade tree-sitter
deprecated The old import pattern `from tree_sitter_lua import language` (without underscore) is no longer supported after v0.1.0. ↓
fix Use `from tree_sitter_lua import language_lua`
gotcha The grammar version (0.5.0) does not match the tree-sitter library version. You must install tree-sitter separately. ↓
fix Run `pip install tree-sitter` before using tree-sitter-lua.
Imports
- language_lua
from tree_sitter_lua import language_lua
Quickstart
from tree_sitter import Language, Parser
from tree_sitter_lua import language_lua
LUA_LANGUAGE = Language(language_lua())
parser = Parser()
parser.set_language(LUA_LANGUAGE)
tree = parser.parse(b"print('hello world')")
print(tree.root_node.sexp())