Giter Club home page Giter Club logo

gounit-vim's Introduction

gounit-vim

Vim plugin for gounit tool that allows you to generate Go tests easily.

Demo

demo

Installation

gounit-vim requires gounit to be available in your $PATH. Alternatively you can provide path to gounit using g:gounit_bin setting.

Plugin installation:

  • Pathogen
    git clone https://github.com/hexdigest/gounit-vim.git ~/.vim/bundle/gounit-vim
    
  • vim-plug
    Plug 'hexdigest/gounit-vim'
    
  • NeoBundle
    NeoBundle 'hexdigest/gounit-vim'
    
  • Vundle
    Plugin 'hexdigest/gounit-vim'
    
  • Vim packages (since Vim 7.4.1528)
    git clone https://github.com/hexdigest/gounit-vim.git ~/.vim/pack/plugins/start/gounit-vim
    

You will also need to install all the necessary GoUnit binaries. It is easy to install by providing a command :GoUnitInstallBinaries, which will go get all the required binaries.

Usage

Call :GoUnit to generate test for the function declaration in the current line or all functions selected in visual mode. GoUnit also understands "range" parameters:

:5,10GoUnit     " genereate tests for functions from line 5 to line 10
:.,$GoUnit      " from the current line till the end of the file
:0,.GoUnit      " from the first line to the current line
:%GoUnit        " generate tests for the whole file

These commands generate tests using template that you set as a preferred with the :GoUnitTemplateUse <template> command. If you don't want to change your preferred template you can use all of the above commands followed by the name of the template, i.e. :GoUnit minimock If you have wildmenu option enabled you can pick desired template from the list of all registered templates with :GoUnit <TAB>.

Managing templates

There are few commands to manage your test templates:

:GoUnitTemplateAdd             " register contents of the current buffer as a new templates
:GoUnitTemplateAdd /file/name  " register /file/name as new template
:GoUnitTemplateDel template    " remove template
:GoUnitTemplateList            " display all registered test templates
:GoUnitTemplateUse template    " set template as preferred

Also you can create useful maps to use it with vim-go plugin for fast test generation.

" maps your leader key + gt to generate tests for the function under your cursor
nnoremap <leader>gt :normal vaf<cr>:GoUnit<cr>

Settings

If you want you can set path to your gounit binary if it's not in your path, for example:

let g:gounit_bin = '/home/user/go/bin/gounit'

gounit-vim's People

Contributors

buoto avatar hexdigest avatar ipriver avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gounit-vim's Issues

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.