update rainbow parens and stuff

This commit is contained in:
Haak Saxberg 2016-12-21 21:27:33 -08:00 committed by Haak Saxberg
parent aba7f89b92
commit d8b94beba4
2 changed files with 36 additions and 83 deletions

View file

@ -171,22 +171,14 @@ function! s:assoc(dict, key, val)
let a:dict[a:key] = add(get(a:dict, a:key, []), a:val) let a:dict[a:key] = add(get(a:dict, a:key, []), a:val)
endfunction endfunction
function! s:ask(message, ...) function! s:ask(message)
call inputsave() call inputsave()
echohl WarningMsg echohl WarningMsg
let answer = input(a:message.(a:0 ? ' (y/N/a) ' : ' (y/N) ')) let proceed = input(a:message.' (y/N) ') =~? '^y'
echohl None echohl None
call inputrestore() call inputrestore()
echo "\r" echo "\r"
return (a:0 && answer =~? '^a') ? 2 : (answer =~? '^y') ? 1 : 0 return proceed
endfunction
function! s:ask_no_interrupt(...)
try
return call('s:ask', a:000)
catch
return 0
endtry
endfunction endfunction
function! plug#end() function! plug#end()
@ -617,7 +609,6 @@ function! s:syntax()
syn match plugRelDate /([^)]*)$/ contained syn match plugRelDate /([^)]*)$/ contained
syn match plugNotLoaded /(not loaded)$/ syn match plugNotLoaded /(not loaded)$/
syn match plugError /^x.*/ syn match plugError /^x.*/
syn region plugDeleted start=/^\~ .*/ end=/^\ze\S/
syn match plugH2 /^.*:\n-\+$/ syn match plugH2 /^.*:\n-\+$/
syn keyword Function PlugInstall PlugStatus PlugUpdate PlugClean syn keyword Function PlugInstall PlugStatus PlugUpdate PlugClean
hi def link plug1 Title hi def link plug1 Title
@ -715,12 +706,6 @@ function! s:prepare(...)
throw 'Invalid current working directory. Cannot proceed.' throw 'Invalid current working directory. Cannot proceed.'
endif endif
for evar in ['$GIT_DIR', '$GIT_WORK_TREE']
if exists(evar)
throw evar.' detected. Cannot proceed.'
endif
endfor
call s:job_abort() call s:job_abort()
if s:switch_in() if s:switch_in()
normal q normal q
@ -736,9 +721,10 @@ function! s:prepare(...)
let s:plug_buf = winbufnr(0) let s:plug_buf = winbufnr(0)
call s:assign_name() call s:assign_name()
for k in ['<cr>', 'L', 'o', 'X', 'd', 'dd'] silent! unmap <buffer> <cr>
execute 'silent! unmap <buffer>' k silent! unmap <buffer> L
endfor silent! unmap <buffer> o
silent! unmap <buffer> X
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap cursorline modifiable setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap cursorline modifiable
setf vim-plug setf vim-plug
if exists('g:syntax_on') if exists('g:syntax_on')
@ -804,12 +790,7 @@ function! s:do(pull, force, todo)
let error = '' let error = ''
let type = type(spec.do) let type = type(spec.do)
if type == s:TYPE.string if type == s:TYPE.string
if spec.do[0] == ':'
call s:load_plugin(spec)
execute spec.do[1:]
else
let error = s:bang(spec.do) let error = s:bang(spec.do)
endif
elseif type == s:TYPE.funcref elseif type == s:TYPE.funcref
try try
let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged') let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged')
@ -1044,18 +1025,18 @@ function! s:update_finish()
call s:log4(name, 'Updating submodules. This may take a while.') call s:log4(name, 'Updating submodules. This may take a while.')
let out .= s:bang('git submodule update --init --recursive 2>&1', spec.dir) let out .= s:bang('git submodule update --init --recursive 2>&1', spec.dir)
endif endif
let msg = s:format_message(v:shell_error ? 'x': '-', name, out) let msg = printf('%s %s: %s', v:shell_error ? 'x': '-', name, s:lastline(out))
if v:shell_error if v:shell_error
call add(s:update.errors, name) call add(s:update.errors, name)
call s:regress_bar() call s:regress_bar()
silent execute pos 'd _' execute pos 'd _'
call append(4, msg) | 4 call append(4, msg) | 4
elseif !empty(out) elseif !empty(out)
call setline(pos, msg[0]) call setline(pos, msg)
endif endif
redraw redraw
endfor endfor
silent 4 d _ 4 d _
call s:do(s:update.pull, s:update.force, filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && has_key(v:val, "do")')) call s:do(s:update.pull, s:update.force, filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && has_key(v:val, "do")'))
call s:finish(s:update.pull) call s:finish(s:update.pull)
call setline(1, 'Updated. Elapsed time: ' . split(reltimestr(reltime(s:update.start)))[0] . ' sec.') call setline(1, 'Updated. Elapsed time: ' . split(reltimestr(reltime(s:update.start)))[0] . ' sec.')
@ -1998,48 +1979,16 @@ function! s:clean(force)
if empty(todo) if empty(todo)
call append(line('$'), 'Already clean.') call append(line('$'), 'Already clean.')
else else
let s:clean_count = 0 if a:force || s:ask('Proceed?')
call append(3, ['Directories to delete:', '']) for dir in todo
redraw! call s:rm_rf(dir)
if a:force || s:ask_no_interrupt('Delete all directories?') endfor
call s:delete([6, line('$')], 1) call append(3, ['Removed.', ''])
else else
call setline(4, 'Cancelled.') call append(3, ['Cancelled.', ''])
nnoremap <silent> <buffer> d :set opfunc=<sid>delete_op<cr>g@
nmap <silent> <buffer> dd d_
xnoremap <silent> <buffer> d :<c-u>call <sid>delete_op(visualmode(), 1)<cr>
echo 'Delete the lines (d{motion}) to delete the corresponding directories'
endif endif
endif endif
4 4
setlocal nomodifiable
endfunction
function! s:delete_op(type, ...)
call s:delete(a:0 ? [line("'<"), line("'>")] : [line("'["), line("']")], 0)
endfunction
function! s:delete(range, force)
let [l1, l2] = a:range
let force = a:force
while l1 <= l2
let line = getline(l1)
if line =~ '^- ' && isdirectory(line[2:])
execute l1
redraw!
let answer = force ? 1 : s:ask('Delete '.line[2:].'?', 1)
let force = force || answer > 1
if answer
call s:rm_rf(line[2:])
setlocal modifiable
call setline(l1, '~'.line[1:])
let s:clean_count += 1
call setline(4, printf('Removed %d directories.', s:clean_count))
setlocal nomodifiable
endif
endif
let l1 += 1
endwhile
endfunction endfunction
function! s:upgrade() function! s:upgrade()
@ -2181,15 +2130,11 @@ function! s:preview_commit()
return return
endif endif
if exists('g:plug_pwindow') && !s:is_preview_window_open()
execute g:plug_pwindow
execute 'e' sha
else
execute 'pedit' sha execute 'pedit' sha
wincmd P wincmd P
endif setlocal filetype=git buftype=nofile nobuflisted modifiable
setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable execute 'silent read !cd' s:shellesc(g:plugs[name].dir) '&& git show --no-color --pretty=medium' sha
execute 'silent %!cd' s:shellesc(g:plugs[name].dir) '&& git show --no-color --pretty=medium' sha normal! gg"_dd
setlocal nomodifiable setlocal nomodifiable
nnoremap <silent> <buffer> q :q<cr> nnoremap <silent> <buffer> q :q<cr>
wincmd p wincmd p

