Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding tree-sitter support for advanced highlighting #398

Open
tomlin7 opened this issue Oct 8, 2024 · 1 comment · May be fixed by #455
Open

Adding tree-sitter support for advanced highlighting #398

tomlin7 opened this issue Oct 8, 2024 · 1 comment · May be fixed by #455
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed language features syntax highlighting, lsp, other language features suggestions needed bugs/features that are still not figured out and need solution suggestions text editor Related to text editor's features

Comments

@tomlin7
Copy link
Owner

tomlin7 commented Oct 8, 2024

Feature

Currently, Pygments handles the syntax highlighting for over 500+ file types. While it's a good system already, there are performance issues with this while editing large files. Treesitter provides a better highlighter and can help in this situation. One drawback is having to add support for each language individually.

Using biscuit extensions to add support for individual languages will solve this issue. Provide support for some of the most popular ones built-in. And have pygments as a fallback highlighter if suitable (keeping the executable size at minimum).

@tomlin7 tomlin7 added enhancement New feature or request text editor Related to text editor's features language features syntax highlighting, lsp, other language features labels Oct 8, 2024
@tomlin7 tomlin7 self-assigned this Oct 8, 2024
@tomlin7 tomlin7 added the help wanted Extra attention is needed label Oct 8, 2024
@tomlin7 tomlin7 pinned this issue Oct 8, 2024
@tomlin7 tomlin7 changed the title Adding treesitter support for advanced highlighting Adding tree-sitter support for advanced highlighting Oct 10, 2024
@tomlin7
Copy link
Owner Author

tomlin7 commented Oct 10, 2024

@RINO-GAELICO I say this one is hard to tackle as it requires good knowledge about both tree-sitter, biscuit's editor component and language features, so this is not a good first issue.

@tomlin7 tomlin7 added the suggestions needed bugs/features that are still not figured out and need solution suggestions label Oct 11, 2024
tomlin7 added a commit that referenced this issue Nov 4, 2024
Fixes #398

Add Tree-sitter support for advanced syntax highlighting for Python files.

* **New File**: `src/biscuit/editor/text/treesitter.py`
  - Implement Tree-sitter highlighter for Python files.
  - Load language library and extract highlight information from the syntax tree.

* **Update**: `src/biscuit/editor/text/highlighter.py`
  - Import and initialize Tree-sitter highlighter for Python files.
  - Add methods to highlight text content using Tree-sitter and Pygments as a fallback.

* **Update**: `src/biscuit/editor/editor.py`
  - Import the Highlighter class.

* **Update**: `README.md`
  - Add documentation for Tree-sitter highlighter and Pygments fallback.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/tomlin7/biscuit/issues/398?shareId=XXXX-XXXX-XXXX-XXXX).
@tomlin7 tomlin7 linked a pull request Nov 4, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed language features syntax highlighting, lsp, other language features suggestions needed bugs/features that are still not figured out and need solution suggestions text editor Related to text editor's features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant