Summary
On Python 3.9, installing textual[syntax] does not install tree-sitter, and syntax highlighting in TextArea.code_editor(...) does not work.
There is no error — it simply falls back to plain text without highlighting.
If I manually install tree-sitter, I then get:
RuntimeError: SyntaxAwareDocument unavailable - tree-sitter is not installed.
Steps to reproduce
python3.9 -m venv venv
source venv/bin/activate
pip install textual==8.0 "textual[syntax]"
from textual.app import App, ComposeResult
from textual.widgets import TextArea
class Demo(App):
def compose(self) -> ComposeResult:
yield TextArea.code_editor(
'{ "a": 1 }',
language="json",
theme="monokai",
)
Demo().run()
Environment
- python-3.9
- textual-8.0
- Os (ubuntu)