Lumacs provides a powerful Lua scripting API for configuration and extensibility, inspired by Emacs but using Lua instead of Elisp.
Lumacs loads init.lua from one of these locations (in order):
./init.lua (current directory)~/.config/lumacs/init.lua~/.lumacs/init.luaeditor (EditorCore)The main editor instance.
Properties:
editor:buffer() - Returns the current Buffereditor:cursor() - Returns current Positioneditor:set_cursor(pos) - Set cursor positionMethods:
editor:move_up() - Move cursor upeditor:move_down() - Move cursor downeditor:move_left() - Move cursor lefteditor:move_right() - Move cursor righteditor:move_to_line_start() - Move to start of lineeditor:move_to_line_end() - Move to end of lineeditor:load_file(path) - Load a fileeditor:quit() - Quit the editorlumacs (module)Module namespace.
Classes:
lumacs.Position(line, column) - Create a cursor positionReturned by editor:buffer().
Properties:
buffer:name() - Get buffer namebuffer:line_count() - Get number of linesbuffer:is_modified() - Check if modifiedbuffer:content() - Get entire content as stringMethods:
buffer:line(index) - Get line by index (0-based)buffer:insert(pos, text) - Insert text at positionbuffer:insert_char(pos, char) - Insert single characterbuffer:insert_newline(pos) - Insert newlinebuffer:erase_char(pos) - Delete character (backspace)buffer:save() - Save buffer to fileRepresents a cursor position.
Constructor:
local pos = lumacs.Position(line, column)
Fields:
pos.line - Line number (0-based)pos.column - Column number (0-based)bind_key(key, callback)Bind a key to a Lua function.
Key names:
"a", "b", "1", etc."Escape", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Home", "End""C-a", "C-s", "C-c", etc.Example:
bind_key("C-s", function()
editor:buffer():save()
message("Buffer saved!")
end)
message(text)Display a message to the user (appears in stderr).
message("Hello from Lua!")
print(...)Print to stderr (stdout is used by TUI).
print("Debug info:", value)
-- Emacs-style navigation
bind_key("C-n", function() editor:move_down() end)
bind_key("C-p", function() editor:move_up() end)
bind_key("C-f", function() editor:move_right() end)
bind_key("C-b", function() editor:move_left() end)
bind_key("C-a", function() editor:move_to_line_start() end)
bind_key("C-e", function() editor:move_to_line_end() end)
-- Save buffer
bind_key("C-s", function()
if editor:buffer():save() then
message("Saved!")
else
message("Failed to save")
end
end)
-- Insert timestamp
bind_key("C-t", function()
local timestamp = os.date("%Y-%m-%d %H:%M:%S")
editor:buffer():insert(editor:cursor(), timestamp)
end)
-- Custom functions
function goto_line(n)
editor:set_cursor(lumacs.Position(n - 1, 0))
end
message("Lumacs configured!")
Coming soon:
print() for debugging (output goes to stderr)init.lua for more ideas