orbitalquark / scintillua

Scintillua enables Scintilla lexers to be written in Lua, particularly using LPeg. It can also be used as a standalone Lua library for syntax highlighting support.
https://orbitalquark.github.io/scintillua
MIT License
52 stars 22 forks source link

Additional highlighting for c++ lexer #85

Closed snoopy closed 1 year ago

snoopy commented 1 year ago

I'd like to know your thoughts on some possible additional highlighting options.

Currently the lexer will highlight namespaces if they are part of an STL type (e.g. std::vector). Other editors seem to highlight all namespaces regardless. So in foo::bar::foobar() foo and bar would be highlighted in a to-be-defined namespace color and foobar would be a normal function highlight. Would this be a possibility for TA as well?

Should values in angle brackets always be highlighted as type? Consider std::vector<Foo>, here Foo is a custom type and could be highlighted as such.

orbitalquark commented 1 year ago

It is a possibility to do both, but one thing I'd like to have is consistency in highlighting. For example, the "foo" and "bar" namespace definitions (and optionally in "using namespace " statements) should also be highlighted the same. Likewise, all appropriate instances of "Foo" should be highlighted as a type (e.g. in its class definition and any type declarations), not just within the angle brackets. I'd like to avoid having the same identifier highlighted differently during its lifetime.

This may require more a accurate syntactic analysis, which may not be possible/feasible.

snoopy commented 1 year ago

This may require more a accurate syntactic analysis, which may not be possible/feasible.

I figured as much. Doing this with just the lpeg lexer sounds a bit tricky. It would probably need something like https://github.com/tree-sitter/tree-sitter and I assume that is out of scope.

orbitalquark commented 1 year ago

Tree Sitter is out of scope for Scintillua, but I have been experimenting with it in another project: https://github.com/orbitalquark/tslexia. I'm not sure if anything will come of it though. The shared object for just one parser is larger than all of Scintillua's Lua lexers...

snoopy commented 1 year ago

Thanks, very interesting.

I'll go ahead and close this since the suggestions are not really feasible IMO.