| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- -- Lumacs Configuration File
- -- This file is executed on startup and allows you to customize keybindings,
- -- create commands, and extend the editor with Lua.
- print("Loading init.lua...")
- -- Example: Custom keybindings
- -- Syntax: bind_key("key", function() ... end)
- -- Emacs-style navigation (Ctrl+N/P for next/previous line)
- bind_key("C-n", function()
- editor:move_down()
- message("Moved down")
- end)
- bind_key("C-p", function()
- editor:move_up()
- message("Moved up")
- end)
- bind_key("C-f", function()
- editor:move_right()
- end)
- bind_key("C-b", function()
- editor:move_left()
- end)
- -- Emacs-style line navigation
- bind_key("C-a", function()
- editor:move_to_line_start()
- end)
- bind_key("C-e", function()
- editor:move_to_line_end()
- end)
- -- Custom command: Save buffer
- bind_key("C-s", function()
- local buf = editor:buffer()
- if buf:save() then
- message("Buffer saved: " .. buf:name())
- else
- message("Failed to save buffer")
- end
- end)
- -- Custom command: Insert timestamp
- bind_key("C-t", function()
- local cursor_pos = editor:cursor()
- local timestamp = os.date("%Y-%m-%d %H:%M:%S")
- editor:buffer():insert(cursor_pos, timestamp)
- message("Inserted timestamp")
- end)
- -- Example: Helper functions you can define
- function goto_line(line_num)
- local pos = lumacs.Position(line_num - 1, 0)
- editor:set_cursor(pos)
- message("Jumped to line " .. line_num)
- end
- -- Example: Buffer inspection
- function buffer_info()
- local buf = editor:buffer()
- local cursor = editor:cursor()
- message(string.format(
- "Buffer: %s | Lines: %d | Cursor: %d,%d | Modified: %s",
- buf:name(),
- buf:line_count(),
- cursor.line + 1,
- cursor.column + 1,
- buf:is_modified() and "yes" or "no"
- ))
- end
- -- Bind to show buffer info
- bind_key("C-i", buffer_info)
- -- Welcome message
- message("Lumacs initialized! Press C-i for buffer info, C-s to save.")
|