Make Ruby on Rails development experience FUN!
YouTube demo video.
Plug 'weizheheng/ror.nvim'
require("dressing").setup({
input = {
min_width = { 60, 0.9 },
},
select = {
-- telescope = require('telescope.themes').get_ivy({...})
telescope = require('telescope.themes').get_dropdown({ layout_config = { height = 15, width = 90 } }), }
})
-- The default settings
require("ror").setup({
test = {
message = {
-- These are the default title for nvim-notify
file = "Running test file...",
line = "Running single test..."
},
coverage = {
-- To customize replace with the hex color you want for the highlight
-- guibg=#354a39
up = "DiffAdd",
-- guibg=#4a3536
down = "DiffDelete",
},
notification = {
-- Using timeout false will replace the progress notification window
-- Otherwise, the progress and the result will be a different notification window
timeout = false
},
pass_icon = "✅",
fail_icon = "❌"
}
})
-- Set a keybind
-- This "list_commands()" will show a list of all the available commands to run
vim.keymap.set("n", "<Leader>rc", ":lua require('ror.commands').list_commands()<CR>", { silent = true })
-- Set a keybind
lvim.builtin.which_key.mappings["r"] = {
name = "Ruby on Rails",
c = { "<cmd>lua require('ror.commands').list_commands()<cr>", "RoR Menu" },
}
Writing test in Rails is fun, but ror.nvim is bringing it to the next level with features like:
If you are using minitest, you will need to install the minitest-json-reporter to your Ruby on Rails project:
group :test do
gem "minitest-json-reporter"
end
I love Telescope, but sometimes there are just too much noise. ROR finders allow you to quickly look for files in:
Rails provide a lot of generator methods, but one just couldn't remember them all!
Supported generators:
Each Rails generators have a destroyer too!
There are a few commands that Rails developers will run daily while developing, instead of switching to your console, just run it in Neovim!
Supported commands:
Rails follows the Model, View, Controller (MVC) pattern, navigations helper provide a way to easily jump to the associated models, views, and controllers easily. Of course, you can quickly jump to the test files too!
When working in a big project, it's very hard to remember all the routes. Rails does provide a CLI
method like rails routes
to list all the routes but that command is SLOwwwww. ROR routes helpers
provide a better experience to look through all the routes in your project.
I bet there are times you don't remember what columns does an ActiveRecord model has? And you have to go to schema.rb and look through them? ror.nvim is here to help!
I have been a Rails developer for 3 years now, and sometimes I still don't remember a lot of the built-in methods. There are active developments on adding types to Ruby code with tools like Sorbet and Ruby's built-in rbs which when pair with steep might give a very good developmet experience with all language server features.
I came across Aaron Patterson's YouTube video on creating a language server and also Shopify's ror-lsp GitHub repo and decided to create my own ror-lsp.
-- With luasnip installed, you will need to add this line to your config
require("luasnip.loaders.from_vscode").lazy_load()