1 set nocompatible
   2 scriptencoding utf8
   3 let &langmap =
   4 \ 'ё`,йq,цw,уe,кr,еt,нy,гu,шi,щo,зp,х[,ъ],'.
   5 \ "фa,ыs,вd,аf,пg,рh,оj,лk,дl,ж\\;,э',".
   6 \ 'яz,чx,сc,мv,иb,тn,ьm,б\,,ю.,'.
   7 \ 'Ё~,ЙQ,ЦW,УE,КR,ЕT,HY,ГU,ШI,ЩO,ЗP,Х{,Ъ},'.
   8 \ 'ФA,ЫS,ВD,АF,ПG,РH,ОJ,ЛK,ДL,Ж:,Э",'.
   9 \ 'ЯZ,ЧX,СC,МV,ИB,ТN,ЬM,Б<,Ю>'
  10 
  11 set viminfo+=n~/.vim/viminfo
  12 set directory=~/.vim/swap//
  13 set undofile undodir=~/.vim/undo//
  14 if !isdirectory(expand(&directory)) " {{{
  15     call mkdir(expand(&directory), 'p')
  16 endif
  17 
  18 if !isdirectory(expand(&undodir))
  19     call mkdir(expand(&undodir), 'p')
  20 endif " }}}
  21 
  22 set titlestring=%F%{&mod?'*':''}\ -\ Vim
  23 set tabline=%!TabLine() guitablabel=%N:%t%{&mod?'*':''}
  24 function! TabLine() " {{{
  25     let s = ''
  26 
  27     for i in range(tabpagenr('$'))
  28         let n = (i + 1)
  29         let s .= (n == tabpagenr() ? '%#TabLineSel#' : '%#TabLine#')
  30         let s .= '%'.n.'T '.n.':%{TabLineLabel('.n.')} '
  31     endfor
  32 
  33     return s.'%#TabLine#%T'
  34 endfunction
  35 
  36 function! TabLineLabel(n)
  37     let list = tabpagebuflist(a:n)
  38     let num = list[tabpagewinnr(a:n) - 1]
  39 
  40     let name = fnamemodify(bufname(num), ':t')
  41     let mod = (getbufvar(num, '&mod') ? '*' : '')
  42 
  43     return (name == '' ? '[No Name]' : name.mod)
  44 endfunction " }}}
  45 
  46 set mouse=a virtualedit=block whichwrap+=<,>,[,]
  47 set mousemodel=popup_setpos keymodel=startsel
  48 set guicursor+=a:blinkwait500-blinkon500-blinkoff500
  49 let [&t_SI, &t_SR, &t_EI] = ["\e[5 q", "\e[3 q", "\e[0 q"]
  50 
  51 set autochdir lazyredraw
  52 set confirm shortmess+=A
  53 set splitbelow splitright
  54 
  55 set foldtext=FoldText() cursorline
  56 set nowrap linebreak display=lastline
  57 set hlsearch incsearch ignorecase smartcase
  58 function! FoldText() " {{{
  59     let char = matchstr(&fillchars, '.*fold:\zs.')
  60     let fold = (v:foldend - v:foldstart + 1).' lines'
  61 
  62     let line = foldtext()
  63     let line = substitute(line, '\(\d\+\)', ' \1', '')
  64     let line = substitute(line, ' .*: ', ' ', '')
  65     let line = substitute(line, '^+', '-', '')
  66 
  67     if strlen(v:folddashes) > 1 || line =~ '(' || line =~ '{'
  68         let line = substitute(line, '^-\+ ', '', '').'('.fold.')'
  69         let fill = getline(v:foldstart)
  70 
  71         if match(fill, '^\s') == 0
  72             let line = substitute(fill, '^\(\s\+\).*', '\1', '').line
  73         endif
  74     else
  75         let fold = ' '.fold
  76         let line .= repeat(char, (80 - strlen(fold) - 4 - strlen(line)))
  77         let line .= fold.' '.repeat(char, 3)
  78     endif
  79 
  80     redraw
  81     return line.repeat(' ', (winwidth(0) - strlen(line)))
  82 endfunction " }}}
  83 
  84 set spelllang+=ru fileformats+=mac
  85 set fileencodings=utf8,cp1251
  86 
  87 set ttimeoutlen=0 nrformats-=octal
  88 set nojoinspaces formatoptions+=j
  89 set completeopt=menu,menuone,longest,preview
  90 
  91 set autoindent smartindent shiftround
  92 set shiftwidth=4 tabstop=4 expandtab smarttab
  93 
  94 set report=0 showcmd
  95 set wildmenu wildignorecase
  96 set wildmode=list:longest,full
  97 
  98 " Binds {{{
  99 
 100 for s:i in range(char2nr('a'), char2nr('z'))
 101     exec 'set <A-'.nr2char(s:i).">=\e".nr2char(s:i)
 102 endfor
 103 
 104 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 105 
 106 noremap <C-a> ggVG
 107 inoremap <C-a> <C-c>ggVG
 108 
 109 vnoremap <Tab> >gv
 110 vnoremap <S-Tab> <gv
 111 inoremap <S-Tab> <C-o><<
 112 
 113 noremap <Bs> X
 114 vnoremap <Bs> <Del>
 115 
 116 noremap <C-v> "+gP
 117 inoremap <C-v> <C-r>+
 118 cnoremap <C-v> <C-r>+
 119 
 120 vnoremap <C-c> "+y
 121 vnoremap <C-x> "+x
 122 
 123 noremap <C-z> u
 124 inoremap <C-z> <C-o>u
 125 
 126 noremap <C-y> <C-r>
 127 inoremap <C-y> <C-O><C-r>
 128 
 129 noremap <C-s> :update<Cr>
 130 vnoremap <C-s> <C-c>:update<Cr>
 131 inoremap <C-s> <C-o>:update<Cr>
 132 
 133 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 134 
 135 vnoremap > >gv
 136 vnoremap < <gv
 137 
 138 nnoremap * *<C-o>
 139 nnoremap g* g*<C-o>
 140 
 141 nnoremap n nzvzz
 142 nnoremap N Nzvzz
 143 
 144 nnoremap Y y$
 145 nnoremap S i<Cr><Esc>^
 146 
 147 nnoremap <A-v> <C-v>
 148 nnoremap <A-z> <C-z>
 149 nnoremap <A-a> <C-a>
 150 nnoremap <A-x> <C-x>
 151 
 152 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 153 
 154 noremap <C-Tab> gt
 155 inoremap <C-Tab> <C-o>gt
 156 
 157 noremap <C-S-Tab> gT
 158 inoremap <C-S-Tab> <C-o>gT
 159 
 160 for s:i in range(1, 9)
 161     exec 'set <A-'.s:i.">=\e".s:i
 162     exec 'noremap <A-'.s:i.'> '.s:i.'gt'
 163     exec 'inoremap <A-'.s:i.'> <C-o>'.s:i.'gt'
 164 endfor
 165 
 166 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 167 
 168 let mapleader = ' '
 169 
 170 nmap <Leader>h :nohls<Cr>
 171 nmap <Leader>s :set spell!<Cr>
 172 nmap <Leader>w :set wrap!<Cr>
 173 
 174 nmap <Leader>n :set nu! nornu<Cr>
 175 nmap <Leader>r :set rnu! nonu<Cr>
 176 
 177 nmap <Leader>z :Goyo<Cr>
 178 
 179 " }}}
 180 " Colors {{{
 181 
 182 set t_Co=16
 183 colorscheme default
 184 
 185 hi clear
 186 syntax on
 187 
 188 hi! Visual ctermbg=NONE ctermfg=grey cterm=reverse
 189 
 190 hi! Search ctermbg=NONE ctermfg=darkYellow cterm=reverse
 191 hi! IncSearch ctermbg=NONE ctermfg=yellow cterm=reverse
 192 hi! SpellBad ctermbg=NONE ctermfg=red cterm=reverse
 193 hi! SpellCap ctermbg=NONE ctermfg=blue cterm=reverse
 194 
 195 hi! TabLine ctermbg=NONE ctermfg=grey cterm=NONE
 196 hi! LineNr ctermbg=NONE ctermfg=grey
 197 
 198 hi! SignColumn ctermbg=NONE ctermfg=NONE
 199 hi! Folded ctermbg=NONE ctermfg=grey
 200 hi! FoldColumn ctermbg=NONE ctermfg=grey
 201 
 202 hi! DiffAdd ctermbg=NONE ctermfg=green cterm=reverse
 203 hi! DiffChange ctermbg=NONE ctermfg=darkYellow cterm=reverse
 204 hi! DiffDelete ctermbg=NONE ctermfg=red cterm=reverse
 205 hi! DiffText ctermbg=NONE ctermfg=NONE cterm=reverse
 206 
 207 hi! Error ctermbg=NONE ctermfg=red
 208 hi! ErrorMsg ctermbg=NONE ctermfg=red
 209 
 210 " }}}
 211 " Statusline {{{
 212 
 213 set laststatus=2
 214 let s:statusline = ''
 215 set statusline=%1*%{StatusLine()}\ %<%F%{&mod?'*':''}\ %R%=
 216 set statusline+=%{&ff}%{&fenc!=''?'\ \ '.&fenc:''}\ %2*\ %P\ %0*
 217 function! StatusLine() " {{{
 218     let now = mode()
 219     let map = {
 220         \ 'n': 'Normal', 'i': 'Insert',
 221         \ 'v': 'Visual', 'V': 'Visual', "\<C-v>": 'Visual',
 222         \ 's': 'Replace', 'S': 'Replace', "\<C-s>": 'Replace',
 223         \ 'R': 'Replace', 'Rv': 'Replace'
 224     \ }
 225 
 226     if now == s:statusline
 227         return ''
 228     endif
 229 
 230     let s:statusline = now
 231 
 232     exec join(['hi! link', 'User2', 'Mode'.get(map, now, 'Normal')], ' ')
 233     redrawstatus
 234 
 235     return ''
 236 endfunction " }}}
 237 
 238 hi! StatusLine cterm=reverse
 239 hi! StatusLineNC ctermbg=white ctermfg=black
 240 
 241 hi! User1 ctermbg=NONE
 242 hi! link User2 ModeNormal
 243 
 244 hi! ModeNormal ctermbg=NONE ctermfg=NONE cterm=reverse
 245 hi! ModeInsert ctermbg=NONE ctermfg=blue cterm=reverse
 246 hi! ModeVisual ctermbg=NONE ctermfg=darkYellow cterm=reverse
 247 hi! ModeReplace ctermbg=NONE ctermfg=red cterm=reverse
 248 
 249 " }}}
 250 " Commands {{{
 251 
 252 au VimEnter * redraw
 253 
 254 au BufReadPre *
 255     \ if getfsize(expand('<afile>')) > (1024 * 1024) |
 256     \ setl ei+=FileType | else | setl ei-=FileType |
 257     \ endif
 258 au BufReadPost * normal g`"zz
 259 au BufWritePre *
 260     \ setl eol | retab |
 261     \ let _reg=@/ | %s/\s\+$//e | let @/=_reg | unlet _reg |
 262     \ if &fenc == 'utf-8' && &bomb | setl nobomb | endif
 263 
 264 au FileType qf setl wrap
 265 au FileType mail setl wrap spell
 266 au FileType markdown setl wrap spell
 267 au FileType *commit setl spell tw=72 sw=2
 268 au BufRead ~/.*,$HOME/.* setl fdm=marker fdc=2
 269 
 270 " }}}
 271 " Plugins {{{
 272 
 273 let s:vundle_path = expand('~/.vim/bundle/vundle.vim')
 274 let &runtimepath .= ','.s:vundle_path
 275 
 276 if !isdirectory(s:vundle_path)
 277      silent! exe '!git clone https://github.com/gmarik/vundle.vim '.s:vundle_path
 278 endif
 279 
 280 filetype off
 281 call vundle#begin(s:vundle_path.'/..')
 282 
 283 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 284 
 285 Plugin 'https://github.com/gmarik/vundle.vim'
 286 Plugin 'https://github.com/mhinz/vim-startify' " {{{
 287 let startify_list_order = [
 288     \ ['   Bookmarks:'], 'bookmarks',
 289     \ ['   Sessions:'], 'sessions',
 290     \ ['   Recent Files:'], 'files'
 291 \ ]
 292 " }}}
 293 
 294 Plugin 'https://github.com/ctrlpvim/ctrlp.vim' " {{{
 295 let g:ctrlp_prompt_mappings = {
 296     \ 'AcceptSelection("e")': ['<2-LeftMouse>'],
 297     \ 'AcceptSelection("t")': ['<Cr>', '<C-t>']
 298 \ }
 299 " }}}
 300 Plugin 'https://github.com/jeetsukumaran/vim-filebeagle'
 301 
 302 Plugin 'https://github.com/junegunn/goyo.vim'
 303 Plugin 'https://github.com/mhinz/vim-signify'
 304 Plugin 'https://github.com/junegunn/vim-peekaboo'
 305 Plugin 'https://github.com/yggdroot/indentLine' " {{{
 306 let indentLine_faster = 1
 307 let indentLine_concealcursor = 0
 308 let indentLine_color_term = 'black'
 309 " }}}
 310 
 311 Plugin 'https://github.com/shougo/neocomplcache.vim' " {{{
 312 let neocomplcache_enable_at_startup = 1
 313 let neocomplcache_enable_smart_case = 1
 314 let neocomplcache_min_syntax_length = 2
 315 let neocomplcache_min_keyword_length = 2
 316 let neocomplcache_enable_insert_char_pre = 1
 317 " }}}
 318 Plugin 'https://github.com/scrooloose/syntastic' " {{{
 319 let syntastic_check_on_open = 1
 320 let syntastic_check_on_wq = 0
 321 let syntastic_auto_loc_list = 1
 322 let syntastic_loc_list_height = 4
 323 " }}}
 324 
 325 Plugin 'https://github.com/sheerun/vim-polyglot'
 326 Plugin 'https://github.com/jamessan/vim-gnupg'
 327 
 328 " Plugin 'https://github.com/jiangmiao/auto-pairs'
 329 Plugin 'https://github.com/tpope/vim-endwise'
 330 Plugin 'https://github.com/adelarsq/vim-matchit'
 331 
 332 Plugin 'https://github.com/tpope/vim-repeat'
 333 Plugin 'https://github.com/tpope/vim-surround'
 334 Plugin 'https://github.com/tpope/vim-commentary'
 335 Plugin 'https://github.com/dhruvasagar/vim-table-mode'
 336 
 337 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 338 
 339 call vundle#end()
 340 filetype plugin indent on
 341 
 342 " }}}