What
Use parser written in c/cpp, such as tree-sitter, to perform highlight and expansion of selection.
Why
- Given language, current component of syntax highlight recognize its keyword only.
- Structural editing for code is missing.
How
Prepared by community
An interface to load dynamic library, so that parser written in c can be loaded and imported from shared library. Shared library can be shipped in plugin.
Required work
- Provide parser of language as plugin.
- Import parser generated by tree-sitter as c source code.
- Parse given code (textual) into Abstract Syntax Tree, and highlight code from AST, rather than current
highlight_observer
.
noticeable APIs:
attach_highlight
highlight_observer
observer_rep::set_highlight
-
language
language::has_highlight
language::highlight
Bonus work
- Structural navigation of cursor, consistent with other parts.
- Edit code can make change to AST, such as semantic insertion and deletion.
- Format code according to AST.
- Highlight or edit code from other APIs.
Works not included
- Highlight or edit code from LSP mentioned by @Oyyko. Because LSP may take effect on a whole project or a bunch of files, but such structure is not included in Mogan, thus LSP is overkilled for current highlighting usage.
- incremental highlight. According to current interface, all text needing highlighted is provided to
language
interface, but increment is not provided.