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.
- Neovim 0.10+
- nvim-treesitter with Ruby parser (Run
:TSInstall ruby)
-- lazy.nvim
{
"h3pei/ruby-fqcn.nvim",
dependencies = { "nvim-treesitter/nvim-treesitter" },
ft = "ruby",
}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
endYou can set up a keymapping as you like:
-- example:
vim.keymap.set("n", "<leader>cf", "<cmd>CopyRubyFQCN<cr>", { desc = "Copy Ruby FQCN" })