Skip to content

h3pei/ruby-fqcn.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ruby-fqcn.nvim

Neovim plugin to extract fully qualified class names (FQCN) from Ruby classes and modules.

Provides the :CopyRubyFQCN command to copy to clipboard, as well as the get_fqcn() API for use by other plugins.

ruby-fqcn.nvim demo

Requirements

Installation

-- lazy.nvim
{
  "h3pei/ruby-fqcn.nvim",
  dependencies = { "nvim-treesitter/nvim-treesitter" },
  ft = "ruby",
}

Usage

With a Ruby file open, run the :CopyRubyFQCN command. that's it!

Based on the cursor position, the FQCN of the current class/module will be copied to the clipboard.

module Foo
  module Bar
    class Baz
      # If cursor is here => "Foo::Bar::Baz" is copied
    end
    # If cursor is here => "Foo::Bar" is copied
  end

  # If cursor is here => "Foo" is copied

  Qux = Struct.new(:x, :y) do
    # If cursor is here
    # => "Foo::Customer" is copied
  end

  Quux = Data.define(:x, :y) # If cursor is here => "Foo::Quux" is copied
end

Keymapping

You can set up a keymapping as you like:

-- example:
vim.keymap.set("n", "<leader>cf", "<cmd>CopyRubyFQCN<cr>", { desc = "Copy Ruby FQCN" })

About

AST-powered FQCN(fully qualified class names) extractor for Ruby files in Neovim

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published