Code Monkey home page Code Monkey logo

go-vim-install's Introduction

go-vim-install

Easy environment setup for Vim addicts and go developers on Ubuntu.

Install

Hereinafter are two easy ways to get your vim environment ready for go development.

Standard
wget https://raw.githubusercontent.com/xlucas/go-vim-install/master/install.sh
chmod +x install.sh
Vagrant

If you want to boot up a clean Ubuntu VM with a GUI and all the features ready to be used, you can use this gist.

Usage

While there are a lot of great plugins of all kinds for Vim made by amazing people, that's always a hassle to retrieve them all, configure your .vimrc, install colorschemes and extra stuff to get everything eventually working. This little installer for ubuntu make the life simpler for go development with Vim, by providing a command line with 3 options to either :

  • Download and install go from a remote tarball containing the go version of your choice (option -go).
  • Setup a fully working Vim environment with amazing plugins, third party helpers and colorschemes (option -vim).
  • Setup your go workspace with required go tools for Vim plugins (option -work).

Examples :

  • ./install.sh -go https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz
  • ./install.sh -vim
  • ./install.sh -work ~/Workspace/go

Be aware to run . ~/.profile after a step is done so environment variables are up to date.

That's all !

Vim environment

The script will install pathogen and the following plugins :

The colorscheme bundled is a variant of molokai.

Here's a screenshot of what the environment will look like :

go-vim-install

The script will install the Monaco font. Set it with a size between 11 and 12 in your terminal configuration.

Workspace setup

The script will install these packages in your workspace :

Most of them are required to have the go-vim plugin fully working. Then you can run crazy things from Vim, like test units with (:GoTest), coverage report with (:GoCoverage), refactor an element name and its references (:GoRename), do code inspection and error checking (:GoDoc, :GoInfo, :GoCallers, :GoCallees, :GoErrCheck ...), build your packages (:GoBuild), detect unchecked errors (:GoErrCheck) and much more. Obviously, you can also remap all these actions to shortcuts of your choice in your .vimrc ! Check the go-vim plugin documentation to get a full list of Go-specific features.

If you don't know what other plugins are doing, you will find some other tasty functionnalities in related documentations !

Shortcuts

The following default shortcuts are set in the .vimrc file :

General

  • F2 : Create a new tab
  • F3 : Maximize/restore current window
  • F4 : Enable search highlight
  • F5 : Disable search highlight
  • F6 : Show/hide the file tree
  • F7 : Show/hide the undo tree
  • F8 : Show/hide the tagbar (shown by default)
  • F9 : Close the current tab
  • CTRL + Up : Go to the next tab
  • CTRL + Down : Go to the previous tab

Formatting

  • F10 : Align text using ',' as a delimiter
  • F12 : Align text using space as a delimiter
  • CTRL + C + , : Format Zen Coding
  • CTRL + _ : Autoclose xml/html tag(s) (repeat to close several ones)
  • CTRL + j : Expand snippet
  • CTRL + n : Go to next snippet item
  • CTRL + p : Go to previous snippet item

Search and replace

  • CTRL + p : Search for a file
  • leader + a : Search for a word recursively from project's root directory
  • leader + aa : Search word under cursor recursively from project's root directory
  • leader + leader + s : Replace all occurences of word under the cursor in this file
  • leader + vr : Recursively replace occurences of word under the cursor in all files

Grammar

  • leader + g : Run a grammar check
  • ! : Go to next grammar error
  • § : Go to previous grammar error
  • leader + ga : Fix all grammar errors automatically
  • leader + gf : Fix this grammar error
  • leader + gr : Remove this grammar error
  • leader + gd : Disable this grammar rule

Git

  • ]c : Go to next hunk
  • [c : Go to previous hunk
  • leader + hp : Preview current git hunk
  • leader + hr : Revert current git hunk
  • leader + hs : Stage current git hunk

Go code

  • , : Jump to next warning/error
  • ? : Jump to previous warning/error
  • leader + b : Go build
  • leader + c : Go coverage
  • leader + l : Go lint
  • leader + i : Show type info of word under cursor
  • leader + e : Rename word under cursor
  • leader + f : Implement an interface
  • leader + ff : Show interface implementing the type under the cursor
  • leader + p : Share selection in the go playground
  • leader + q : Import package (type package name)
  • leader + r : Go run (normal mode) / Add tags to a selected struct (visual mode)
  • leader + s : Go install
  • leader + t : Go test
  • leader + v : Go vet
  • leader + ds : Open declaration of word under cursor in new split window
  • leader + dv : Open declaration of word under cursor in new vertical window
  • leader + dt : Open declaration of word under cursor in new tab
  • leader + gs : Open godoc of word under cursor in new split window
  • leader + gv : Open godoc of word under cursor in new vertical window
  • leader + gb : Open godoc of word under cursor in browser

go-vim-install's People

Watchers

 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.