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