当前位置:   article > 正文

go系列-centos 7.2配置go vim ide_vim配置go语言ide

vim配置go语言ide

1. 获取Vundle.vim

  1. # mkdir ~/.vim/VundleVim
  2. # git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/VundleVim/Vundle.vim 

2. 获取vim-go

  1. if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
  2. set fileencodings=utf-8,latin1
  3. endif
  4. set nocompatible " Use Vim defaults (much better!)
  5. set bs=indent,eol,start " allow backspacing over everything in insert mode
  6. "set ai! " always set autoindenting on
  7. "set backup " keep a backup file
  8. set viminfo='20,\"50 " read/write a .viminfo file, don't store more
  9. " than 50 lines of registers
  10. set history=50 " keep 50 lines of command line history
  11. set ruler " show the cursor position all the time
  12. set nu
  13. "set cindent
  14. "set foldlevel=99
  15. set foldmethod=syntax
  16. "set cursorline
  17. "hi cursorline cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
  18. "hi cursorline cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
  19. "set cursorline ctermfg=Red ctermbg=Black cterm=bold
  20. "set cursorcolumn
  21. set showmatch
  22. set hlsearch
  23. set incsearch
  24. set smartindent
  25. set autochdir
  26. set nocp
  27. set shiftwidth=4
  28. set tabstop=4
  29. set expandtab
  30. set foldlevel=99
  31. "set autoindent!
  32. set statusline=
  33. set numberwidth=5
  34. set undolevels=5000
  35. "chuanqi
  36. "set showmode
  37. "set ambiwidth=double
  38. """"""""""""""""""""""""""""""""""""""""""""""""""""""
  39. "set softtabstop=4
  40. "set laststatus=2
  41. "highlight StatusLine cterm=bold ctermfg=yellow ctermbg=blue
  42. "highlight StatusLine cterm=bold ctermfg=black ctermbg=white
  43. "colorscheme molokai
  44. "colorscheme togglebg
  45. colorscheme desert
  46. set tags=tags;
  47. set autochdir
  48. set encoding=utf-8
  49. set nocst
  50. set cspc=6
  51. "let g:autocscope_menus=0
  52. filetype off
  53. set rtp+=~/.vim/bundle/Vundle.vim
  54. " 这里要注意 begin 里面是空的
  55. call vundle#begin()
  56. Plugin 'VundleVim/Vundle.vim'
  57. "Plugin 'Valloric/YouCompleteMe'
  58. "Plugin 'gmarik/vundle'
  59. Bundle 'taglist.vim'
  60. Plugin 'SuperTab'
  61. Plugin 'vimwiki'
  62. ""Plugin 'c.vim'
  63. Plugin 'fatih/vim-go'
  64. "Plugin 'gtags.vim'
  65. Plugin 'dgryski/vim-godef'
  66. Plugin 'nsf/gocode', {'rtp': 'vim/', 'do':'~/.vim/symlink.sh'}
  67. Plugin 'Blackrush/vim-gocode'
  68. Plugin 'The-NERD-tree'
  69. Plugin 'jstemmer/gotags'
  70. Plugin 'bradfitz/goimports'
  71. "Bundle 'cespare/vim-golang'
  72. Plugin 'majutsushi/tagbar'
  73. Plugin 'derekwyatt/vim-scala'
  74. call vundle#end()
  75. """""""""""""""""""""""""""""""""""""""""""
  76. " for gocode
  77. " for close gofmt autosave on save file
  78. "filetype plugin indent off
  79. filetype plugin on
  80. "imap <C-Space> <C-x><C-o>
  81. imap <C-j> <C-x><C-o>
  82. let go_version_warning=0
  83. """"""""""""""""""""
  84. "set ambiwidth=double
  85. "set bufhidden=hide
  86. "set bsdir=buffer
  87. "source $VIMRUNTIME/delmenu.vim
  88. "source $VIMRUNTIME/menu.vim
  89. "set t_co=256
  90. "let g:SuperTabDefaultCompletionType = "<c-n>"
  91. "let g:SuperTabDefaultCompletionType="context"
  92. "let g:SuperTabDefaultCompletionType="<c-x><c-u>"
  93. "let g:SuperTabMappingTabLiteral="<c-u>"
  94. "imap <C-u> <C-x><C-u>
  95. imap <C-p> <C-x><C-p>
  96. """"""""""""""""""""""""""""""""""""""""""""""""""
  97. " for vim-go plugin open
  98. let g:go_highlight_functions = 1
  99. let g:go_highlight_methods = 1
  100. let g:go_highlight_structs = 1
  101. let g:go_highlight_operators = 1
  102. let g:go_highlight_build_constraints = 0
  103. "let g:go_fmt_fail_silently = 1
  104. let g:go_fmt_autosave = 1
  105. "let g:go_play_open_browser = 0
  106. "let g:go_fmt_command="goimports"
  107. """"""""""""""""""""""""""""""""""""""""""""""""""
  108. "" end open
  109. """"""""""""""""""""""""""""""""""""""""""""""""""
  110. " for gocode gocomplete
  111. " imap <C-Space> <C-x><C-o>
  112. "imap <C-j> <C-x><C-o>
  113. """"""""""""""""""""""""""""""""""""""""""""""""""
  114. """"""""""""""""""""""""""""""""""""""""""""""""""
  115. " for golang syntax
  116. "Bundle 'scrooloose/syntastic'
  117. " check go code syntax error : >> xxx
  118. set statusline+=%#warningmsg#
  119. set statusline+=%{SyntasticStatuslineFlag()}
  120. set statusline+=%*
  121. "let g:syntastic_always_populate_loc_list = 1
  122. "let g:syntastic_auto_loc_list = 0
  123. "let g:syntastic_check_on_open = 1
  124. "let g:syntastic_check_on_wq = 1
  125. "let g:syntastic_aggregate_errors = 1
  126. """""""""""""""""""""""""""""""""""""""""""""""""
  127. """"""""""""""""""""""""""""""""""""""""""""""""""
  128. "use gotags binary file; same to go
  129. "Bundle 'majutsushi/tagbar'
  130. "use with `gotags -R .`
  131. "nmap <F3> :TagbarToggle<CR>
  132. "let g:tagbar_type_go = {
  133. " \ 'ctagstype' : 'go',
  134. " \ 'kinds' : [
  135. " \ 'p:package',
  136. " \ 'i:imports:1',
  137. " \ 'c:constants',
  138. " \ 'v:variables',
  139. " \ 't:types',
  140. " \ 'n:interfaces',
  141. " \ 'w:fields',
  142. " \ 'e:embedded',
  143. " \ 'm:methods',
  144. " \ 'r:constructor',
  145. " \ 'f:functions'
  146. " \ ],
  147. " \ 'sro' : '.',
  148. " \ 'kind2scope' : {
  149. " \ 't' : 'ctype',
  150. " \ 'n' : 'ntype'
  151. " \ },
  152. " \ 'scope2kind' : {
  153. " \ 'ctype' : 't',
  154. " \ 'ntype' : 'n'
  155. " \ },
  156. " \ 'ctagsbin' : 'gotags',
  157. " \ 'ctagsargs' : '-sort -silent'
  158. " \ }
  159. """""""""""""""""""""""""""""""""""""
  160. " for go dir list
  161. map <F2> :NERDTreeToggle<CR>
  162. map <C-F1> :NERDTreeFind<CR>
  163. let NERDTreeChDirMode=2
  164. let NERDTreeQuitOnOpen=1
  165. let NERDTreeShowBookmarks=1
  166. let NERDTreeMinimalUI=1
  167. let NERDTreeDirArrows=1
  168. "let NERDTreeWinPos="right"
  169. " auto exit win when vim quit
  170. autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") &&b:NERDTreeType == "primary") | q | endif
  171. "auto open NERDTree
  172. "autocmd vimenter * NERDTree
  173. "
  174. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  175. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  176. " godef plugins
  177. " split windows
  178. let g:godef_split=1
  179. " open new windows
  180. let g:godef_split=2
  181. let g:godef_same_file_in_same_window=1
  182. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  183. "hi CursorLine cterm=NONE ctermfg=white guibg=darkred guifg=white
  184. "hi CursorColumn cterm=NONE ctermfg=white guibg=darkred guifg=white
  185. "ctermbg=darkred ctermbg=darkred
  186. """"""""""""""""""""""""""""""""""""""""""
  187. "filetype plugin indent on
  188. "set completeopt=longest,menu
  189. "set cscopetag
  190. "let Tlist_WinHeight
  191. "set list
  192. "set lcs=tab:\|\
  193. "match LeaderTab /^\t/
  194. " for c cscope command
  195. if has("cscope")
  196. set csprg=/usr/bin/cscope
  197. set csto=0
  198. set cst
  199. set nocsverb
  200. if filereadable("cscope.out")
  201. cs add cscope.out
  202. elseif $CSCOPE_DB!=""
  203. cs add $CSCOPE_DB
  204. endif
  205. set csverb
  206. endif
  207. "
  208. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  209. "set stal=3
  210. "vim status line
  211. set laststatus=2 "显示状态栏(默认值为1, 无法显示状态栏)
  212. "set statusline=
  213. set statusline+=%2*%-3.3n%0*\
  214. set statusline+=%f\ " file name
  215. set statusline+=%h%1*%m%r%w%0*
  216. set statusline+=[
  217. if v:version >= 600
  218. set statusline+=%{strlen(&ft)?&ft:'none'},
  219. set statusline+=%{&fileencoding},
  220. endif
  221. set statusline+=%{&fileformat}]
  222. set statusline+=%=
  223. "set statusline+=%2*0x%-8B\ " current char
  224. set statusline+=0x%-8B
  225. set statusline+=%-14.(%l,%c%V%)
  226. if filereadable(expand("$VIM/vimfiles/plugin/vimbuddy.vim"))
  227. set statusline+=\ %{VimBuddy()} " vim buddy
  228. endif
  229. ""highlight StatusLine guifg=SlateBlue guibg=Yellow
  230. "highlight StatusLineNC guifg=Gray guibg=White
  231. "
  232. ""设置路径,多个路径用逗号分隔
  233. "set path=.,"E:/Web/htdocs",,
  234. "
  235. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  236. ""缺省不产生备份文件
  237. set nobackup
  238. ""在输入括号时光标会短暂地跳到与之相匹配的括号处,不影响输入
  239. "set showmatch
  240. ""正确地处理中文字符的折行和拼接
  241. set formatoptions+=mM
  242. ""置粘贴模式,这样粘贴过来的程序代码就不会错位了。
  243. "set paste
  244. "
  245. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  246. " for c tags cTagList
  247. "map <F4> :silent! Tlist<CR>
  248. "let Tlist_Auto_Open=0
  249. "let Tlist_Use_Right_Window=1
  250. "let Tlist_WinWidth=25
  251. "let Tlist_Show_One_File=1 "²»ͬʱÏʾ¶àμþµÄag£¬ֻÏʾµ±ǰμþµÄ
  252. "let Tlist_Exit_OnlyWindow=1 "ȹûist´°¿ÚÇîһ¸����ڣ¬Ôͳö
  253. "let Tlist_Ctags_Cmd="/usr/bin/ctags"
  254. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  255. "syntax enable
  256. syntax on
  257. "set filetype=on
  258. "set filetype=go
  259. "set filetype=python
  260. "set filetype=c
  261. au BufReadPost * if line("'\"") > 0| if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
  262. au BufRead,BufNewFile *.go set filetype=go "" set golang syntax on
  263. function! CurDir()
  264. let curdir = substitute(getcwd(), $HOME, "~", "g")
  265. return curdir
  266. endfunction
  267. set statusline=[%n]\ %f%m%r%h\ \|\ \ pwd:\ %{CurDir()}\ \ \|%=\|
  268. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  269. "set statusline=[%n]\ %f%m%r%h\ \|\ \ pwd:\ %{CurDir()}\ \ \|%=\|\ %l,%c\ %p%%\ \|\ ascii=%b,hex=%b%{((&fenc==\"\")?\"\":\"\ \|\ \".&fenc)}\ \|\ %{$USER}\ @\ %{hostname()}\
  270. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""one line

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/340676
推荐阅读
相关标签
  

闽ICP备14008679号