Skip to content

Go impl integrated with treesitter to provide interface implementation stubs for desired types

License

Notifications You must be signed in to change notification settings

venomlab/goimpl.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Go impl for neovim

Lua API to easily provide Go implementation for current type

Prerequisites

Installation

Lazy.nvim:

-- init.lua
{ 'venomlab/goimpl.nvim', tag = "0.1.0" }

Usage

Public function impl of goimpl module checks if file is of type Go and then asks for interface prompt. If everything is fine, you'll have function stubs for the desired type

The simplest way would be to just set new keybinding somewhere in "after plugins" section:

-- after/plugin/goimpl.lua
local goimpl = require("goimpl")

vim.keymap.set("n", "<leader>im", function()
    if goimpl.is_go() then -- call impl if current buffer is attached to Go file
        goimpl.impl()
    end
end)

Better would be to add it to your LSP config on buffer attach. Example with lsp-zero.nvim:

-- after/plugin/lsp.lua
lsp_zero.on_attach(function(client, bufnr)
    local opts = { buffer = bufnr, remap = false }

    local goimpl = require("goimpl")
    if goimpl.is_go() then -- register keybinding only if it is Go file
        vim.keymap.set("n", "<leader>im", function()
            goimpl.impl()
        end, opts)
    end

    -- your other keymaps

About

Go impl integrated with treesitter to provide interface implementation stubs for desired types

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages