*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 let &langmap  =
  88 \ 'ё`,йq,цw,уe,кr,еt,нy,гu,шi,щo,зp,х[,ъ],'.
  89 \ "фa,ыs,вd,аf,пg,рh,оj,лk,дl,ж\\;,э',".
  90 \ 'яz,чx,сc,мv,иb,тn,ьm,б\,,ю.,'.
  91 \ 'Ё~,ЙQ,ЦW,УE,КR,ЕT,HY,ГU,ШI,ЩO,ЗP,Х{,Ъ},'.
  92 \ 'ФA,ЫS,ВD,АF,ПG,РH,ОJ,ЛK,ДL,Ж:,Э",'.
  93 \ 'ЯZ,ЧX,СC,МV,ИB,ТN,ЬM,Б<,Ю>'
  94 
  95 nnoremap Y y$
  96 nnoremap * *<C-o>
  97 nnoremap n nzvzz
  98 
  99 nnoremap <Bs> X
 100 vnoremap <Bs> x
 101 vnoremap <Tab> >gv
 102 vnoremap <S-Tab> <gv
 103 
 104 vnoremap <C-c> "+y
 105 vnoremap <C-x> "+x
 106 noremap  <C-v> "+gP
 107 inoremap <C-v> <C-r>+
 108 cnoremap <C-v> <C-r>+
 109 
 110 noremap  <C-z> u
 111 inoremap <C-z> <C-o>u
 112 noremap  <C-y> <C-r>
 113 inoremap <C-y> <C-o><C-r>
 114 
 115 noremap  <C-s> :update<Cr>
 116 vnoremap <C-s> <C-c>:update<Cr>
 117 inoremap <C-s> <C-o>:update<Cr>
 118 
 119 nmap _ :Ranger<Cr>
 120 nmap - :RangerTab<Cr>
 121 
 122 nmap <F5> :w \| make!<Cr>
 123 nmap <Leader>h :nohls<Cr>
 124 nmap <Leader>R :redraw!<Cr>
 125 nmap <Leader>n :setl nu! nornu<Cr>
 126 
 127 nmap <Leader>gl :GitLog<Cr>
 128 nmap <Leader>gP :GitPush<Cr>
 129 nmap <Leader>gg :MagitOnly<Cr>
 130 
 131 au FileType vimwiki nmap <Leader>W :Vimwiki2HTMLBrowse<Cr>
 132 au BufRead *newsboat/urls nmap <Leader>S Vip:'<,'>!sort -k 2<Cr>
 133 
 134 for s:i in range(1, 9)
 135     exec 'set <A-'.s:i.">=\e".s:i
 136     exec 'noremap <A-'.s:i.'> '.s:i.'gt'
 137     exec 'inoremap <A-'.s:i.'> <C-o>'.s:i.'gt'
 138 endfor
 139 
 140 " }}}
 141 " Colors {{{
 142 
 143 set t_RV=
 144 set t_Co=16
 145 
 146 syntax enable
 147 colors default
 148 
 149 hi! clear
 150 
 151 hi! Visual ctermbg=NONE ctermfg=grey cterm=reverse
 152 
 153 hi! Search ctermbg=NONE ctermfg=darkYellow cterm=reverse
 154 hi! IncSearch ctermbg=NONE ctermfg=yellow cterm=reverse
 155 
 156 hi! SpellBad ctermbg=NONE ctermfg=red cterm=underline
 157 hi! SpellCap ctermbg=NONE ctermfg=blue cterm=underline
 158 
 159 hi! link TabLine User1
 160 hi! link TabLineSel User2
 161 
 162 hi! LineNr ctermbg=NONE ctermfg=grey
 163 hi! SignColumn ctermbg=NONE ctermfg=NONE
 164 
 165 hi! Folded ctermbg=NONE ctermfg=grey
 166 hi! FoldColumn ctermbg=NONE ctermfg=grey
 167 
 168 hi! DiffAdd ctermbg=NONE ctermfg=green cterm=reverse
 169 hi! DiffChange ctermbg=NONE ctermfg=darkYellow cterm=reverse
 170 hi! DiffDelete ctermbg=NONE ctermfg=red cterm=reverse
 171 hi! DiffText ctermbg=NONE ctermfg=NONE cterm=reverse
 172 
 173 hi! Error ctermbg=NONE ctermfg=red
 174 hi! ErrorMsg ctermbg=NONE ctermfg=red
 175 
 176 hi! SpecialKey ctermbg=NONE ctermfg=darkGrey
 177 au BufEnter * call matchadd('SpecialKey', '[ \t]')
 178 
 179 " }}}
 180 " Statusline {{{
 181 
 182 set laststatus=2
 183 set statusline=%{StatusLine()}
 184 set statusline+=%a %<%F%{&mod?'*':''} %r  %=
 185 set statusline+=   %{&ft}  %{&enc}  %{&ff}  %2* %P %0*
 186 function! StatusLine() " {{{
 187     if mode() == s:statusline
 188         return ''
 189     endif
 190 
 191     let s:statusline = mode()[0]
 192     let mode = get({
 193         \ 'i': 'Insert', 'R': 'Replace',
 194         \ 'v': 'Visual', 'V': 'Visual', "\<C-v>": 'Visual'
 195     \ }, s:statusline, 'Normal')
 196 
 197     exec 'hi! link User2 Mode'.mode
 198     redrawstatus | redrawtabline
 199 
 200     return ''
 201 endfunction
 202 
 203 let s:statusline = '' " }}}
 204 
 205 hi! StatusLine cterm=NONE
 206 hi! StatusLineNC cterm=NONE
 207 
 208 hi! User1 ctermbg=NONE
 209 hi! link User2 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 *commit setl spell tw=72 sw=2
 224 au FileType mail,markdown,vimwiki setl wrap spell
 225 
 226 au VimEnter,BufEnter,FocusGained * call writefile([v:servername], expand('~/.vim/vimpid'))
 227 au FileType vimwiki inoremap <expr> <Cr> pumvisible() ? "\<Cr>" : "<Esc>:VimwikiReturn 1 5<Cr>"
 228 
 229 command GitPush !git push
 230 command GitLog term ++close tig %
 231 
 232 command Ranger call Ranger('sp ')
 233 command RangerTab call Ranger('tabe ')
 234 function! Ranger(cmd) " {{{
 235     let s:ranger_c = a:cmd
 236     call term_start(
 237         \ ['ranger', '--choosefiles', s:ranger_f, '--selectfile', expand('%')],
 238         \ { 'term_finish': 'close', 'exit_cb': 'RangerCb' }
 239     \ )
 240 endfunction
 241 
 242 function! RangerCb(msg, code)
 243     if !filereadable(s:ranger_f)
 244         redraw! | return
 245     endif
 246 
 247     exec s:ranger_c.join(readfile(s:ranger_f), ' | '.s:ranger_c)
 248     redraw! | call delete(s:ranger_f)
 249 endfunction
 250 
 251 let s:ranger_c = ''
 252 let s:ranger_f = tempname() " }}}
 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'}]
 298 
 299 " }}}