赞
踩
打造适合自己的go IDE
前几天mac出了点问题,公司给换了一台,唯一不爽的就是原有的环境要重建,记录下
# brew 安装
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
# iterm2 安装
brew cask install iterm2
# vim 安装
brew install vim
# Vundle (插件管理器) 安装
mkdir -p ~/.vim/bundle
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
# npm 安装
brew install npm
~/.vimrc
"============================================================================== " vim 内置配置 "============================================================================== " 设置 vimrc 修改保存后立刻生效,不用在重新打开 " 建议配置完成后将这个关闭 autocmd BufWritePost $MYVIMRC source $MYVIMRC set nocompatible " 关闭兼容模式 set nu " 设置行号 set cursorline "突出显示当前行 set cursorcolumn " 突出显示当前列 set showmatch " 显示括号匹配 set mouse=v " 允许鼠标点击定位 set paste " 粘贴时保持格式 set ruler " 显示当前光标所在的行列号 set scrolloff=3 " 标移动到buffer的顶部和底部时保持3行距离 set nowrap " 取消换行 " 设定默认解码 set fenc=utf-8 set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936 " 允许使用退格键 set backspace=eol,start,indent set whichwrap+=<,>,h,l " tab 缩进 set tabstop=4 " 设置Tab长度为4空格 set shiftwidth=4 " 设置自动缩进长度为4空格 set autoindent " 继承前一行的缩进方式,适用于多行注释 " 定义快捷键的前缀,即<Leader> let mapleader=";" "vundle 配置 set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() Plugin 'fatih/vim-go' Plugin 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } Plugin 'junegunn/fzf.vim' Plugin 'scrooloose/nerdtree' Plugin 'Valloric/YouCompleteMe' Plugin 'dgryski/vim-godef' call vundle#end() " vim-go au FileType go nmap C :GoCoverage<CR> au FileType go nmap gl :GoDeclsDir<CR> au FileType go nmap c :GoDoc<CR> au FileType go nmap gs :GoImports<CR> au FileType go nmap gi :GoInfo<CR> au FileType go nmap e :GoRename<CR> au FileType go nmap gr :GoRun<CR> au FileType go nmap gc :GoCallers<CR> au FileType go nmap gb :GoBuild<CR> au FileType go nmap D :GoDef<CR> au FileType go nmap gt :GoDefType<CR> autocmd BufWritePost *.go :GoVet! let g:go_asmfmt_autosave = 1 let g:go_auto_sameids = 1 let g:go_auto_type_info = 1 let g:go_def_mode = 'gopls' let g:go_doc_keywordprg_enabled = 1 let g:go_doc_max_height = 25 let g:go_echo_command_info = 1 let g:go_echo_go_info = 1 let g:go_fmt_autosave = 1 let g:go_fmt_command = "goimports" let g:go_imports_command = "gopls" let g:go_implements_mode = "gopls" let g:go_imports_autoremove = 1 let g:go_referrers_mode = "gopls" let g:go_doc_popup_window=1 let g:go_gopls_complete_unimported = 1 let g:go_gopls_enabled = 1 let g:go_highlight_build_constraints = 1 let g:go_highlight_extra_types = 1 let g:go_highlight_fields = 1 let g:go_highlight_function_parameters = 1 let g:go_highlight_functions = 1 let g:go_highlight_generate_tags = 1 let g:go_highlight_interfaces = 0 let g:go_highlight_methods = 1 let g:go_highlight_operators = 1 let g:go_highlight_structs = 1 let g:go_highlight_types = 1 let g:go_info_mode = 'gopls' let g:go_mod_fmt_autosave = 1 let g:go_template_autocreate = 0 let g:go_textobj_include_function_doc = 1 let g:go_autodetect_gopath = 1 let g:go_metalinter_autosave = 0 " 开启实时搜索 set incsearch " 搜索时大小写不敏感 set ignorecase syntax enable syntax on " 开启文件类型侦测 filetype plugin indent on " 启用自动补全 " 退出插入模式指定类型的文件自动保存 au InsertLeave *.go,*.sh,*.php write
使用
vim
输入:PluginInstall
会安装.vimrc
文件列出来的所有插件:PluginInstall plugin-name
vim +PluginInstall +qall
自动补全
cd ~/.vim/bundle/YouCompleteMe
python3 install.py --all
预览
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。