A Docker-based isolated environment for Ruby developers to experiment with Neovim configuration using Lua, without affecting your current Neovim setup.
This project creates a Docker container with Neovim, Ruby, and essential Ruby development tools, allowing you to:
- Test Neovim configurations for Ruby development
- Use Lua for plugin management and configuration
- Keep your local Neovim setup untouched
- Share and reproduce the Ruby development environment across different machines
- Ruby-focused setup: Solargraph LSP, Rubocop linting, and Ruby-aware autocompletion
- Modern autocompletion: nvim-cmp with LSP, buffer, path, cmdline, and Lua sources
- Diagnostics and search: Telescope integration for diagnostics, files, and more
This environment is specifically configured for Ruby development with:
- Ruby LSP: Solargraph for intelligent code completion, go-to-definition, and refactoring
- Ruby Linting: Rubocop integration for code style and quality checks
- Modern Plugin Manager: lazy.nvim for efficient plugin management
- Autocompletion: nvim-cmp with Ruby-aware completion powered by Solargraph
- Fuzzy Search: Telescope for file navigation, diagnostics, and Ruby-specific searches
- Diagnostics: Real-time error highlighting and inline diagnostics from both LSP and Rubocop
The easiest way to test this Neovim setup for Ruby development is using the provided Makefile commands:
Run make help to see all available commands:
make help-
Build the Docker image (first time only):
make build
-
Test with a Ruby project (recommended):
# Mount a specific Ruby project NVIM_WORKSPACE=/path/to/your/ruby/project make nvim # Or use your home directory (default) make nvim
-
Open a shell for testing:
# Mount a specific Ruby project NVIM_WORKSPACE=/path/to/your/ruby/project make shell # Or use your home directory (default) make shell
Once inside Neovim (via make nvim), test these Ruby development features:
-
Open a Ruby file:
:e /workspace/your_ruby_file.rb
-
Test autocompletion: Type Ruby code and use
<Tab>or<C-Space>for completions -
Test LSP features:
gd- Go to definitiongr- Go to referencesK- Show documentation
-
Test diagnostics: Look for inline error highlighting and use
:Telescope diagnosticsto see all issues -
Test Rubocop integration: Save a file and check for style violations
-
Check health: Run
:checkhealthto verify all components are working
The Makefile automatically mounts your workspace:
- If
NVIM_WORKSPACEis set, that path is mounted at/workspace - If not set, your home directory (
$HOME) is mounted at/workspaceby default
This allows you to edit Ruby files from your host system inside the Docker container.
- Docker installed on your system
- Docker Compose installed on your system
git clone <your-repo-url>
cd nvim-docker# Build the Docker image (first time only)
make build
# Test with a Ruby project
NVIM_WORKSPACE=/path/to/your/ruby/project make nvim
# Or test with your home directory
make nvimThat's it! You're now testing the Neovim setup for Ruby development.
nvim_docker/
├── Dockerfile # Docker image definition
├── docker-compose.yml # Docker Compose configuration
├── nvim_config/ # Your Neovim configuration (mounted as volume)
└── README.md # This file
The Dockerfile compiles Neovim from source on top of Ubuntu 22.04, ensuring compatibility with all processor architectures (including ARM64/Apple Silicon and x86_64).
Dependencies installed include:
- Git, curl, ninja-build, gettext, cmake
- Build tools (build-essential)
- ca-certificates
- ripgrep (for fast text searching with Telescope)
Neovim is cloned from the official GitHub repository and built during the image build process. This approach avoids issues with pre-built binaries and ensures the latest stable version is used, regardless of your host architecture.
To build the image:
docker build --no-cache -t nvim-lua .The docker-compose.yml file:
- Maps your local
nvim_config/directory to/home/nvimuser/.config/nvimin the container - Creates a non-root user for security
- Sets up interactive terminal support
- Configures the working directory
docker compose run --rm nvim-serviceAnd from within the container, run:
nvimYou can mount any local folder into the container at /workspace by setting the NVIM_WORKSPACE environment variable. This allows you to use Neovim inside Docker with any project or directory from your host system.
- If
NVIM_WORKSPACEis set, that path will be mounted at/workspaceinside the container. - If
NVIM_WORKSPACEis not set, your home directory ($HOME) will be mounted at/workspaceby default.
Examples:
- Mount a specific project folder:
NVIM_WORKSPACE=/Users/youruser/projects/myproject make nvim
- Use your home directory (default):
make nvim
Inside Neovim (in Docker), you can then open files from /workspace as needed.
This makes the setup flexible and user-friendly for different workflows and users.
- Terminal color scheme (iTerm2, Terminal, etc.): Controls the base colors of the terminal background, text, and ANSI colors. This affects all terminal applications, including Neovim.
- Neovim color scheme (via plugins like lazy.nvim): Controls how Neovim colors code, UI, and background. Examples:
tokyonight,gruvbox, etc.
If you have termguicolors enabled in your Neovim config (which is recommended and already set in this setup), Neovim will use truecolor (24-bit) and display its themes as intended, regardless of the terminal's color scheme—as long as your terminal supports truecolor.
Recommendation:
- For the best visual experience with modern Neovim themes, use a terminal with full truecolor support, such as iTerm2, Alacritty, or Kitty.
- The default Terminal app on macOS may display colors differently or less vibrantly, even with
termguicolorsenabled. - You do NOT need to match your terminal's color scheme to your Neovim theme if you use truecolor.
Summary:
- Use a modern terminal with truecolor support for the best Neovim appearance.
termguicolorsshould be enabled in your Neovim config (already set).- Neovim's theme will look the same inside and outside Docker, provided your terminal supports truecolor.
Place your Neovim configuration files in the nvim_config/ directory:
nvim_config/
├── init.lua # Main Neovim configuration
├── lua/
│ ├── plugins.lua # Plugin definitions
│ ├── keymaps.lua # Key mappings
│ └── settings.lua # Editor settings
└── after/
└── plugin/ # Plugin-specific configurations
Ensure the volume mapping is correct in docker-compose.yml:
volumes:
- ./nvim_config:/home/nvimuser/.config/nvimThe container runs as a non-root user (nvimuser). If you encounter permission issues, check that the nvim_config/ directory has appropriate permissions.
- Mount your Ruby project: Use
NVIM_WORKSPACE=/path/to/ruby/project make nvim - Edit Ruby files: Open files from
/workspaceinside Neovim - Test Ruby features: Use autocompletion, LSP navigation, and Rubocop linting
- Iterate configuration: Modify files in
nvim_config/and test withmake nvim - Share setup: Commit your configuration to version control for team sharing
To use this setup on another machine:
- Clone this repository
- Ensure Docker and Docker Compose are installed
- Run the setup commands:
docker build -t nvim-lua . mkdir -p nvim_config docker compose run --rm nvim-service
Feel free to submit issues and enhancement requests!
[Add your license here]