打造超级舒适的Go开发环境之VIM配置
最近博主已经从VIM迁移到了EMACS作为主要生产工具,目的是为了学习Lisp和体验EMACS操作系统之美,哈哈,不要被我弄的技术焦虑,没错,我就是换了个吃饭的盘子。写下这篇博客也是为了纪念我顺利的“从VIM毕业了”。
在阅读本文之前,你需要:
- 准备一个UNIX like的操作系统
- 一个可以跨过山和大海的代-理
话不多说,开始吧~
(1)下载必要的Go工具链
go get -v github.com/mdempsky/gocode go get -v github.com/ramya-rao-a/go-outline go get -v github.com/acroca/go-symbols go get -v github.com/uudashr/gopkgs go get -v golang.org/x/tools/cmd/guru go get -v golang.org/x/tools/cmd/gorename go get -v github.com/sqs/goreturns go get -v github.com/rogpeppe/godef go get -v golang.org/x/tools/cmd/godoc go get -v golang.org/x/lint/golint go get -v github.com/derekparker/delve/tree/master/cmd/dlv go get -v github.com/fatih/gomodifytags go get -v github.com/haya14busa/goplay go get -v github.com/josharian/impl go get -v github.com/tylerb/gotype-live go get -v github.com/cweill/gotests go get -v github.com/sourcegraph/go-langserver go get -v github.com/davidrjenni/reftools/tree/master/cmd/fillstruct
(2)安装VIM
macOS用户可能需要安装一下macvim:
brew install macvim
(3)主题配置
为了实现类似于Atom的Onedark和Onelight模式,我们可能需要安装两个主题:
- onedark.vim(只支持黑暗模式):
https://github.com/joshdick/onedark.vim.git
- one.vim(同时支持):
https://github.com/rakr/vim-one.git
在.vim
目录下创建三个目录:autoload
,bundle
,colors
,将两个仓库克隆到本地,然后将autoload目录的one.vim或者onedark.vim拷贝到autoload目录,将colors目录的one.vim或者onedark.vim拷贝到colors目录。
配置主题,修改~/.vimrc
文件:
colorscheme one set background=dark
当你想要将主题更改为Onelight的时候,只要将dark替换为light即可。
(4)插件配置
首先要安装插件管理器Vundle:
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
然后配置~/.vimrc
文件:
set nocompatible " be iMproved, required filetype off " required " set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " alternatively, pass a path where Vundle should install plugins "call vundle#begin('~/some/path/here') " let Vundle manage Vundle, required Plugin 'VundleVim/Vundle.vim' " The following are examples of different formats supported. " Keep Plugin commands between vundle#begin/end. " plugin on GitHub repo Plugin 'tpope/vim-fugitive' " plugin from http://vim-scripts.org/vim/scripts.html " Plugin 'L9' " Git plugin not hosted on GitHub Plugin 'git://git.wincent.com/command-t.git' " git repos on your local machine (i.e. when working on your own plugin) Plugin 'file:///home/gmarik/path/to/plugin' " The sparkup vim script is in a subdirectory of this repo called vim. " Pass the path to set the runtimepath properly. Plugin 'rstacruz/sparkup', {'rtp': 'vim/'} " Install L9 and avoid a Naming conflict if you've already installed a " different version somewhere else. " Plugin 'ascenator/L9', {'name': 'newL9'} " All of your Plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required " To ignore plugin indent changes, instead use: "filetype plugin on " " Brief help " :PluginList - lists configured plugins " :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate " :PluginSearch foo - searches for foo; append `!` to refresh local cache " :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal " " see :h vundle for more details or wiki for FAQ " Put your non-Plugin stuff after this line
为了支持多种编程语言,我们采用YouCompleteMe插件,macOS用户使用如下命令:
brew install cmake python python3 mono go nodejs
如果你已经使用nvm作为Node.js版本管理器,或者已经通过PKG方式安装了Python3.x版本,那么只需要PATH可以识别到命令,另外nvm用户需要安装npm:
brew install npm
接下来需要进行编译:
cd ~/.vim/bundle/YouCompleteMe python3 install.py --all
由于YouCompleteMe插件使用Vundle安装可能导致失败,因此通过手动安装的方式实现,其他插件均可以通过Vundle安装:
Plugin 'fatih/vim-go' Plugin 'Tagbar' Plugin 'scrooloose/nerdtree' Plugin 'Xuyuanp/nerdtree-git-plugin' Plugin 'vim-airline/vim-airline' Plugin 'vim-airline/vim-airline-themes'
写到.vimrc文件中,然后打开vim,进入命令模式,使用如下命令安装:
:PluginInstall
vim-go插件需要下载一些工具包,如果使用Vundle安装失败,可以进入vim使用如下命令:
:GoInstallBinaries
配置完成后的整个.vimrc文件如下:
set nocompatible " be iMproved, required filetype off " required syntax on colorscheme one let g:one_allow_italics = 1 set background=dark set nu let NERDTreeWinSize=50 let NERDTreeShowLineNumbers=1 let NERDTreeAutoCenter=1 let NERDTreeShowHidden=1 let g:go_gopls_enabled = 0 set laststatus=2 "始终显示状态栏 set tabstop=2 "一个制表符的长度 set softtabstop=2 "一个制表符的长度(可以大于tabstop) set shiftwidth=2 "一个缩进的长度 set expandtab "使用空格替代制表符 set smarttab "智能制表符 set autoindent "自动缩进 set smartindent "只能缩进 set ruler "显示位置指示器 set ignorecase "检索时忽略大小写 set hls "检索时高亮显示匹配项 set helplang=cn "帮助系统设置为中文 set foldmethod=syntax "代码折叠 set guifont=PowerlineSymbols\ for\ Powerline set nocompatible set t_Co=256 let g:Powerline_symbols = 'fancy' " let g:nerdtree_tabs_open_on_console_startup=1 "Use 24-bit (true-color) mode in Vim/Neovim when outside tmux. "If you're using tmux version 2.2 or later, you can remove the outermost $TMUX check and use tmux's 24-bit color support "(see < http://sunaku.github.io/tmux-24bit-color.html#usage > for more information.) if (empty($TMUX)) if (has("nvim")) "For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 > let $NVIM_TUI_ENABLE_TRUE_COLOR=1 endif "For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 > "Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd > " < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 > if (has("termguicolors")) set termguicolors endif endif " set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " alternatively, pass a path where Vundle should install plugins "call vundle#begin('~/some/path/here') " let Vundle manage Vundle, required Plugin 'VundleVim/Vundle.vim' Plugin 'fatih/vim-go' Plugin 'Valloric/YouCompleteMe',{'do':'python3 install.py --all'} Plugin 'Tagbar' Plugin 'scrooloose/nerdtree' Plugin 'Xuyuanp/nerdtree-git-plugin' Plugin 'vim-airline/vim-airline' Plugin 'vim-airline/vim-airline-themes' " All of your Plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required " To ignore plugin indent changes, instead use: "filetype plugin on " " Brief help " :PluginList - lists configured plugins " :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate " :PluginSearch foo - searches for foo; append `!` to refresh local cache " :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal " " see :h vundle for more details or wiki for FAQ " Put your non-Plugin stuff after this line let g:go_highlight_types = 1 let g:go_highlight_fields = 1 let g:go_highlight_functions = 1 let g:go_highlight_function_calls = 1 let g:go_highlight_operators = 1 let g:go_highlight_extra_types = 1
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
AWS 数据加密知识点
一、S3 加密 服务端加密 服务器端加密是由接收数据的应用程序或服务在数据目的地对数据进行加密。Amazon S3 在将您的数据写入数据中心内的磁盘时会在对象级别上加密这些数据,并在您访问这些数据时为您解密这些数据。只要您验证了您的请求并且拥有访问权限,您访问加密和未加密对象的方式就没有区别。例如,如果您使用预签名的 URL 来共享您的对象,那么对于加密和解密对象,该 URL 的工作方式是相同的。此外,在您列出存储桶中的对象时,列表 API 会返回所有对象的列表(无论对象是否加密)。 注意您不能对同一个对象应用不同类型的服务器端加密。 您有三个互斥选项,具体取决于您选择如何管理加密密钥: 具有 Amazon S3 托管密钥的服务器端加密 (SSE-S3) 当您使用具有 Amazon S3 托管密钥的服务器端加密 (SSE-S3) 时,每个对象均使用唯一密钥加密。作为额外的保护,它将使用定期轮换的主密钥对密钥本身进行加密。Amazon S3 服务器端加密使用可用的最强数据块密码之一(即 256 位高级加密标准 (AES-256))来加密您的数据。有关更多信息,请参阅使用具有 Amazon...
- 下一篇
Go Search Extension 0.2 版发布
Go Search Extension是一款可以在浏览器地址栏快速、方便、高效地搜索 Go 文档的浏览器插件,支持 Chrome/Firefox/Edge 。类似于 Rust 社区的Rust Search Extension。 下载地址: Chrome Web Store Firefox Microsoft Edge 主要功能: 搜索 Go 标准库文档 可通过关键词搜索 package 、func 、interface,快速查看其定义和描述,也可选中并跳转到文档页面查看具体说明。 搜索热门的 package 可通过搜索 package 名称获得 GitHub 上 star 数top 20k的 go 项目文档相关的信息,包括最新版本号和 package 的说明。 默认搜索关键字的时候,搜索结果会混合标准库文档和第三方库的结果。可以在关键字前加一个前缀!(英文叹号)只搜索第三方库。 快速跳转 git 仓库 在搜索 Top 20K 第三方库的时候,在关键字前拼接两个!!就可跳转到该 package 的 git 仓库地址,非常方便!当然目前只支持 Github 、Gitlab 、Bitbuck...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- Docker使用Oracle官方镜像安装(12C,18C,19C)
- CentOS7,CentOS8安装Elasticsearch6.8.6
- CentOS6,CentOS7官方镜像安装Oracle11G
- CentOS7编译安装Cmake3.16.3,解决mysql等软件编译问题
- SpringBoot2编写第一个Controller,响应你的http请求并返回结果
- CentOS8编译安装MySQL8.0.19
- SpringBoot2配置默认Tomcat设置,开启更多高级功能
- Windows10,CentOS7,CentOS8安装Nodejs环境
- Docker快速安装Oracle11G,搭建oracle11g学习环境
- CentOS8,CentOS7,CentOS6编译安装Redis5.0.7