[BUG] Docs: "Adding support for custom languages" example fails with current tree-sitter (TypeError from tree_sitter_languages.get_language)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- documentation
Research direction
Read docs/widgets/text_area.md and docs/examples/widgets/text_area_custom_language.py, then check the custom language installation note and example against the current tree-sitter packages. Update the documentation and example so Java language registration works with the supported dependency versions. Done when the walkthrough and included example run and the install note accurately describes what textual[syntax] installs.
Written by the indexing model from the issue text.
Description
Have you checked closed issues? Yes — searched for tree-sitter-languages / get_language / custom languages / text_area_custom_language. No existing issue covers this docs example breakage (related closed items were dependency upgrades or missing binaries, not this walkthrough).
Have you checked against the most recent version of Textual? Yes — textual 8.2.8 (current on PyPI) with textual[syntax] (tree-sitter 0.26.0), Python 3.12, clean virtualenv.
The bug
Docs: https://textual.textualize.io/widgets/text_area/#adding-support-for-custom-languages
Source: docs/widgets/text_area.md and docs/examples/widgets/text_area_custom_language.py
The example does:
from tree_sitter_languages import get_language
java_language = get_language("java")
This raises:
TypeError: __init__() takes exactly 1 argument (2 given)
tree-sitter-languages 1.10.2 is not compatible with tree-sitter >= 0.25, which textual[syntax] now requires. The included example file fails the same way. The install note near the top of the page also still says textual[syntax] installs tree-sitter-languages, which it no longer does (it installs individual tree-sitter-<lang> packages).
Suggested fix using the per-language package Textual already depends on:
import tree_sitter_java
from tree_sitter import Language
java_language = Language(tree_sitter_java.language())
With that change the example registers Java and highlights it (tested).
- Dominant language
- Python
- Stars
- 37.6k
- Forks
- 1.4k
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Textualize/textual
-
8.2.8: _parse_extended_key crashes the input thread on Kitty colon sub-parameters (key:shifted:base, mods:event) — ValueError in int(), app panicsPossibly taken @NavpreetSSidhu claimed this 9 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Textualize/textual#6746 · 3 comments ·
-
text boxes never stop listeningMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Textualize/textual#6744 · 3 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Textualize/textual#6738 · 4 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Textualize/textual#6735 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Textualize/textual#6734 · 2 comments ·
All issues in Textualize/textual
Similar issues
-
Remove the `pull_request_target` workflow before GitHub blocks itPossibly taken @jat255 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
IBM/mcp-context-forge#7483 ·
Maintainers usually reply within 2 days
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
[Bug Report]: OpenAI 辅助 API 连通性测试因输出上限仅 1 token 误报“未知错误”Possibly taken @fjfanjian claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Project-N-E-K-O/N.E.K.O#3640 ·
Maintainers usually reply within 1 day
-
author-page correction
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
acl-org/acl-anthology#10808 · 1 comment ·
Maintainers usually reply within 1 day