Skip to content

fang2hou/go-impl.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

33 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

go-impl.nvim

A fast and minimal Go interface implementation plugin powered by Neovim's built-in LSP client and Treesitter.

go-impl.nvim_Demo.mp4

✨ Features

  • Built on Neovim primitives
    Leverages the native LSP client (vim.lsp), Treesitter, and vim.system() for async subprocess management. No heavy dependencies.
  • Fully Asynchronous
    Non-blocking LSP requests, interface selection, and impl execution for a seamless experience.
  • Smart Receiver Detection
    Uses Treesitter to locate the struct under the cursor and predict a sensible receiver abbreviation.
  • Multi-Picker Support
    Works with snacks.nvim (recommended, bundled with LazyVim), fzf-lua, or telescope.nvim. Auto-detected based on availability.
  • Generic Parameters Support
    Interactive input for each type parameter with highlighting and live preview of the interface declaration.

πŸ“¦ Requirements

πŸ’Ώ Installation

Install with lazy.nvim
{
  "fang2hou/go-impl.nvim",
  ft = "go",
  dependencies = {
    "MunifTanjim/nui.nvim",

    -- Choose one of the following fuzzy finder
    "folke/snacks.nvim",
    "ibhagwan/fzf-lua",
    "nvim-telescope/telescope.nvim",
  },
  opts = {},
  keys = {
    {
      "<leader>Gi",
      function()
        require("go-impl").open()
      end,
      mode = { "n" },
      desc = "Go Impl",
    },
  },
}

πŸš€ Usage

  1. Open a Go file and place the cursor on a struct.
  2. Run :GoImplOpen or :lua require("go-impl").open().
  3. Confirm the receiver, pick an interface, fill in any generic type parameters.

βš™οΈ Configuration

The defaults work out of the box. See config.lua for all options.

require("go-impl").setup({
  -- explicitly pick a picker, or leave nil for auto-detection
  picker = nil, -- "snacks" | "fzf_lua" | "telescope"
  insert = {
    position = "after", -- "after" | "before" | "end"
    before_newline = true,
    after_newline = false,
  },
})

πŸ”— Alternatives

πŸ“„ License

MIT

About

πŸš€ A faster way to implement Go interfaces in Neovim

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages