Course Lessons
Standalone tools for linting & formatting
Ok, so we have stylua
installed and formatting/linting our lua code. Lets expand this to a real language like ruby
.
In all seriousness, expanding our configuration to other languages is really easy now. We just need to map the linting/formatting tool we're using to the builtins
section of the none-ls package (again, that is here: https://github.com/nvimtools/none-ls.nvim/blob/main/doc/BUILTINS.md), install that via Mason
, and add the corresponding configuration to our none-ls.lua
file.
Ruby uses rubocop for linting and formatting. So we can install Rubocop with Mason
(or by installing our gem with bundler or manually). Then, we configure our none-ls.lua
file to look like this:
"nvimtools/none-ls.nvim",
config = function()
local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.formatting.stylua,
null_ls.builtins.diagnostics.rubocop,
null_ls.builtins.formatting.rubocop,
},
})
vim.keymap.set("n", "<leader>gf", vim.lsp.buf.format, {})
end,
}
Now you should have a working configuration for Ruby on Rails projects with linting and formatting!!
You've completed this lesson!
You completed this lesson less than a minute ago.