From ac3f2922eed01a5cd1628ebd16650cc88b03f70d Mon Sep 17 00:00:00 2001 From: light <1870499383@qq.com> Date: Wed, 14 Nov 2018 13:11:22 +0800 Subject: [PATCH] vimrc update --- go/vim-go.md | 18 +++++++++++++++++ vim/vimrc | 57 ++++++++++++++++++++++++++++++++++------------------ 2 files changed, 56 insertions(+), 19 deletions(-) create mode 100644 go/vim-go.md diff --git a/go/vim-go.md b/go/vim-go.md new file mode 100644 index 0000000..c8e7e5e --- /dev/null +++ b/go/vim-go.md @@ -0,0 +1,18 @@ +# install vim-go + + +## vundle + +在.vimrc添加 + +``` bash +Plugin 'fatih/vim-go' +``` +重新打开vim, PluginInstall 安装vim-go + + +## vim-go + + 在vim中使用 :GoInstallBinaries 安装vim-go的一些增强功能, 其中一些包需要翻墙,具体包位置参考 ~/.vim/bundle/vim-go/plugin/go.vim. + 主要是golang.org/x/tools 包比较困难,可以go get github.com/golang/tools 在复制到golang.org/x/目录下 + diff --git a/vim/vimrc b/vim/vimrc index d1fa194..975adfd 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -1,10 +1,15 @@ " set the runtime path to include Vundle and initialize +set rtp+=~/.fzf/ set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() Plugin 'VundleVim/Vundle.vim' -"Plugin 'junegunn/fzf.vim' +Plugin 'junegunn/fzf.vim' +nmap l :BLines +nmap L :Lines + +Plugin 'rking/ag.vim' Plugin 'w0rp/ale' @@ -96,6 +101,9 @@ Plugin 'alvan/vim-closetag' let g:closetag_filenames = '*.html,*.xhtml,*.phtml,*.launch' +Plugin 'jiangmiao/auto-pairs' + + Plugin 'vim-airline/vim-airline' Plugin 'vim-airline-themes' let g:airline_theme='bubblegum' @@ -131,8 +139,8 @@ map 9 :b 9 map q :bwipeout " ctags 配置 -map :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q --languages=Python,C++ -f .tags . -imap :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q --languages=Python,C++ -f .tags . +map :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q --languages=Python,C++ -f .tags . +imap :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q --languages=Python,C++ -f .tags . set tags=tags set tags+=.tags set tags+=./.tags @@ -149,6 +157,11 @@ Plugin 'The-NERD-tree' map :NERDTreeToggle let NERDTreeWinSize=25 + +Plugin 'fatih/vim-go' + + + call vundle#end() " required " 在文件外修改时自动加载 @@ -156,6 +169,24 @@ set autoread " make 项目 autocmd FileType c,cpp map :w:make +map :call CompileRunGcc() + +func! CompileRunGcc() + exec "w" + if &filetype == 'c' + exec '!g++ % -o %<' + exec '!time ./%<' + elseif &filetype == 'cpp' + exec '!g++ % -o %<' + exec '!time ./%<' + elseif &filetype == 'python' + exec '!time python %' + elseif &filetype == 'sh' + :!time bash % + elseif &filetype == 'go' + exec 'GoRun' + endif +endfunc "从不备份 set nobackup @@ -258,22 +289,6 @@ set scrolloff=3 set smartindent " 高亮显示普通txt文件(需要txt.vim脚本) au BufRead,BufNewFile * setfiletype txt -"自动补全 -:inoremap ( ()i -:inoremap ) =ClosePair(')') -":inoremap { {}O -":inoremap } =ClosePair('}') -:inoremap [ []i -:inoremap ] =ClosePair(']') -:inoremap " ""i -:inoremap ' ''i -function! ClosePair(char) - if getline('.')[col('.') - 1] == a:char - return "\" - else - return a:char - endif -endfunction filetype plugin indent on "打开文件类型检测, 加了这句才可以用智能补全 set completeopt=longest,menu @@ -298,3 +313,7 @@ if has("autocmd") autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee,*.vue :call CleanExtraSpaces() endif + +colorscheme slate +highlight Comment ctermfg=blue +