Re: [code] [textadept] Custom lexer + theme + file extension, all portable

From: Mitchell <>
Date: Thu, 30 May 2019 11:04:32 -0400 (EDT)

Hi Lukas,

On Thu, 30 May 2019, Procházka Lukáš Ing. wrote:

> Hello,
> I am struggling a bit with lexer and theme.
> I'm using TA as portable, so my all extensions, experiments, tests and so are
> located in dir "d:\Lukas\Miscell\TextAdept".
> Also, I'm always running TA with -u option, i.e. "textadept.exe -u
> d:\Lukas\Miscell\TextAdept".
> So here I have init.lua (d:\Lukas\Miscell\TextAdept\init.lua).
> Suppose I'd like to create a lexer "MyLexer" to be associated with extension
> ".MyExt" and buffers with "MyLexer" to be shown using "MyTheme" colors.
> 1. Where should I put the lexer? Into:
> a) d:\Lukas\Miscell\TextAdept\lexers\MyLexer.lua or
> b) d:\Lukas\Miscell\TextAdept\modules\MyLexer.lua or
> c) whereever, but 'package.path' must be adopted so that TA is able
> to locate "MyLexer.lua"?

Textadept looks for lexers in `_USERHOME..'/lexers'`, so option (a).

> 2. Do I have load MyLexer explicitly (in the scope of
> d:\Lukas\Miscell\TextAdept\init.lua) or does TA load MyLexer automatically
> due to its placing in d:\Lukas\Miscell\TextAdept\lexers (or another dir)?

No, Textadept does this automatically.

> 3. How do I associate MyLexer with files with .MyExt extension?
> Note that in , section "Using
> Lexers", "Textadept", before "Migrating Legacy Lexers", there is a broken
> link .
> a) Somehow in d:\Lukas\Miscell\TextAdept\init.lua working with
> textadept.file_types.patterns?
> b) Handling events.BUFFER_NEW event in
> d:\Lukas\Miscell\TextAdept\init.lua?

> 4. How do I apply MyTheme to buffer of a file of .MyExt?
> - Is the theme related to lexer, so when I associate MyTheme with
> MyLexer (how?), buffers are colored appropriately?

Textadept does not support per-buffer themes. You could try setting the theme using[1], but I don't know if it would work reliably. You could also manually set styles on a per-language basis[2], which will probably work better.

Textadept themes define properties like colors and styles. The lexer then references these properties when it runs.



You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Thu 30 May 2019 - 11:04:32 EDT

This archive was generated by hypermail 2.2.0 : Fri 31 May 2019 - 06:26:54 EDT