/cmp-rails-fixture-names

An nvim-cmp source for Ruby on Rails fixture names including documentation

Primary LanguageLuaMIT LicenseMIT

cmp-rails-fixture-names

This plugin is a source for nvim-cmp to complete Ruby on Rails fixture names. Names meaning the individual fixtures each fixture type represents.

For example, a User model would have a users fixture type and each fixture has a name. If you have a user fixture called bob. This cmp source will auto-complete the fixture name bob when you type users(:.

It will also parse the fixture file and show the fixture data/attributes in the documentation window.

There is a companion plugin, called cmp-rails-fixture-types that only completes fixture types.

Setup

Prerequisites

Fixtures must exist in the default location of test/fixtures or spec/fixtures and be .yml files.

This plugin regex parses the YAML files for completion data so anything fancy like a Ruby loop that generates fixtures will likely break.

Installation

Install cmp-rails-fixture-names using your plugin manager of choice. For example, here it is using lazy.nvim:

{
  "hrsh7th/nvim-cmp",
  dependencies = {
    { "wassimk/cmp-rails-fixture-names", version = "*", ft = "ruby" },
  },
}

Then add rails-fixture-names source in your nvim-cmp configuration:

require("cmp").setup {
  -- ...
  sources = {
    { name = "rails-fixture-names" },
    -- other sources ...
  },
  -- ...
}