README
¶
gmacs Test Package Plugin
A comprehensive Ruby language support plugin for the gmacs editor.
Features
- Syntax Checking: Basic Ruby syntax validation
- Code Formatting: Automatic indentation and formatting
- Documentation Lookup: Built-in Ruby documentation
- REPL Integration: Evaluate Ruby code (mock implementation)
- Navigation: Go to definition support (mock implementation)
- Testing: Run Ruby tests (mock implementation)
- Configuration: Customizable settings
Installation
Add this to your ~/.config/gmacs/init.lua:
gmacs.use_package("github.com/TakahashiShuuhei/gmacs-test-package", "v1.0.0")
Usage
Basic Configuration
-- Configure Ruby mode settings
gmacs.after_packages_loaded(function()
if gmacs.ruby then
-- Set indentation
gmacs.ruby.set_config("indent_size", 2)
gmacs.ruby.set_config("use_spaces", true)
gmacs.ruby.set_config("auto_end", true)
-- Enable syntax highlighting
gmacs.ruby.set_config("highlight_syntax", true)
end
end)
Key Bindings
gmacs.after_packages_loaded(function()
if gmacs.ruby then
-- Ruby-specific key bindings
gmacs.global_set_key("C-c C-c", "ruby-eval")
gmacs.global_set_key("C-c C-d", "ruby-show-doc")
gmacs.global_set_key("C-c C-f", "ruby-format-code")
gmacs.global_set_key("C-c C-t", "ruby-run-tests")
gmacs.global_set_key("C-c C-g", "ruby-goto-definition")
end
end)
Custom Commands
You can create custom commands that use Ruby mode functionality:
gmacs.after_packages_loaded(function()
if gmacs.ruby then
-- Custom command to check Ruby syntax
function check_ruby_syntax()
local current_buffer = gmacs.current_buffer()
if current_buffer then
local content = current_buffer.content or ""
local issues = gmacs.ruby.check_syntax(content)
if #issues > 0 then
for _, issue in ipairs(issues) do
gmacs.message("Syntax issue: " .. issue)
end
else
gmacs.message("No syntax issues found!")
end
end
end
gmacs.register_command("ruby-check", check_ruby_syntax, "Check Ruby syntax")
gmacs.global_set_key("C-c C-s", "ruby-check")
-- Custom command to format current buffer
function format_ruby_buffer()
local current_buffer = gmacs.current_buffer()
if current_buffer then
local content = current_buffer.content or ""
local formatted = gmacs.ruby.format_code(content)
gmacs.message("Buffer formatted!")
-- In real implementation, this would replace buffer content
end
end
gmacs.register_command("ruby-format", format_ruby_buffer, "Format Ruby code")
end
end)
Available Functions
Syntax and Formatting
gmacs.ruby.check_syntax(code)- Check Ruby code for syntax issuesgmacs.ruby.format_code(code)- Format Ruby code with proper indentation
Documentation and Help
gmacs.ruby.show_doc(symbol)- Show documentation for a Ruby symbol
Development Tools
gmacs.ruby.eval(code)- Evaluate Ruby code (mock)gmacs.ruby.goto_definition(symbol)- Find symbol definition (mock)gmacs.ruby.run_tests([file])- Run Ruby tests (mock)
Configuration
gmacs.ruby.set_config(key, value)- Set configuration optiongmacs.ruby.get_config(key)- Get configuration option
Configuration Options
indent_size(number): Number of spaces for indentation (default: 2)use_spaces(boolean): Use spaces instead of tabs (default: true)auto_end(boolean): Automatically add 'end' keywords (default: true)highlight_syntax(boolean): Enable syntax highlighting (default: true)
Example Configuration
Complete example for ~/.config/gmacs/init.lua:
-- Load Ruby mode
gmacs.use_package("github.com/TakahashiShuuhei/gmacs-test-package", "v1.0.0")
-- Configure Ruby mode after packages are loaded
gmacs.after_packages_loaded(function()
if gmacs.ruby then
-- Configuration
gmacs.ruby.set_config("indent_size", 2)
gmacs.ruby.set_config("use_spaces", true)
gmacs.ruby.set_config("auto_end", true)
-- Key bindings
gmacs.global_set_key("C-c r c", "ruby-check-syntax")
gmacs.global_set_key("C-c r f", "ruby-format")
gmacs.global_set_key("C-c r d", "ruby-doc")
gmacs.global_set_key("C-c r t", "ruby-test")
-- Custom commands
function ruby_check_syntax()
local word = gmacs.current_word()
local issues = gmacs.ruby.check_syntax(word)
gmacs.message("Found " .. #issues .. " syntax issues")
end
function ruby_show_help()
local word = gmacs.current_word()
local doc = gmacs.ruby.show_doc(word)
gmacs.message(doc)
end
function ruby_run_all_tests()
local result = gmacs.ruby.run_tests()
gmacs.message(result)
end
gmacs.register_command("ruby-check-syntax", ruby_check_syntax, "Check Ruby syntax")
gmacs.register_command("ruby-doc", ruby_show_help, "Show Ruby documentation")
gmacs.register_command("ruby-test", ruby_run_all_tests, "Run Ruby tests")
gmacs.message("Ruby mode loaded and configured!")
end
end)
Requirements
- gmacs editor with plugin support
- Go 1.21+ (for building the plugin)
- Linux, macOS, or FreeBSD (plugin loading not supported on Windows)
Development
This plugin is built using the gmacs plugin system. The main implementation is in ruby_mode_plugin.go.
Building
The plugin is automatically built by gmacs when first loaded. Manual building:
go build -buildmode=plugin -o ruby_mode.so ruby_mode_plugin.go
Testing
Test the plugin functionality:
go test -v
License
MIT License - see LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
Support
- Issues: GitHub Issues
- Documentation: gmacs Plugin Documentation
Documentation
¶
There is no documentation for this package.
Click to show internal directories.
Click to hide internal directories.