View file

@ -22,7 +22,6 @@ Plug 'bling/vim-airline'
Plug 'myusuf3/numbers.vim' Plug 'myusuf3/numbers.vim'
Plug 'mhinz/vim-signify' Plug 'mhinz/vim-signify'
Plug 'nathanaelkane/vim-indent-guides' Plug 'nathanaelkane/vim-indent-guides'
Plug 'kien/rainbow_parentheses.vim'
Plug 'danro/rename.vim' Plug 'danro/rename.vim'
Plug 'pbrisbin/vim-mkdir' Plug 'pbrisbin/vim-mkdir'
@ -48,6 +47,8 @@ Plug 'tpope/vim-endwise'
Plug 'benekastah/neomake' Plug 'benekastah/neomake'
Plug 'Valloric/YouCompleteMe', { 'do': 'yes \| ./install.sh' } Plug 'Valloric/YouCompleteMe', { 'do': 'yes \| ./install.sh' }
Plug 'luochen1990/rainbow'
call plug#end() call plug#end()
filetype plugin indent on " required filetype plugin indent on " required
@ -80,9 +81,10 @@ if executable('ag')
" ag is fast enough that CtrlP doesn't need to cache " ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0 let g:ctrlp_use_caching = 0
endif endif
let g:ctrlp_custom_ignore="node_modules\|\.git\|_build"
" Gundo " Mundo
map <leader>u :GundoToggle<CR> map <leader>u :MundoToggle<CR>
" Indent guides " Indent guides
let g:indent_guides_start_level = 2 let g:indent_guides_start_level = 2
@ -100,7 +102,12 @@ autocmd! BufWritePost * Neomake
let g:netrw_liststyle = 3 " let netrw look like NERDTree let g:netrw_liststyle = 3 " let netrw look like NERDTree
" Rainbow parentheses " Rainbow parentheses
autocmd VimEnter * RainbowParenthesesToggleAll let g:rainbow_conf = {
\ 'guifgs': ['RoyalBlue3', 'SeaGreen3', 'DarkOrchid3', 'firebrick3', 'RoyalBlue3', 'SeaGreen3', 'DarkOrchid3', 'firebrick3', 'RoyalBlue3', 'DarkOrchid3', 'firebrick3', 'RoyalBlue3', 'SeaGreen3', 'DarkOrchid3', 'firebrick3'],
\ 'ctermfgs': ['red', 'brown', 'blue', 'gray', 'green', 'magenta', 'cyan', 'darkred', 'brown', 'darkblue', 'gray', 'darkgreen', 'darkmagenta', 'darkcyan', 'red'],
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold']
\}
let g:rainbow_active = 1
" Vim-Test " Vim-Test
nmap <silent> <leader>t :TestNearest<CR> nmap <silent> <leader>t :TestNearest<CR>
@ -139,9 +146,9 @@ set noswapfile
set pastetoggle=<F2> set pastetoggle=<F2>
set nowrap set nowrap
syntax on
filetype on filetype on
filetype plugin indent on filetype plugin indent on
syntax on
try try
colorscheme jellybeans colorscheme jellybeans
@ -218,6 +225,7 @@ noremap Q <nop>
"terminal remaps "terminal remaps
if has('nvim') if has('nvim')
tnoremap <Esc> <C-\><C-n> tnoremap <Esc> <C-\><C-n>
nnoremap <leader>o :below 10sp term://$SHELL<cr>i
endif endif
" Quicker window movement " Quicker window movement