参考
https://blog.csdn.net/zhang197093/article/details/78559903?locationNum=5&fps=1
官方提供go 插件
https://github.com/golang/go/wiki/IDEsAndTextEditorPlugins
upgrade vim
- 卸载原来的vim 相关软件
apt-get remove vim vim-tiny vim-common vim-runtime -y
- 拷贝 vim 源码
git config –global http.postBuffer 2000000000
git clone https://github.com/vim/vim.git
- cd 到安装目录 ,安装
cd ~/vim/src
sudo apt-get install libncurses5-dev -y
./configure
sudo make install
install vim plugin
安装vim的插件管理工具 vim-pathogen
https://github.com/tpope/vim-pathogen先创建两个目录
mkdir -p ~/.vim/autoload ~/.vim/bundle下载 vim-pathogen 到 ~/.vim/autoload 目录下
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vimvim ~/.vimrc
set nocompatible execute pathogen#infect() syntax on filetype plugin indent on
安装 vim-pathogen 后再安装其他插件的时候,只需cd ~/.vim/bundle 到该目录下,git clone 即可
install vim-go
vim-go 是一款go代码高亮和语法检查的插件
cd ~/.vim/bundle/
git clone https://github.com/fatih/vim-go.git
install gocode , vim-gocode
gocode是一款go的代码提示插件- 正确设置GOROOT、GOPATH、PATH等几个环境变量
编辑配置文件: vim /etc/profile
export GOROOT=/usr/local/go export GOBIN=$GOROOT/bin export GOPATH=/home/baixx/GoProject export PATH=$PATH:$GOBIN:$GOPATH/bin
使配置立即生效: source /etc/profile
- install gocode
cd $GOPATH/src
go get -u github.com/nsf/gocode
(cd gocode&make intall 我不知道用这步了没,反正试了很多遍)- install vim-gocode
https://github.com/Blackrush/vim-gocode
cd ~/.vim/bundle
git clone https://github.com/Blackrush/vim-gocode.git安装完gocode后,运行下面命令设置一下gocode的propose-builtins(默认为false,不会自动联想go语言内置的类型、常量和方法等),
gocode set propose-builtins true
ctrl + p , ctrl + o
vim-gocode 的使用说明及快捷键:
https://github.com/Blackrush/vim-gocode/blob/master/doc/vim-gocode.txtinstall tagbar
https://github.com/majutsushi/tagbar
一款用于显示代码结构的插件
cd ~/.vim/bundle/
git clone https://github.com/majutsushi/tagbar.git
设置 展开/关闭 视图快捷键:
vim ~/.vimrc
write the content of the file automatically if you call :make
set autowrite
前面有点乱
IDEs and Plugins for Go
https://github.com/golang/go/wiki/IDEsAndTextEditorPlugins
Gocode: An autocompletion daemon that includes support for emacs and vim.
- Vim & Neovim: Vi Improved. There are a number of plugins available that make editing Go code easier.
- The vim-go plugin includes misc/vim and has many other new improvements.
- The Syntastic plugin gives instant feedback on compile errors
- The tagbar plugin uses Gotags, above, to show an outline of the current file
- A vim compiler plugin for syntax checking
- A vim-godef plugin integrates with the ‘godef’ tool, above
- A vim-go-extra is vim plugin based on misc/vim in go repository. This works fine on windows too!
- A vim-bootstrap is generator provides a simple method of generating a .vimrc configuration for vim
vim-go follows the standard runtime path structure. Below are some helper lines for popular package managers:
vim-go ===== install
- Vim 8 packages
git clone https://github.com/fatih/vim-go.git ~/.vim/pack/plugins/start/vim-go
- Pathogen
git clone https://github.com/fatih/vim-go.git ~/.vim/bundle/vim-go
- vim-plug
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
offical vim-go-tutorial
vim-gocode
vim-gocode ===== install
https://github.com/Blackrush/vim-gocode
Make sure you have installed gocode before installing this plugin :
source-shell
go get github.com/nsf/gocode
Vundle
Add this line to your ~/.vimrc configuration file :
Bundle ‘Blackrush/vim-gocode’
And then run vim :
vim +BundleInstall
Pathogen
cd ~/.vim/bundle
git clone https://github.com/Blackrush/vim-gocode.git`
自动添加/移除import:goimports
相关设置安装