AVIM is a custom text editor built inside the ComputerCraft/CC:Tweaked mod for Minecraft. It emulates the functionality and feel of Neovim, offering features like keybindings, visual mode, command execution, and plugin support, all within the limited environment of ComputerCraft.
- Modal Editing: Just like Vim, AVIM operates in different modes (
Normal
,Visual
,Insert
,Command
). - Custom Keybindings: Map your own keybindings in different modes to create a personalized workflow.
- Plugins: AVIM supports plugins, allowing users to extend its functionality.
- Command Execution: Use the command mode to execute commands, search, and replace text.
- Syntax Highlighting: AVIM has autocompletion and syntax highlighting built right in!
- Download AVIM: Use one of the following methods to install avim the intended way:
(Manual Install)
wget https://gist.githubusercontent.com/SquidDev/e0f82765bfdefd48b0b15a5c06c0603b/raw/clone.min.lua
git/clone.min https://github.com/arismoko/avim.git
mv avim _avim-files
mv _avim-files/avim avim
avim
or
(Recommended Install)
pastebin get ZsJWP7fr install_avim
install_avim
avim
- Load Plugins: Customize the plugins by editing the
plugins/pluginConfig.lua
file.
Launch the editor by running the main AVIM script. You will be greeted with a simple menu where you can create or open files, manage plugins, or exit the program.
-- Code snippet from the main menu:
local function handleMainMenu()
print("Welcome to AVIM")
print("1. Create New File")
print("2. Open File")
print("3. Manage Plugins")
print("4. Quit")
end
AVIM supports customizable keybindings in different modes. Here is how you can define a keybinding:
-- Example keybinding: Move left in Normal and Visual modes
KeyHandler:map({"n", "v"}, "h", function()
CommandHandler:execute("move_left")
end, "Move Left")
- Modes:
"n"
(Normal),"v"
(Visual),"i"
(Insert),"c"
(Command). - Key Sequence:
"h"
in this case. - Callback: The function to execute when the key is pressed.
- Description: A short description of what the keybinding does.
-
Move to the Top of the File:
KeyHandler:map({"n", "v"}, "g + g", function() CommandHandler:execute("move_to_top") end, "Move to Top")
-
Cut Line:
KeyHandler:map("n", "d + d", function() CommandHandler:execute("cut_line") end, "Cut Line")
-- Enter Visual Mode
KeyHandler:map("n", "v", function()
CommandHandler:execute("enter_visual_mode")
end, "Enter Visual Mode")
Commands are the backbone of AVIM's functionality. Here's how you can create and map commands.
-- Example Command: Move Cursor Left
CommandHandler:map("move_left", function()
Model.cursorX = math.max(1, Model.cursorX - 1)
end)
- Command Name:
"move_left"
in this example. - Callback: The function that defines the command’s behavior.
-
Search for Text:
CommandHandler:map("search", function(pattern) -- Logic for searching text end)
-
Yank (Copy) a Line:
CommandHandler:map("yank_line", function() Model:yankLine() end)
AVIM supports plugins, allowing users to extend the editor's functionality. Plugins are Lua modules that are loaded based on a configuration file.
-- Load plugin configuration
local pluginConfigFile = "plugins/pluginConfig.lua"
if fs.exists(pluginConfigFile) then
plugins = require("plugins.pluginConfig")
end
Each plugin must have an init
function that is called upon loading:
-- Example Plugin Initialization
function plugin.init(components)
-- Plugin logic here
end
Plugins can be enabled or disabled through a configuration file:
-- Example plugin configuration
plugins = {
{name = "fileExplorer", enabled = true},
{name = "autocomplete", enabled = false},
}
This plugin provides a simple file explorer interface within AVIM.
local function openFileExplorer()
local files = fs.list(shell.dir())
table.sort(files)
-- Logic to display files and handle navigation
end
KeyHandler:map("n", "backslash", function()
openFileExplorer()
end, "Open File Explorer")
## Contributions
Feel free to contribute to AVIM by submitting issues or pull requests on our GitHub repository. Contributions can include new features, plugins, bug fixes, or improvements to documentation.
---
**AVIM** brings the power of modal text editing to ComputerCraft, combining the flexibility of Vim with the extensibility of Lua in a Minecraft environment. Explore, customize, and enhance your text editing experience with AVIM!