This feature is still under development

Lua

Embedded Lua Scripting

1. Support

Since: NeoMutt 2017-04-14

Dependencies: None

2. Introduction

Lua is a simple scripting language that's frequently embedded into other programs, such as NeoVim. It allows users to cusotomise the behaviour of the host program.

In NeoMutt, Lua can used to get/set config options and run commands.

3. Commands

lua "lua-commands"

lua-source filename

4. Usage

A simple example of running some Lua commands in NeoMutt.

# In NeoMutt, make the Sidebar wider
:lua "local x = mutt.get('sidebar_width'); x = x + 5; mutt.set('sidebar_width', x)"

Next, create a script for easier reuse.

Create a local Lua script, sw.lua

-- Make the sidebar wider
function sw()
  local width = mutt.get('sidebar_width')
  width = width + 5
  mutt.set('sidebar_width', width)
end

Alter your NeoMutt config to add:

# Load the script once
lua-source "sw.lua"

# Create a binding to run the function in the script
macro index <F1> "<enter-command>lua 'sw()'<enter>

5. Limitations

Currently, the Lua Scripting is very limited. It doesn't have any way to interact with the objects within NeoMutt: the Mailboxes, the Emails, etc. Beyond that, there's almost zero documentation.

This state is changing. There is some new work coming to NeoMutt that exposes the Accounts, Mailboxes and Emails to Lua. This would allow the user to perform meaningful actions.

See: https://github.com/neomutt/neomutt/pull/4707

6. Credits

Richard Russon, Bernard Pratz, Rayford Shireman, Darshit Shah

Search by Algolia