Code Monkey home page Code Monkey logo

gopher.nvim's Introduction

gopher.nvim

Stand With Ukraine

Minimalistic plugin for Go development in Neovim written in Lua.

It's not an LSP tool, the main goal of this plugin is add go tooling support in Neovim.

Install

Pre-dependency: go (tested on 1.17 and 1.18)

use {
  "olexsmir/gopher.nvim",
  requires = { -- dependencies
    "nvim-lua/plenary.nvim",
    "nvim-treesitter/nvim-treesitter",
  },
}

Also, run TSInstall go if go parser if isn't installed yet.

Config

By .setup function you can configure the plugin.

Note:

  • installer does not install the tool in user set path
require("gopher").setup {
  commands = {
    go = "go",
    gomodifytags = "gomodifytags",
    gotests = "~/go/bin/gotests", -- also you can set custom command path
    impl = "impl",
    iferr = "iferr",
  },
}

Features

  1. Installation requires this go tool:
:GoInstallDeps

It will install next tools:

  1. Modify struct tags: By default json tag will be added/removed, if not set:
:GoTagAdd json " For add json tag
:GoTagRm yaml " For remove yaml tag
  1. Run go mod command:
:GoMod tidy " Runs `go mod tidy`
:GoMod init asdf " Runs `go mod init asdf`
  1. Run go get command

Link can have a http or https prefix.

You can provide more than one package url:

:GoGet github.com/gorilla/mux
  1. Interface implementation

Command syntax:

:GoImpl [receiver] [interface]

" Also you can put cursor on the struct and run:
:GoImpl [interface]

Example of usage:

" Example
:GoImpl r Read io.Reader
" or simply put your cursor in the struct and run:
:GoImpl io.Reader
  1. Generate tests with gotests

Generate one test for a specific function/method:

:GoTestAdd

Generate all tests for all functions/methods in current file:

:GoTestsAll

Generate tests only for exported functions/methods in current file:

:GoTestsExp
  1. Run go generate command;
" Run `go generate` in cwd path
:GoGenerate

" Run `go generate` for current file
:GoGenerate %
  1. Generate doc comment

First set a cursor on public package/function/interface/struct and execute:

:GoCmt
  1. Generate if err

Set cursor on the line with err and execute:

:GoIfErr
  1. Setup nvim-dap for go in one line.

Notice: nvim-dap is required

require"gopher.dap".setup()

Contributing

PRs are always welcome. See CONTRIBUTING.md

Thanks

gopher.nvim's People

Contributors

olexsmir avatar 1stvaliduser avatar elliottminns avatar brotifypacha avatar gearcog avatar huskyroll avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.