*nohtml*

vim/vimrc

   1 lang messages C
   2 scriptencoding utf8
   3 
   4 set viminfo+=n~/.vim/viminfo history=1000
   5 set noswapfile undofile undodir=~/.cache/vim/undo//
   6 if !isdirectory(expand(&undodir)) " {{{
   7     call mkdir(expand(&undodir), 'p')
   8 endif " }}}
   9 
  10 set titlestring=%F%{&mod?'*':''}\ -\ Vim
  11 set tabline=%!TabLine() tabpagemax=100
  12 function! TabLine() " {{{
  13     let s = ''
  14 
  15     for i in range(tabpagenr('$'))
  16         let n  = (i + 1)
  17         let s .= (n == tabpagenr() ? '%#TabLineSel#' : '%#TabLine#')
  18         let s .= '%'.n.'T '.n.':%{TabLineLabel('.n.')} '
  19     endfor
  20 
  21     return s.'%#TabLine#%T'
  22 endfunction
  23 
  24 function! TabLineLabel(n)
  25     let list = tabpagebuflist(a:n)
  26     let num  = list[tabpagewinnr(a:n) - 1]
  27 
  28     let name = fnamemodify(bufname(num), ':t')
  29     let mod  = (getbufvar(num, '&mod') ? '*' : '')
  30 
  31     return (name == '' ? '[No Name]' : name.mod)
  32 endfunction " }}}
  33 
  34 set mouse=a mousefocus mousemodel=popup
  35 set virtualedit=block keymodel=startsel
  36 let [&t_SI, &t_SR, &t_EI] = ["\e[5 q", "\e[3 q", "\e[0 q"]
  37 
  38 set autochdir modeline lazyredraw splitbelow splitright
  39 set foldmethod=marker foldcolumn=2 foldtext=FoldText()
  40 function! FoldText() " {{{
  41     let fold = (v:foldend - v:foldstart + 1).' lines'
  42 
  43     let line = foldtext()
  44     let line = substitute(line, '\(\d\+\)', ' \1', '')
  45     let line = substitute(line, ' .*: ', ' ', '')
  46     let line = substitute(line, '^+', '-', '')
  47 
  48     if strlen(v:folddashes) > 1 || line =~ '(' || line =~ '{'
  49         let line = substitute(line, '^-\+ ', '', '').'('.fold.')'
  50         let fill = getline(v:foldstart)
  51 
  52         if match(fill, '^\s') == 0
  53             let line = substitute(fill, '^\(\s\+\).*', '\1', '').line
  54         endif
  55     else
  56         let char = matchstr(&fillchars, '.*fold:\zs.')
  57         let fill = (&colorcolumn ? &colorcolumn : 80)
  58         let fill = (fill - 1 - 4 - strlen(line))
  59 
  60         let fold  = ' '.fold
  61         let line .= repeat(char, (fill - strlen(fold)))
  62         let line .= fold.' '.repeat(char, 3)
  63     endif
  64 
  65     redraw
  66     return line.repeat(' ', (winwidth(0) - strlen(line)))
  67 endfunction " }}}
  68 
  69 set list listchars=tab:›\ ,space:·
  70 set hlsearch incsearch ignorecase smartcase
  71 set spelllang+=ru fileencodings=utf8,cp1251
  72 
  73 set nowrap linebreak display=lastline
  74 set tabstop=4 shiftwidth=0 expandtab
  75 set autoindent smartindent shiftround smarttab
  76 
  77 set ttimeoutlen=0 completeopt=menuone,noinsert
  78 set whichwrap+=<,>,[,] backspace=indent,eol,start
  79 set nojoinspaces formatoptions+=j
  80 
  81 set confirm report=0 showcmd
  82 set wildmenu wildignorecase wildmode=list:longest,full
  83 
  84 " Keys {{{
  85 
  86 let mapleader = ' '
  87 set nolangremap
  88 let &langmap  =
  89 \ 'ё`,йq,цw,уe,кr,еt,нy,гu,шi,щo,зp,х[,ъ],'.
  90 \ "фa,ыs,вd,аf,пg,рh,оj,лk,дl,ж\\;,э',".
  91 \ 'яz,чx,сc,мv,иb,тn,ьm,б\,,ю.,'.
  92 \ 'Ё~,ЙQ,ЦW,УE,КR,ЕT,HY,ГU,ШI,ЩO,ЗP,Х{,Ъ},'.
  93 \ 'ФA,ЫS,ВD,АF,ПG,РH,ОJ,ЛK,ДL,Ж:,Э",'.
  94 \ 'ЯZ,ЧX,СC,МV,ИB,ТN,ЬM,Б<,Ю>'
  95 
  96 nnoremap Y y$
  97 nnoremap n nzvzz
  98 nnoremap * *<C-o>
  99 
 100 nnoremap <Bs> X
 101 vnoremap <Bs> x
 102 
 103 vnoremap <Tab>   >gv
 104 vnoremap <S-Tab> <gv
 105 
 106 vnoremap <C-c> "+y
 107 vnoremap <C-x> "+x
 108 
 109 noremap  <C-v> "+gP
 110 inoremap <C-v> <C-r>+
 111 cnoremap <C-v> <C-r>+
 112 
 113 noremap  <C-z> u
 114 inoremap <C-z> <C-o>u
 115 noremap  <C-y> <C-r>
 116 inoremap <C-y> <C-o><C-r>
 117 
 118 noremap  <C-s>      :update<Cr>
 119 vnoremap <C-s> <C-c>:update<Cr>
 120 inoremap <C-s> <C-o>:update<Cr>
 121 
 122 nnoremap _ :Ranger<Cr>
 123 nnoremap - :RangerTab<Cr>
 124 
 125 nnoremap <Leader>h :nohls<Cr>
 126 nnoremap <Leader>R :redraw!<Cr>
 127 nnoremap <Leader>g :MagitOnly<Cr>
 128 nnoremap <Leader>n :setl nu! nornu<Cr>
 129 
 130 au FileType *       noremap <F5> :w \| make!<Cr>
 131 au FileType vimwiki noremap <F5> :VimwikiAll2HTML<Cr>
 132 
 133 for s:i in range(1, 9)
 134     exec 'set <A-'.s:i.">=\e".s:i
 135     exec 'noremap <A-'.s:i.'> '.s:i.'gt'
 136     exec 'inoremap <A-'.s:i.'> <C-o>'.s:i.'gt'
 137 endfor
 138 
 139 " }}}
 140 " Colors {{{
 141 
 142 set t_RV=
 143 set t_Co=16
 144 
 145 syntax enable
 146 colors default
 147 
 148 hi! clear
 149 
 150 hi! Visual ctermbg=NONE ctermfg=grey cterm=reverse
 151 
 152 hi! Search    ctermbg=NONE ctermfg=darkYellow cterm=reverse
 153 hi! IncSearch ctermbg=NONE ctermfg=yellow     cterm=reverse
 154 
 155 hi! SpellBad ctermbg=NONE ctermfg=red  cterm=underline
 156 hi! SpellCap ctermbg=NONE ctermfg=blue cterm=underline
 157 
 158 hi! link TabLine    StatusLine
 159 hi! link TabLineSel StatusLineMode
 160 
 161 hi! LineNr     ctermbg=NONE ctermfg=grey
 162 hi! SignColumn ctermbg=NONE ctermfg=NONE
 163 
 164 hi! Folded     ctermbg=NONE ctermfg=grey
 165 hi! FoldColumn ctermbg=NONE ctermfg=grey
 166 
 167 hi! DiffAdd    ctermbg=green      ctermfg=black
 168 hi! DiffChange ctermbg=darkYellow ctermfg=black
 169 hi! DiffDelete ctermbg=red        ctermfg=black
 170 hi! DiffText   ctermbg=black      ctermfg=white cterm=reverse
 171 
 172 hi! Error    ctermbg=NONE ctermfg=red
 173 hi! ErrorMsg ctermbg=NONE ctermfg=red
 174 
 175 hi! SpecialKey ctermbg=NONE ctermfg=darkGrey
 176 au  BufEnter * call matchadd('SpecialKey', '[ \t]')
 177 
 178 " }}}
 179 " Statusline {{{
 180 
 181 set laststatus=2
 182 set statusline=%{StatusLine()}
 183 set statusline+=%a %<%F%{&mod?'*':''} %r  %=
 184 set statusline+=   %{&ft}  %{&enc}  %{&ff}
 185 set statusline+=   %#StatusLineMode# %P %0*
 186 function! StatusLine() " {{{
 187     if mode() == s:statusline | return '' | endif
 188 
 189     let s:statusline = mode()[0]
 190     exec 'hi! link StatusLineMode Mode'.get({
 191         \ 'i': 'Insert', 'R': 'Replace',
 192         \ 'v': 'Visual', 'V': 'Visual', "\<C-v>": 'Visual'
 193     \ }, s:statusline, 'Normal')
 194 
 195     if v:version < 801
 196         redraw!
 197     else
 198         redrawstatus
 199         redrawtabline
 200     endif
 201 
 202     return ''
 203 endfunction
 204 
 205 let s:statusline = '' " }}}
 206 
 207 hi!      StatusLine     cterm=NONE
 208 hi!      StatusLineNC   cterm=NONE
 209 hi! link StatusLineMode ModeNormal
 210 
 211 hi! ModeNormal  ctermbg=NONE ctermfg=NONE       cterm=reverse,bold
 212 hi! ModeInsert  ctermbg=NONE ctermfg=blue       cterm=reverse,bold
 213 hi! ModeVisual  ctermbg=NONE ctermfg=darkYellow cterm=reverse,bold
 214 hi! ModeReplace ctermbg=NONE ctermfg=red        cterm=reverse,bold
 215 
 216 " }}}
 217 " Commands {{{
 218 
 219 au VimResized  * wincmd =
 220 au BufReadPost * normal g`"zz
 221 au BufWritePre * setl eol | retab | %s/\s\+$//e
 222 
 223 au FileType mail     setl wrap spell
 224 au FileType markdown setl wrap spell
 225 au FileType *commit  setl wrap spell tw=72 sw=2
 226 au FileType vimwiki  setl wrap spell | inoremap <buffer> <expr> <Cr>
 227 \ pumvisible() ? "\<Cr>" : "<Esc>:VimwikiReturn 1 5<Cr>"
 228 
 229 command Ranger call Ranger('sp ')
 230 command RangerTab call Ranger('tabe ')
 231 function! Ranger(cmd) " {{{
 232     let s:ranger_c = a:cmd
 233     call term_start(
 234         \ ['ranger', '--choosefiles', s:ranger_f, '--selectfile', expand('%')],
 235         \ { 'term_finish': 'close', 'exit_cb': 'RangerCb' }
 236     \ )
 237 endfunction
 238 
 239 function! RangerCb(msg, code)
 240     if !filereadable(s:ranger_f)
 241         redraw! | return
 242     endif
 243 
 244     exec s:ranger_c.join(readfile(s:ranger_f), ' | '.s:ranger_c)
 245     redraw! | call delete(s:ranger_f)
 246 endfunction
 247 
 248 let s:ranger_c = ''
 249 let s:ranger_f = tempname() " }}}
 250 
 251 au VimEnter,BufEnter,FocusGained *
 252 \ call writefile([v:servername], expand('~/.vim/vimpid'))
 253 
 254 " }}}
 255 " Plugins {{{
 256 
 257 if !filereadable(expand('~/.vim/autoload/plug.vim'))
 258     silent !curl -sLo ~/.vim/autoload/plug.vim --create-dirs
 259     \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
 260 endif
 261 
 262 call plug#begin('~/.vim/plug')
 263 
 264 Plug 'https://github.com/ctrlpvim/ctrlp.vim'
 265 Plug 'https://github.com/junegunn/vim-peekaboo'
 266 
 267 Plug 'https://github.com/jreybert/vimagit'
 268 Plug 'https://github.com/mhinz/vim-signify'
 269 
 270 Plug 'https://github.com/w0rp/ale'
 271 Plug 'https://github.com/lifepillar/vim-mucomplete'
 272 
 273 Plug 'https://github.com/sheerun/vim-polyglot'
 274 Plug 'https://github.com/jamessan/vim-gnupg'
 275 Plug 'https://github.com/calviken/vim-gdscript3'
 276 
 277 Plug 'https://github.com/tpope/vim-endwise'
 278 Plug 'https://github.com/adelarsq/vim-matchit'
 279 
 280 Plug 'https://github.com/tpope/vim-commentary'
 281 Plug 'https://github.com/nelstrom/vim-visual-star-search'
 282 
 283 Plug 'https://github.com/vimwiki/vimwiki'
 284 
 285 call plug#end()
 286 
 287 let ale_sign_warning = '>>'
 288 let ale_linters = {'c': ['gcc']}
 289 let ale_c_gcc_options = '-std=gnu11 -Wall'
 290 let magit_default_fold_level = 2
 291 let ctrlp_prompt_mappings = {
 292     \ 'AcceptSelection("e")': ['<2-LeftMouse>'],
 293     \ 'AcceptSelection("t")': ['<Cr>', '<C-t>']
 294 \ }
 295 let mucomplete#enable_auto_at_startup = 1
 296 let mucomplete#chains = {'default' : ['path', 'c-n', 'omni', 'uspl']}
 297 let vimwiki_list = [{'path': '~/Wiki/', 'path_html': '~/Wiki/html'}]
 298 
 299 " }}}