Textadept’s Userhome

A quick example on how to keep sanity in configurations.


A little while has passed since the last piece on the TGTT. Textadept has had quite a number of revisions since then. We seen the text-editor refine what it already could do and bring new horizons of features. So let's go right ahead to part V of “The Ever Expanding Series On Textadept Guides, Tips, And Tricks:" Textadept's Userhome and help explain another useful ability.

Kind of a weird place to look at, but the userhome can be a devil's advocate for Textadept. It holds the deepest darkest secrets of your mess … er… configurations, in which you have become accustomed to. If you are like me, fellow reader, you may have felt horror touching that cavern that is your userhome. One small line change and the whole universe may implode on you! Well, dear internet friend, let’s rectify this wrong! Your Textadept home should be a sanctuary of work. A place you give homage to your brilliant settings you so cautiously produced. It should hold a level of perfection you are proud of showing to the world!

However, to get to this stage of your userhome, you first must travel the mountains known as modulation. Textadept’s use of Lua for all things means you don't have to make your init.lua the one file to rule them all of your editor. In fact, due to the nature of Lua, you should really take the time to string your thoughts into singlets of small Lua scripts, commonly known as modules in Lua space. Doing so, when you do (not if) cause the Armageddon, because you so handsomely forgot to add a comma, you can narrow down the issue with prejudice to one simple line in one simple file. Thus, if you agree with me, let's get to it and make your consciously smart decision of a modulized userhome.

Example of init.lua module.

The main idea you should follow here is to keep your init.lua file as your initializer. What I mean is, only use the file to load modules and primitive settings you have for Textadept. This also means that your init.lua file is going to be as barebone as you can possibly get it. You don’t want to have anything that looks like work here! You will have all those things still producing dragons, but moved to allocated separate “safer” modules.

Now that we got the initializer idea for the init.lua file, let us figure out what we should put where. This is the easy step in my opinion. For my preference, I put all similar configurations grouped into one module. As an example, remapped or global shortcuts would all go to keymap.lua, file extensions for auto recognizing would fall under extensions.lua, and etc. It’s a convention that makes easier changesets for you to manipulate and easier to navigate when the errors come.

All those split up modules should also be globally allocated. This is one of those rare moments I’m advising something normally told to be a nono in Lua. I’m telling you here, you may want to have your module require calls globally defined instead of locally defined. The reason is simple: all of these new files will be changing settings globally defined by Textadept anyhow. While you can have these modules locally scoped and unless you want to use those same names for other modules/functions, it doesn't really make sense to allocate them as local scoped modules when the configurations are changing global scoped settings in Textadept. Due note, even though I’m advising global scoped populace here, you still should follow the local scope method of Lua, when writing the configurations into the modules.

With all this said, one exception which has yet to be truly modulized for me in the userhome; properties.lua. The module is still a mysterious dungeon I’ve yet to venture through. It may be out of laziness, but it has stayed an organized configuration mess… I have however made the semantic highlighting portion a module on its own. I’ll probably modulize the hell out of the file too. For now though, the configurations stay safe from this modulized userhome project I have been proposing.

I hope the discussion on the modulation of the userhome helped explain a little on ease in configuration of Textadept. If you want more examples, then don’t fear to take a venture at my userhome: