1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 02:10:05 +08:00
SpaceVim/docs/layers/lang/go.md

73 lines
2.3 KiB
Markdown
Raw Normal View History

---
title: "SpaceVim golang layer"
description: "This layer is for golang development. It also provides additional language-specific key mappings."
---
2018-06-23 14:37:41 +08:00
# [Available Layers](../../) >> lang#go
<!-- vim-markdown-toc GFM -->
- [Description](#description)
- [Install](#install)
2018-01-03 22:56:15 +08:00
- [Features](#features)
- [Key bindings](#key-bindings)
<!-- vim-markdown-toc -->
## Description
This layer is for golang development. It also provides additional language-specific key mappings.
## Install
2018-06-23 14:37:41 +08:00
To use this configuration layer, update custom configuration file with:
```toml
[[layers]]
name = "lang#go"
```
2018-01-03 22:56:15 +08:00
After the installation, run `:GoInstallBinaries` inside vim.
2018-01-03 22:56:15 +08:00
## Features
- auto-completion
- syntax checking
- goto definition
- refernce finder
## Key bindings
**Import key bindings:**
2019-02-03 20:51:01 +08:00
| Key Bindings | Descriptions |
| ------------ | ------------------------- |
| `SPC l a` | go alternate |
| `SPC l b` | go build |
| `SPC l c` | go coverage |
| `SPC l d` | go doc |
| `SPC l D` | go doc vertical |
| `SPC l e` | go rename |
| `SPC l g` | go definition |
| `SPC l G` | go generate |
| `SPC l h` | go info |
| `SPC l i` | go implements |
| `SPC l I` | implement stubs |
| `SPC l k` | add tags |
| `SPC l K` | remove tags |
| `SPC l l` | list declarations in file |
| `SPC l m` | format improts |
| `SPC l M` | add import |
| `SPC l r` | go referrers |
| `SPC l s` | fill struct |
| `SPC l t` | go test |
| `SPC l v` | freevars |
| `SPC l x` | go run |
**Code formatting:**
2019-02-03 20:51:01 +08:00
the default key bindings for format current buffer is `SPC b f`, and this key bindings is defined in [format layer](<>). You can also use `g=` to indent current buffer.
2017-12-19 16:42:29 +08:00
To make neoformat support go files, you should have [go-fmt](http://golang.org/cmd/gofmt/) command available, or
install [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports). `go-fmt` is delivered by golang's default installation, so make sure you have correctly setup your go environment.