My home config
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

280 lines
7.5 KiB

  1. " http://kastaneda.kiev.ua/desktop/dotrc/vim.html
  2. " общие настройки
  3. syntax on " включить подсветку синтаксиса
  4. set ts=4 " у меня табуляция (tabstop) 4 символа
  5. set tabstop=4
  6. set shiftwidth=4
  7. set textwidth=79
  8. set tw=79
  9. set colorcolumn=80,120,160
  10. "set expandtab
  11. set autoindent
  12. set copyindent
  13. "set background=dark " весьма важная штука! :)
  14. set lbr
  15. set showcmd
  16. set nocompatible " обойдёмся без стандартного vi
  17. set backspace=indent,eol,start
  18. set nofixendofline
  19. color backbone
  20. set number
  21. nmap <F6> :set invlist<cr>
  22. " set breakindent " https://www.linux.org.ru/forum/general/10615635?lastmod=1403800233259
  23. " https://ru.wikibooks.org/wiki/Vim#%D0%A1%D0%BF%D0%BE%D1%81%D0%BE%D0%B1_2
  24. set langmap=ёйцукенгшщзхъфывапролджэячсмитьбю;`qwertyuiop[]asdfghjkl\\;'zxcvbnm\\,.,ЙЦУКЕHГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ;QWERTYUIOP{}ASDFGHJKL:\\"ZXCVBNM<>
  25. " Setup for the GNU coding format standard
  26. function! GnuIndent()
  27. setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1
  28. setlocal shiftwidth=2
  29. setlocal tabstop=4
  30. endfunction
  31. " Setup for the CPP coding format standard
  32. function! CppIndent()
  33. setlocal shiftwidth=4
  34. setlocal tabstop=4
  35. setlocal noexpandtab
  36. set textwidth=119
  37. set tw=119
  38. set colorcolumn=120,160
  39. endfunction
  40. " Setup for the Sh coding format standard
  41. function! ShIndent()
  42. setlocal shiftwidth=4
  43. setlocal tabstop=4
  44. setlocal noexpandtab
  45. endfunction
  46. " Setup for the Vala coding format standard
  47. function! ValaIndent()
  48. setlocal shiftwidth=4
  49. setlocal tabstop=4
  50. setlocal noexpandtab
  51. set textwidth=119
  52. set tw=119
  53. set colorcolumn=120,160
  54. endfunction
  55. au FileType c call GnuIndent()
  56. au FileType cpp call CppIndent()
  57. au FileType vala,vapi call ValaIndent()
  58. au FileType sh call ShIndent()
  59. " отключение бэкапов
  60. set nobackup
  61. " set backup
  62. " set backupdir=$HOME/.vim/backups
  63. " set directory=$HOME/.vim/temp
  64. " чтобы курсор не прыгал, а вёл себя так, как kwrite и т.п.
  65. nnoremap j gj
  66. nnoremap k gk
  67. vnoremap j gj
  68. vnoremap k gk
  69. nnoremap <Down> gj
  70. nnoremap <Up> gk
  71. vnoremap <Down> gj
  72. vnoremap <Up> gk
  73. inoremap <Down> <C-o>gj
  74. inoremap <Up> <C-o>gk
  75. " файлы автоматом делаются исполняемыми
  76. function ModeChange()
  77. if getline(1) =~ "^#!"
  78. if getline(1) =~ "/bin/"
  79. silent !chmod a+x <afile>
  80. endif
  81. endif
  82. endfunction
  83. au BufWritePost * call ModeChange()
  84. " интуитивные горячие клавиши =)
  85. imap <F11> <Esc>:set<Space>nu!<CR>a
  86. nmap <F11> :set<Space>nu!<CR>
  87. nmap <F2> :w<cr>
  88. vmap <F2> <esc>:w<cr>i
  89. imap <F2> <esc>:w<cr>i
  90. nmap <F10> :q!<cr>
  91. vmap <F10> <esc>:q!<cr>i
  92. imap <F10> <esc>:q!<cr>i
  93. " вкладки
  94. :set tabpagemax=99
  95. nmap <C-a> :tabnew<cr>
  96. imap <C-a> <ESC>:tabnew<cr>
  97. map <C-x>n :tabnext<cr>
  98. nmap <C-x>n :tabnext<cr>
  99. imap <C-x>n :tabnext<cr>
  100. map <C-x>p :tabprev<cr>
  101. nmap <C-x>p :tabprev<cr>
  102. imap <C-x>p :tabprev<cr>
  103. " кириллица
  104. set encoding=utf-8
  105. set termencoding=utf-8
  106. set fileencoding=utf-8
  107. set wildmenu
  108. set wcm=<Tab>
  109. menu Encoding.CP1251 :e ++enc=cp1251<CR>
  110. menu Encoding.CP866 :e ++enc=cp866<CR>
  111. menu Encoding.KOI8-U :e ++enc=koi8-u<CR>
  112. menu Encoding.UTF-8 :e ++enc=utf-8<CR>
  113. map <F8> :emenu Encoding.<TAB>
  114. set fileencodings=utf-8,cp1251,cp866,koi8-r
  115. " вкл/выкл автоперенос
  116. set pastetoggle=<F5>
  117. " set paste
  118. " nmap <F6> :set noautoindent<cr>
  119. " imap <F6> :set noautoindent<cr>
  120. " nmap <F5> :set autoindent<cr>
  121. " imap <F5> :set autoindent<cr>
  122. " inoremap <silent> <C-u> <ESC>u:set paste<CR>.:set nopaste<CR>gi " чтобы отступы не съезжали при вставке из буфера X Window
  123. " FONT SIZE SHORTCUTS
  124. set guifont=Liberation\ Mono\ 8
  125. let g:MyFontSize = 8
  126. function! ToggleMyFontSize()
  127. if ( g:MyFontSize == 10 )
  128. let g:MyFontSize = 8
  129. elseif ( g:MyFontSize == 8 )
  130. let g:MyFontSize = 9
  131. elseif ( g:MyFontSize == 9 )
  132. let g:MyFontSize = 10
  133. endif
  134. execute "set guifont=Liberation\\ Mono\\ ".g:MyFontSize
  135. endfunction
  136. nnoremap <silent> <F12> :call ToggleMyFontSize()<CR>
  137. " ctags/cscope
  138. let local_tags = ".ctags"
  139. let local_tags2 = "tags"
  140. let local_cscope = ".cscope.out"
  141. let local_cscope2 = "cscope.out"
  142. let local_path = "/"
  143. let current_path = getcwd()
  144. " If the current path is a child of $HOME directory, start from $HOME
  145. if current_path =~ $HOME
  146. let local_path = $HOME . local_path
  147. let current_path = substitute(current_path, $HOME, '', "")
  148. endif
  149. let path_parts = split(current_path, "/")
  150. for path_part in path_parts
  151. let local_path = local_path . path_part . "/"
  152. if filereadable(local_path . local_tags)
  153. exe ":set tags+=" . local_path . local_tags
  154. endif
  155. if filereadable(local_path . local_tags2)
  156. exe ":set tags+=" . local_path . local_tags2
  157. endif
  158. if filereadable(local_path . local_cscope)
  159. exe "cs add" local_path . local_cscope
  160. endif
  161. if filereadable(local_path . local_cscope2)
  162. exe "cs add" local_path . local_cscope2
  163. endif
  164. endfor
  165. unlet local_tags local_tags2 local_cscope local_cscope2 local_path current_path path_parts
  166. map <F4> [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR>
  167. " Foldging
  168. set foldenable
  169. set foldmethod=syntax
  170. " VUNDLE "
  171. set nocompatible " be iMproved
  172. filetype off " required!
  173. set rtp+=~/.vim/bundle/vundle/
  174. call vundle#rc()
  175. " let Vundle manage Vundle
  176. " required!
  177. Bundle 'gmarik/vundle'
  178. " My Bundles here:
  179. "
  180. " original repos on github
  181. Bundle 'tpope/vim-fugitive'
  182. Bundle 'Lokaltog/vim-easymotion'
  183. "Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
  184. Bundle 'tpope/vim-rails.git'
  185. " vim-scripts repos
  186. Bundle 'L9'
  187. Bundle 'FuzzyFinder'
  188. Bundle 'vim-tags'
  189. " non github repos
  190. Bundle 'git://git.wincent.com/command-t.git'
  191. " ...
  192. Bundle 'majutsushi/tagbar'
  193. Bundle 'vim-startify'
  194. Bundle 'clang-complete'
  195. Bundle 'scrooloose/nerdcommenter'
  196. filetype plugin indent on " required!
  197. "
  198. " Brief help
  199. " :BundleList - list configured bundles
  200. " :BundleInstall(!) - install(update) bundles
  201. " :BundleSearch(!) foo - search(or refresh cache first) for foo
  202. " :BundleClean(!) - confirm(or auto-approve) removal of unused bundles
  203. "
  204. " see :h vundle for more details or wiki for FAQ
  205. " NOTE: comments after Bundle command are not allowed..
  206. " clang_complete
  207. " let g:clang_complete_copen = 1
  208. " let g:clang_user_options='|| exit 0'
  209. filetype plugin on
  210. let g:clang_library_path="/usr/lib/llvm"
  211. let g:clang_user_options='|| exit 0'
  212. let g:clang_complete_auto = 1
  213. let g:clang_complete_copen = 0
  214. " ------- Vala --------
  215. " Disable valadoc syntax highlight
  216. "let vala_ignore_valadoc = 1
  217. " Enable comment strings
  218. let vala_comment_strings = 1
  219. " Highlight space errors
  220. let vala_space_errors = 1
  221. " Disable trailing space errors
  222. "let vala_no_trail_space_error = 1
  223. " Disable space-tab-space errors
  224. let vala_no_tab_space_error = 1
  225. " Minimum lines used for comment syncing (default 50)
  226. "let vala_minlines = 120
  227. " ----- Vala taglist ------
  228. " Work-around Tag List for Vala
  229. let tlist_vala_settings='c#;d:macro;t:typedef;n:namespace;c:class;'.
  230. \ 'E:event;g:enum;s:struct;i:interface;'.
  231. \ 'p:properties;m:method'
  232. " ----- TagBar ------
  233. nmap <F9> :TagbarToggle<CR>
  234. let g:tagbar_ctags_bin = "anjuta-tags"
  235. " ----- NERDTree ------
  236. nmap <F12> :NERDTreeToggle<CR>
  237. " ------- VimDiff -------
  238. if &diff
  239. let mapleader = ","
  240. map dp1 :diffput LOCAL<CR>
  241. map dp2 :diffput BASE<CR>
  242. map dp3 :diffput REMOTE<CR>
  243. map do1 :diffget LOCAL<CR>
  244. map do2 :diffget BASE<CR>
  245. map do3 :diffget REMOTE<CR>
  246. endif