kentookura / tree-sitter-forester

tree-sitter grammar for forester
https://forester-tree-sitter-playground.netlify.app/
GNU General Public License v3.0
7 stars 2 forks source link

need to parse math part #1

Closed dannypsnl closed 8 months ago

dannypsnl commented 9 months ago

The \li in math expression #{\lim_{x \to 0} f(x)} also got highlighted as \li{...}.

kentookura commented 9 months ago

I wanted to set up language injections but didn't get around to it. When we have this set up we can get syntax highlighting for latex embedded in tree files

https://tree-sitter.github.io/tree-sitter/syntax-highlighting#language-injection https://github.com/DariusCorvus/tree-sitter-language-injection.nvim

dannypsnl commented 9 months ago

Another similar issue was \proof got parsed as \p as above; this is a defined block, I'm not sure if tree-sitter is able to solve these situations.

kentookura commented 9 months ago

Some of this is actually an issue with the queries which are part of the neovim plugin. Queries basically allow you to pattern match on a syntax tree, and the way I implemented them in forester.nvim is not particularly sophisticated yet (matching strings). The plan is to change the parser to use fields: https://tree-sitter.github.io/tree-sitter/creating-parsers#using-fields This will make pattern matching much easier and will alllow us to write better syntax highlighting

kentookura commented 8 months ago

See the new screenshot, the parser isn't perfect yet but much better than before