Open alerque opened 4 years ago
@pkulchenko I'm curious if you have any pointers for me given your experience with Lua and editors. Never-mind wining it up to vim, is doing syntax highlighting from a PEG grammar even feasible? Is this a hair-brained idea?
@alerque, scintillua does this quite successfully, but it relies on Scintilla to do the actual rendering of the highlighted components (so it does the lexing itself and plugs into Scintilla to report the parts that need to be highlighted). I've integrated that into ZeroBrane Studio and also did custom LPEG-based lexers in Lua.
So, I think the answer to your question is "yes", it's possible, but you'd need to find a way to report the result of the parsing back to the editor for styling. It may even be possible to modify lexer.lua from scintillua to generate the structures that neovim expects.
Right now the syntax level supported by this plugin sucks. I can of course keep working on the regular expressions and make them a lot better. However before I do that it occurred to me...
Both vim an neovim support Lua based plugins, with the latter having very good support. SILE is written in Lua and the TeX-like grammar is already being parsed in PEG to an AST with position information.
Would it be possible to either call out to SILE or rip out the LPEG work and reuse it for this syntax plugin? The biggest issue that comes to mind is that any syntax errors will cause the whole thing to die. Are there other issues? Is there even a way to wire this up?