From fedb20d9fb31e5f2df995a08c5605a75de49893d Mon Sep 17 00:00:00 2001 From: TiynGER Date: Thu, 29 Apr 2021 16:02:39 +0200 Subject: [PATCH] golang: added guide to install and setup go in vim --- wiki/linux/vim/golang.md | 41 ++++++++++++++++++++++++++++ wiki/programming-languages/golang.md | 21 ++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 wiki/linux/vim/golang.md create mode 100644 wiki/programming-languages/golang.md diff --git a/wiki/linux/vim/golang.md b/wiki/linux/vim/golang.md new file mode 100644 index 0000000..d753367 --- /dev/null +++ b/wiki/linux/vim/golang.md @@ -0,0 +1,41 @@ +# GoLang in Vim + +GoLang is a common programming language. +In this entry we will focus on making vim support Go and use vim as an ide for it. +This guide is based on a guide from [octetz.com](https://octetz.com/docs/2019/2019-04-24-vim-as-a-go-ide/). + +## Build, Test, Run, Docs, Debug, Format + +To enable most of the basic functions of an IDE you need to install `vim-go` via +`vim plug`. +For this add `Plug 'fatih/vim-go' " better support for golang` in your plug section +in the `init.vim` file. +Then run `:PlugInstall` and `:GoInstallBinaries` inside `nvim`. +Finally add `let g:go_def_mapping_enabled = 0` to your `init.vim` to make sure +the mapping `gd` will be used by `coc` and its language server. + +## Autocompletion + +### Coc + +To enable autocompletion for [coc](coc.md) you need to install `ccls`. +After that you need to add the following lines to your coc config file. + +```json +{ + "languageserver": { + "golang": { + "command": "gopls", + "rootPatterns": [ + "go.mod", + ".vim/", + ".git/", + ".hg/" + ], + "filetypes": [ + "go" + ] + } + } +} +``` diff --git a/wiki/programming-languages/golang.md b/wiki/programming-languages/golang.md new file mode 100644 index 0000000..c2d623d --- /dev/null +++ b/wiki/programming-languages/golang.md @@ -0,0 +1,21 @@ +# GoLang + +GoLang is a common programming language. + +## Installation + +To get go working you basically just need to install [Go](https://golang.org/doc/install). +Make sure to set the `GOPATH` and the `GOBIN` variable and add the last to the `Path` +by adding the following to your `.profile`: + +```sh +export GOPATH="${HOME}/code/go" +export GOBIN="${GOPATH}/bin" +export PATH="${GOBIN}:${PATH}" +``` + +## IDE + +### Vim + +The steps to make Vim a Go IDE are described in [the vim section of this wiki](../linux/vim/golang.md).