当前位置:   article > 正文

vim配置go_vim-gocode tarbinine-vim

vim-gocode tarbinine-vim
  1. set fileencodings=utf-8,gb2312,gbk,gb18030
  2. set termencoding=utf-8
  3. set encoding=utf-8
  4. set gfn=Consolas:h12 "字体,大小
  5. "=============================================================================
  6. " vim 内置配置
  7. "==============================================================================
  8. " 设置 vimrc 修改保存后立刻生效,不用在重新打开
  9. " 配置完成后将这个关闭
  10. autocmd BufWritePost $MYVIMRC source $MYVIMRC
  11. filetype off
  12. " 关闭兼容模式
  13. set nocompatible
  14. set showcmd "显示命令行
  15. set backspace=indent,eol,start
  16. set clipboard+=unnamed
  17. set nu " 设置行号
  18. set cursorline "突出显示当前行
  19. " set cursorcolumn " 突出显示当前列
  20. set showmatch " 显示括号匹配
  21. set backspace=2
  22. " tab 缩进
  23. set tabstop=4 " 设置Tab长度为4空格
  24. set shiftwidth=4 " 设置自动缩进长度为4空格
  25. set noswapfile "不生成swap文件
  26. set autoindent " 继承前一行的缩进方式,适用于多行注释
  27. set ruler "打开状态栏标尺
  28. set laststatus=2 "总是显示状态行
  29. set showtabline=2 "标签栏的显示,0永远不显示 1两个以上显示 2 永远显示
  30. set statusline=%F%m%r%h%w\[POS=%l,%v][%p%%]\%{strftime(\"%d/%m/%y\ -\ %H:%M\")} "我的状态行显示的内容(包括文件类型和解码)
  31. set hlsearch "搜索时高亮显示被找到的文本
  32. set foldmethod=syntax "代码折叠
  33. set fdm=indent "代码折叠
  34. set foldlevel=100 "启动vim时不要自动折叠代码
  35. nnoremap <space> zo "代码折叠快捷键
  36. let autosave=15 "15s,自动保存文件" 定义快捷键的前缀,即<Leader>
  37. let mapleader=","
  38. nnoremap <silent> <Leader>w :WMToggle <CR>
  39. " ==== 系统剪切板复制粘贴 ====
  40. " v 模式下复制内容到系统剪切板
  41. vmap <Leader>c "+yy
  42. " n 模式下复制一行到系统剪切板
  43. nmap <Leader>c "+yy
  44. " n 模式下粘贴系统剪切板的内容
  45. nmap <Leader>v "+p
  46. imap <F9> <C-x><C-o>
  47. " 开启实时搜索
  48. set incsearch
  49. " 搜索时大小写不敏感
  50. set ignorecase
  51. syntax enable
  52. :inoremap ( ()<ESC>i
  53. :inoremap ) <c-r>=ClosePair(')')<CR>
  54. :inoremap { {<CR>}<ESC>O
  55. :inoremap } <c-r>=ClosePair('}')<CR>
  56. :inoremap [ []<ESC>i
  57. :inoremap ] <c-r>=ClosePair(']')<CR>
  58. :inoremap " ""<ESC>i
  59. :inoremap ' ''<ESC>i
  60. function! ClosePair(char)
  61. if getline('.')[col('.') - 1] == a:char
  62. return "\<Right>"
  63. else
  64. return a:char
  65. endif
  66. endfunction
  67. " 退出插入模式指定类型的文件自动保存
  68. au InsertLeave *.go,*.sh,*.php write
  69. "==============================================================================
  70. " Plugin
  71. "==============================================================================
  72. " set the runtime path to include Vundle and initialize
  73. set rtp+=~/.vim/bundle/Vundle.vim
  74. call vundle#begin()
  75. Plugin 'VundleVim/Vundle.vim'
  76. " Install Vim-go
  77. Plugin 'fatih/vim-go'
  78. Plugin 'tpope/vim-fugitive'
  79. Plugin 'scrooloose/nerdtree'
  80. Plugin 'majutsushi/tagbar'
  81. Plugin 'Valloric/YouCompleteMe'
  82. " 代码自动完成,安装完插件还需要额外配置才可以使用
  83. "Plugin 'ycm-core/YouCompleteMe'
  84. call vundle#end() " required
  85. "==============================================================================
  86. " 主题配色
  87. "==============================================================================
  88. " 开启24bit的颜色,开启这个颜色会更漂亮一些
  89. " set termguicolors
  90. " 配色方案, 可以从上面插件安装中的选择一个使用
  91. "colorscheme one " 主题
  92. "set background=dark " 主题背景 dark-深色; light-浅色
  93. filetype plugin indent on
  94. syntax on " 开启文件类型侦测
  95. "==============================================================================
  96. " vim-go 插件
  97. "==============================================================================
  98. let g:go_fmt_command = "goimports" " 格式化将默认的 gofmt 替换
  99. let g:go_debug=['shell-commands']
  100. let g:go_metalinter_command = "golangci-lint" "语法校验
  101. let g:go_autodetect_gopath = 1
  102. let g:go_list_type = "quickfix"
  103. let g:go_version_warning = 1
  104. let g:go_highlight_types = 1
  105. let g:go_highlight_fields = 1
  106. let g:go_highlight_functions = 1
  107. let g:go_highlight_function_calls = 1
  108. let g:go_highlight_operators = 1
  109. let g:go_highlight_extra_types = 1
  110. let g:go_highlight_methods = 1
  111. let g:go_highlight_generate_tags = 1
  112. let g:godef_split=2
  113. " vim-go custom mappings
  114. "au FileType go nmap <Leader>s <Plug>(go-implements)
  115. "au FileType go nmap <Leader>i <Plug>(go-info)
  116. "au FileType go nmap <Leader>gd <Plug>(go-doc)
  117. "au FileType go nmap <Leader>gv <Plug>(go-doc-vertical)
  118. "au FileType go nmap <leader>r <Plug>(go-run)
  119. "au FileType go nmap <leader>b <Plug>(go-build)
  120. "au FileType go nmap <leader>t <Plug>(go-test)
  121. "au FileType go nmap <leader>c <Plug>(go-coverage)
  122. "au FileType go nmap <Leader>ds <Plug>(go-def-split)
  123. "au FileType go nmap <Leader>dv <Plug>(go-def-vertical)
  124. "au FileType go nmap <Leader>dt <Plug>(go-def-tab)
  125. "au FileType go nmap <Leader>e <Plug>(go-rename)
  126. "==============================================================================
  127. " auto-pairs 插件
  128. "==============================================================================
  129. "let g:AutoPairsFlyMode = 0
  130. "let g:AutoPairsShortcutBackInsert = '<M-b>'
  131. "==============================================================================
  132. " NERDTree 插件
  133. "==============================================================================
  134. " 打开和关闭NERDTree快捷键
  135. map <F3> :NERDTreeToggle<CR>
  136. nnoremap <silent> <Leader>n :NERDTreeToggle <CR>
  137. " 显示行号
  138. "let NERDTreeShowLineNumbers=1
  139. " 打开文件时是否显示目录
  140. let NERDTreeAutoCenter=0
  141. " 是否显示隐藏文件
  142. let NERDTreeShowHidden=0
  143. " 设置宽度
  144. let NERDTreeWinSize=25
  145. " 忽略一下文件的显示
  146. let NERDTreeIgnore=['\.pyc','\~$','\.swp']
  147. " 打开 vim 文件及显示书签列表
  148. let NERDTreeShowBookmarks=2
  149. " 在终端启动vim时,共享NERDTree
  150. let g:nerdtree_tabs_open_on_console_startup=1
  151. "==============================================================================
  152. " majutsushi/tagbar 插件
  153. "==============================================================================
  154. " majutsushi/tagbar 插件打开关闭快捷键
  155. nmap <F12> :TagbarToggle<CR>
  156. "nnoremap <silent> <Leader>t :TagbarToggle <CR>
  157. "nmap <F12>tb :TagbarToggle<CR>
  158. let g:tagbar_ctags_bin='/usr/bin/ctags'
  159. let g:tagbar_width=30
  160. "autocmd BufReadPost *.go,*.cpp,*.c,*.h,*.hpp,*.cc,*.cxx call tagbar#autoopen()
  161. let g:tagbar_type_go = {
  162. \ 'ctagstype' : 'go',
  163. \ 'kinds' : [
  164. \ 'p:package',
  165. \ 'i:imports:1',
  166. \ 'c:constants',
  167. \ 'v:variables',
  168. \ 't:types',
  169. \ 'n:interfaces',
  170. \ 'w:fields',
  171. \ 'e:embedded',
  172. \ 'm:methods',
  173. \ 'r:constructor',
  174. \ 'f:functions'
  175. \ ],
  176. \ 'sro' : '.',
  177. \ 'kind2scope' : {
  178. \ 't' : 'ctype',
  179. \ 'n' : 'ntype'
  180. \ },
  181. \ 'scope2kind' : {
  182. \ 'ctype' : 't',
  183. \ 'ntype' : 'n'
  184. \ },
  185. \ 'ctagsbin' : 'gotags',
  186. \ 'ctagsargs' : '-sort -silent'
  187. \ }
  188. "==============================================================================
  189. " nerdtree-git-Plugin 插件
  190. "==============================================================================
  191. let g:NERDTreeGitStatusIndicatorMapCustom = {
  192. \ "Modified" : "✹",
  193. \ "Staged" : "✚",
  194. \ "Untracked" : "✭",
  195. \ "Renamed" : "➜",
  196. \ "Unmerged" : "═",
  197. \ "Deleted" : "✖",
  198. \ "Dirty" : "✗",
  199. \ "Clean" : "✔︎",
  200. \ 'Ignored' : '☒',
  201. \ "Unknown" : "?"
  202. \ }
  203. let g:NERDTreeGitStatusShowIgnored = 1
  204. "==============================================================================
  205. " Valloric/YouCompleteMe 插件
  206. "==============================================================================
  207. let g:ycm_server_python_interpreter='/usr/bin/python3.6'
  208. let g:ycm_global_ycm_extra_conf='~/.vim/.ycm_extra_conf.py'
  209. "是否开启语义补全"
  210. let g:ycm_seed_identifiers_with_syntax=1
  211. "是否在注释中也开启补全"
  212. let g:ycm_complete_in_comments=1
  213. let g:ycm_collect_identifiers_from_comments_and_strings = 0
  214. "开始补全的字符数"
  215. let g:ycm_min_num_of_chars_for_completion=2
  216. "补全后自动关机预览窗口"
  217. let g:ycm_autoclose_preview_window_after_completion=1
  218. " 禁止缓存匹配项,每次都重新生成匹配项"
  219. let g:ycm_cache_omnifunc=0
  220. "字符串中也开启补全"
  221. let g:ycm_complete_in_strings = 1
  222. let g:ycm_show_diagnostics_ui = 0 "关闭语法提示
  223. let g:ycm_complete_in_comments=1 " 补全功能在注释中同样有效
  224. let g:ycm_confirm_extra_conf=0 " 允许 vim 加载 .ycm_extra_conf.py 文件,不再提示
  225. let g:ycm_collect_identifiers_from_tags_files=1 " 开启 YCM 标签补全引擎
  226. let g:ycm_min_num_of_chars_for_completion=1 " 从第一个键入字符就开始罗列匹配项
  227. let g:ycm_cache_omnifunc=0 " 禁止缓存匹配项,每次都重新生成匹配项
  228. let g:ycm_seed_identifiers_with_syntax=1 " 语法关键字补全
  229. let g:ycm_goto_buffer_command = 'horizontal-split' " 跳转打开上下分屏
  230. "离开插入模式后自动关闭预览窗口"\
  231. autocmd InsertLeave * if pumvisible() == 0|pclose|endif
  232. "回车即选中当前项"
  233. "inoremap <expr> <CR> pumvisible() ? '<C-y>' : '\<CR>'
  234. " better key bindings for UltiSnipsExpandTrigger
  235. "let g:UltiSnipsExpandTrigger = "<tab>"
  236. "let g:UltiSnipsJumpForwardTrigger = "<tab>"
  237. "let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
  238. "==============================================================================
  239. " easymotion/vim-easymotion
  240. "==============================================================================
  241. "let g:EasyMotion_do_mapping = 0 " Disable default mappings"
  242. " --暂时停用下面一行 @kevin 2019-7-18
  243. "let g:EasyMotion_leader_key = '<Space>'
  244. " Bi-directional find motion
  245. " Jump to anywhere you want with minimal keystrokes, with just one key binding.
  246. " `s{char}{label}`
  247. " --暂时停用下面一行 @kevin 2019-7-18
  248. "map s <Plug>(easymotion-s)
  249. " or
  250. " `s{char}{char}{label}`
  251. " Need one more keystroke, but on average, it may be more comfortable.
  252. ""nmap s <Plug>(easymotion-s2)
  253. ""map t <Plug>(easymotion-t2)
  254. " Turn on case insensitive feature
  255. "let g:EasyMotion_smartcase = 0
  256. " JK motions: Line motions
  257. "map <Leader>j <Plug>(easymotion-j)
  258. "map <Leader>k <Plug>(easymotion-k)
  259. " search
  260. "map // <Plug>(easymotion-sn)
  261. "omap // <Plug>(easymotion-tn)
  262. "==============================================================================
  263. " ctrlp插件
  264. "==============================================================================
  265. map <F2> :CtrlPMixed <CR>
  266. let g:ctrlp_by_filename = 0
  267. let g:ctrlp_regexp=1
  268. let g:ctrlp_working_path_mode = 'rw'
  269. let g:ctrlp_working_path_mode="ra"
  270. let g:ctrlp_lazy_update=1
  271. let g:ctrlp_use_caching=1
  272. let g:ctrlp_cache_dir=$HOME.'/.vim/.cache/ctrlp'
  273. let g:ctrlp_clear_cache_on_exit=1
  274. let g:ctrlp_max_depth=20
  275. let g:ctrlp_max_height=15
  276. set wildignore+=*/.git/*,*/.hg/*,*/.svn/*
  277. let g:ctrlp_custom_ignore={
  278. \ 'dir': '\v[\/]\.(git|hg|svn)$',
  279. \ 'file': '\v\.(exe|so|dll|a|o|tar|tar.gz|pyc|zip)$',
  280. \ 'link': 'SOME_BAD_SYMBOLIC_LINKS',
  281. \ }
  282. "==============================================================================
  283. " 多标签支持(minibuf)
  284. "==============================================================================
  285. let g:miniBufExplMapWindowNavVim=1
  286. let g:miniBufExplMapWindowNavArrows=1
  287. let g:miniBufExplMapCTabSwitchBufs=1
  288. let g:miniBufExplModSelTarget=1
  289. let g:miniBufExplorerMoreThanOne=0
  290. hi MBEVisibleActive guifg=#A6DB29 guibg=fg
  291. hi MBEVisibleChangedActive guifg=#F1266F guibg=fg
  292. hi MBEVisibleChanged guifg=#F1266F guibg=fg
  293. hi MBEVisibleNormal guifg=#5DC2D6 guibg=fg
  294. hi MBEChanged guifg=#CD5907 guibg=fg
  295. hi MBENormal guifg=#808080 guibg=fg
  296. "==============================================================================
  297. " 其他插件配置
  298. "==============================================================================
  299. " markdwon 的快捷键
  300. map <silent> <F5> <Plug>MarkdownPreview
  301. map <silent> <F6> <Plug>StopMarkdownPreview
  302. " tab 标签页切换快捷键
  303. :nn <Leader>1 1gt
  304. :nn <Leader>2 2gt
  305. :nn <Leader>3 3gt
  306. :nn <Leader>4 4gt
  307. :nn <Leader>5 5gt
  308. :nn <Leader>6 6gt
  309. :nn <Leader>7 7gt
  310. :nn <Leader>8 8gt
  311. :nn <Leader>9 8gt
  312. :nn <Leader>0 :tablast<CR>
  313. set t_Co=256
  314. colorscheme molokai
  315. "colorscheme one
  316. set background=dark " 主题背景 dark-深色; light-浅色

molokai安装:.vim文件夹下新建colors文件夹,新建文件molokai.vim

gcc-8.5:CentOS 編譯安裝 gcc/c++ 8.5

CMake导入第三方库 及 新Centos7环境配置 2022.7.1记_凉巷少年与狸猫的博客-CSDN博客

复制以下配置:

https://github.com/tomasr/molokai/blob/master/colors/molokai.vim

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

闽ICP备14008679号