Re: [code] [Textadept] Enriching Lua highlighting, have some questions

From: Mitchell <>
Date: Mon, 31 Mar 2014 15:00:18 -0400 (Eastern Daylight Time)

Hi Advert,

On Sat, 29 Mar 2014, Advert Slaxxor wrote:

> I'm thinking about adding some features to Textadept's Lua lexer and
> module, but I was wondering if anyone has attempted (or done) this before.
> I'm also looking for some feedback, suggestions, and the like :)
> What I'm looking to do is:
> - Add more tokens, for styling/highlighting/coloring (I'll call this
> 'styling' from now on) different things. (i.e `and not or` -> different
> style than `false nil true` -- I've already tested the waters by doing
> this, it was surprisingly easy, thanks to the great documentation!)
> - Style 'fields' (table.<field>), locals, 'surprise globals' (unknown to
> the editor, i.e one-line file: `print(x)` -- `x` would be a 'surprise
> global', since it's referenced before it's assigned), and globals
> differently from one another.
> - Think about more stuff to do once this is done. There's lots I want to
> mess around with, but the above are probably the most useful/practical.
> My plan of attack so far:
> - Make the lexer strict. My problem with this is that the current one does
> not track state, except for when it's doing embedded lexers.
> - Lots of new tokens. Need to name them reasonably, but that'll be the easy
> part :)
> - Generate AST from the lexer, somehow. Maybe just use the token stream to
> generate AST.
> This shouldn't be necessary if the lexer can keep state, but there's so
> much fun stuff that's possible with AST.
> Does this look good? Is there anything I'm missing? How about features you
> would like to see added? Maybe it's too bloat-y? (though, I don't mind
> going all out on styling/inspection)

I think the idea is good in principle and quite useful. However, marking
text based on context using a lexer is probably not the best idea. For
performance reasons, lexers are only given parts of the entire buffer to
lex at a time. A better method for you would probably be to have a
function process the entire buffer and use indicators to mark text instead
of using lexer styles. This function could be run in an interval, when the
buffer is saved, etc.

Textadept's source code has examples of indicator use for marking text.


You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Mon 31 Mar 2014 - 15:00:18 EDT

This archive was generated by hypermail 2.2.0 : Tue 01 Apr 2014 - 06:37:50 EDT