Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/orbitalquark/tslexia
A Scintilla lexer that makes use of Tree-sitter parsers
https://github.com/orbitalquark/tslexia
lexer lexers scintilla syntax-highlighting tree-sitter
Last synced: about 2 months ago
JSON representation
A Scintilla lexer that makes use of Tree-sitter parsers
- Host: GitHub
- URL: https://github.com/orbitalquark/tslexia
- Owner: orbitalquark
- License: mit
- Created: 2022-08-06T21:55:56.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-08-06T21:56:03.000Z (over 2 years ago)
- Last Synced: 2024-10-23T20:15:24.627Z (2 months ago)
- Topics: lexer, lexers, scintilla, syntax-highlighting, tree-sitter
- Language: C++
- Homepage:
- Size: 12.7 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TSLexia
TSLexia is a [Scintilla][] lexer that makes use of [Tree-sitter][] parsers.
[Scintilla]: https://scintilla.org
[Tree-sitter]: https://tree-sitter.github.io/tree-sitter## Compile
TSLexia requires only a C compiler and a C++ compiler that supports C++17.
make deps
make # or 'make win' for Windows dlls
make parsersThere are now *libtslexia.so* and *libtree-sitter-[name].so* (or *TSLexia.dll* and
*tree-sitter-[name].dll*) libraries you can use with your Scintilla application.## Usage
1. In your application, `#include "TSLexia.h"`.
2. Dynamically load the *libtslexia.so* or *TSLexia.dll* library if needed.
3. Call `CreateLexer()` with the path to a Tree-sitter parser,
e.g. `CreateLexer("/path/to/libtree-sitter-c.so")`. For multi-language
files or for parsers that depend on others, use a ';'-separated list of paths,
e.g. `CreateLexer("libtree-sitter-c.so;libtree-sitter-cpp.so")`. Make sure the order is from
generic to specific or parent to child.
4. Use the returned lexer with Scintilla's `SCI_SETILEXER` message to set it.
5. Use Scintilla's `SCI_SETKEYWORDS` message to pass in a Tree-sitter query file that matches
nodes and uses named captures for assigning styles to those nodes, e.g. `SendScintilla(sci,
SCI_SETKEYWORDS, 0, (sptr_t)"/path/to/tslexia/queries/c.scm")`. When using multiple parsers,
use the index of the parser passed to `CreateLexer()`.
6. Define style settings for TSLexia's `TSLEXIA_*` styles (see *TSLexia.h*).
7. That's it!