Use Vim as a Ruby IDE
This is a general guide for using SpaceVim as a Ruby IDE, including layer configuration and usage.Each of the following sections will be covered:
- Enable language layer
- Code completion
- Syntax linting
- Jump to test file
- running code
- Code formatting
- REPL support <!-- vim-markdown-toc --> ### Enable language layer
To add Ruby language support in SpaceVim, you need to enable the lang#ruby
layer. Press SPC f v d
to openSpaceVim configuration file, and add the following snippet:
[[layers]]
name = "lang#ruby"
For more info, you can read the lang#ruby layer documentation.
Code completion
lang#ruby
layer will load the Ruby plugin automatically, unless itβs overriden in your init.toml
.The completion menu will be opened as you type.
Syntax linting
The checkers layer is enabled by default. This layer provides asynchronous syntax linting via neomake.It will run rubocop asynchronously.
Install rubocop via gem:
gem install rubocop
Jump to test file
SpaceVim use built-in plugin to manager the files in a project, you can add a .project_alt.json
to the root of your project with the following content:
{
"src/*.rb": {"alternate": "test/{}.rb"},
"test/*.rb": {"alternate": "src/{}.rb"}
}
With this configuration, you can jump between the source code and test file via command :A
running code
To run current script, you can press SPC l r
, and a split windowwill be openen, the output of the script will be shown in this window.It is running asynchronously, and will not block your Vim.
Code formatting
The format layer is also enabled by default. With this layer you can use key binding SPC b f
to format current buffer.Before using this feature, please install rufo:
gem install rufo
REPL support
Start a irb
inferior REPL process with SPC l s i
. After the REPL process being started, you cansend code to inferior process. All key bindings prefix with SPC l s
, including sending line, sending selection or evensend whole buffer.
Top comments (3)
I do love VIM. Never heard of SpaceVim until now.
Uncertain if I would give it a run since I'm a MacVim user and I always stick with Janus.
I tried moving my plugin set to Vundle or Pathogen but seem to lose functionality along the way.
Uncertain if SpaceVim is just a plugin manager that is much more user-friendly and the plugins are tweaked to work out of the box together seamlessly.
SpaceVim is just like junes. but has many differences. to add your plugins, you can use custom_plugin in config file.
for More discussion, you can join spacevim community.
If its just like Janus, I guess I can just stick with what I have. good to know.