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:undo() - Undo last changeeditor:redo() - Redo last changeeditor:quit() - Quit the editorWindow Management:
editor:split_horizontally() - Split current window (Top/Bottom)editor:split_vertically() - Split current window (Left/Right)editor:close_window() - Close the active windoweditor:next_window() - Cycle focus to the next windowlumacs (module)Module namespace.
Classes:
lumacs.Position(line, column) - Create a cursor positionlumacs.Range(start_pos, end_pos) - Create a rangelumacs.TextAttribute(color, style) - Create a text attributeEnums:
lumacs.ColorType - Colors (Keyword, String, Comment, etc.)lumacs.Style - Styles (Normal, Bold, Italic, Underline)lumacs.BufferEvent - Events (Loaded, AfterChange, etc.)Returned 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 stringbuffer.language - Get/Set language string (e.g., "lua", "cpp")Methods:
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(range) - Delete a range of textbuffer:erase_char(pos) - Delete character (backspace)buffer:replace(range, text) - Replace text in a rangebuffer:find(query, start_pos) - Find text starting from position. Returns Range or nil.buffer:save() - Save buffer to fileStyling & Events:
buffer:set_style(range, attr) - Apply syntax highlightingbuffer:clear_styles() - Clear all stylesbuffer:on_buffer_event(callback) - Register an event listenerRepresents a cursor position.
Constructor:
local pos = lumacs.Position(line, column)
Fields:
pos.line - Line number (0-based)pos.column - Column number (0-based)Represents a text range.
Constructor:
local range = lumacs.Range(start_pos, end_pos)
Fields:
range.start - Start Positionrange.end - End Positionbind_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."M-a", "M-2", "M-ArrowUp", etc.Example:
bind_key("C-s", function()
editor:buffer():save()
message("Buffer saved!")
end)
message(text)Display a message to the user (appears in the minibuffer/status line).
message("Hello from Lua!")
print(...)Print to stderr (stdout is used by TUI).
print("Debug info:", value)
-- Window Management
bind_key("M-2", function() editor:split_horizontally() end)
bind_key("M-3", function() editor:split_vertically() end)
bind_key("M-0", function() editor:close_window() end)
bind_key("C-w", function() editor:next_window() end)
-- Search
bind_key("C-f", function()
-- Implementation using buffer:find()
end)
Press : to enter the command buffer. You can type Lua commands or editor shortcuts.
:w - Save:q - Quit:wq - Save and Quit:print(1+1) - Execute Lua codePlugins can react to editor events:
editor.buffer:on_buffer_event(function(event)
if event.event == lumacs.BufferEvent.Loaded then
print("File loaded: " .. event.language)
end
end)