diff --git a/vim-files/vim/autoload/plug.vim b/vim-files/vim/autoload/plug.vim index d6f7afc..ffe2f77 100644 --- a/vim-files/vim/autoload/plug.vim +++ b/vim-files/vim/autoload/plug.vim @@ -171,22 +171,14 @@ function! s:assoc(dict, key, val) let a:dict[a:key] = add(get(a:dict, a:key, []), a:val) endfunction -function! s:ask(message, ...) +function! s:ask(message) call inputsave() echohl WarningMsg - let answer = input(a:message.(a:0 ? ' (y/N/a) ' : ' (y/N) ')) + let proceed = input(a:message.' (y/N) ') =~? '^y' echohl None call inputrestore() echo "\r" - return (a:0 && answer =~? '^a') ? 2 : (answer =~? '^y') ? 1 : 0 -endfunction - -function! s:ask_no_interrupt(...) - try - return call('s:ask', a:000) - catch - return 0 - endtry + return proceed endfunction function! plug#end() @@ -617,7 +609,6 @@ function! s:syntax() syn match plugRelDate /([^)]*)$/ contained syn match plugNotLoaded /(not loaded)$/ syn match plugError /^x.*/ - syn region plugDeleted start=/^\~ .*/ end=/^\ze\S/ syn match plugH2 /^.*:\n-\+$/ syn keyword Function PlugInstall PlugStatus PlugUpdate PlugClean hi def link plug1 Title @@ -715,12 +706,6 @@ function! s:prepare(...) throw 'Invalid current working directory. Cannot proceed.' endif - for evar in ['$GIT_DIR', '$GIT_WORK_TREE'] - if exists(evar) - throw evar.' detected. Cannot proceed.' - endif - endfor - call s:job_abort() if s:switch_in() normal q @@ -736,9 +721,10 @@ function! s:prepare(...) let s:plug_buf = winbufnr(0) call s:assign_name() - for k in ['', 'L', 'o', 'X', 'd', 'dd'] - execute 'silent! unmap ' k - endfor + silent! unmap + silent! unmap L + silent! unmap o + silent! unmap X setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap cursorline modifiable setf vim-plug if exists('g:syntax_on') @@ -804,12 +790,7 @@ function! s:do(pull, force, todo) let error = '' let type = type(spec.do) 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) - endif + let error = s:bang(spec.do) elseif type == s:TYPE.funcref try 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.') let out .= s:bang('git submodule update --init --recursive 2>&1', spec.dir) 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 call add(s:update.errors, name) call s:regress_bar() - silent execute pos 'd _' + execute pos 'd _' call append(4, msg) | 4 elseif !empty(out) - call setline(pos, msg[0]) + call setline(pos, msg) endif redraw 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:finish(s:update.pull) 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) call append(line('$'), 'Already clean.') else - let s:clean_count = 0 - call append(3, ['Directories to delete:', '']) - redraw! - if a:force || s:ask_no_interrupt('Delete all directories?') - call s:delete([6, line('$')], 1) + if a:force || s:ask('Proceed?') + for dir in todo + call s:rm_rf(dir) + endfor + call append(3, ['Removed.', '']) else - call setline(4, 'Cancelled.') - nnoremap d :set opfunc=delete_opg@ - nmap dd d_ - xnoremap d :call delete_op(visualmode(), 1) - echo 'Delete the lines (d{motion}) to delete the corresponding directories' + call append(3, ['Cancelled.', '']) endif endif 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 function! s:upgrade() @@ -2181,15 +2130,11 @@ function! s:preview_commit() return endif - if exists('g:plug_pwindow') && !s:is_preview_window_open() - execute g:plug_pwindow - execute 'e' sha - else - execute 'pedit' sha - wincmd P - endif - setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable - execute 'silent %!cd' s:shellesc(g:plugs[name].dir) '&& git show --no-color --pretty=medium' sha + execute 'pedit' sha + wincmd P + setlocal filetype=git buftype=nofile nobuflisted modifiable + execute 'silent read !cd' s:shellesc(g:plugs[name].dir) '&& git show --no-color --pretty=medium' sha + normal! gg"_dd setlocal nomodifiable nnoremap q :q wincmd p diff --git a/vim-files/vimrc b/vim-files/vimrc index ebde524..b8c5dec 100644 --- a/vim-files/vimrc +++ b/vim-files/vimrc @@ -22,7 +22,6 @@ Plug 'bling/vim-airline' Plug 'myusuf3/numbers.vim' Plug 'mhinz/vim-signify' Plug 'nathanaelkane/vim-indent-guides' -Plug 'kien/rainbow_parentheses.vim' Plug 'danro/rename.vim' Plug 'pbrisbin/vim-mkdir' @@ -48,6 +47,8 @@ Plug 'tpope/vim-endwise' Plug 'benekastah/neomake' Plug 'Valloric/YouCompleteMe', { 'do': 'yes \| ./install.sh' } +Plug 'luochen1990/rainbow' + call plug#end() filetype plugin indent on " required @@ -80,9 +81,10 @@ if executable('ag') " ag is fast enough that CtrlP doesn't need to cache let g:ctrlp_use_caching = 0 endif +let g:ctrlp_custom_ignore="node_modules\|\.git\|_build" -" Gundo -map u :GundoToggle +" Mundo +map u :MundoToggle " Indent guides let g:indent_guides_start_level = 2 @@ -100,7 +102,12 @@ autocmd! BufWritePost * Neomake let g:netrw_liststyle = 3 " let netrw look like NERDTree " 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 nmap t :TestNearest @@ -139,9 +146,9 @@ set noswapfile set pastetoggle= set nowrap +syntax on filetype on filetype plugin indent on -syntax on try colorscheme jellybeans @@ -218,6 +225,7 @@ noremap Q "terminal remaps if has('nvim') tnoremap + nnoremap o :below 10sp term://$SHELLi endif " Quicker window movement