Screen Too Small

This course material requires a larger screen to properly display the terminal and editor interfaces.

Please use a tablet, laptop, or desktop computer for the best learning experience.

You can continue browsing, but the experience will be significantly limited.

16/25
Free Trial: 4 lessons remaining
Unlock Full Access

Standalone tools for linting & formatting

Estimated time: 5 minutes

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.