Commit 5b79dc84 authored by Murukesh Mohanan's avatar Murukesh Mohanan

sync

parent dc8c59b6
......@@ -171,14 +171,22 @@ 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 proceed = input(a:message.' (y/N) ') =~? '^y'
let answer = input(a:message.(a:0 ? ' (y/N/a) ' : ' (y/N) '))
echohl None
call inputrestore()
echo "\r"
return proceed
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
endfunction
function! plug#end()
......@@ -196,6 +204,9 @@ function! plug#end()
filetype off
for name in g:plugs_order
if !has_key(g:plugs, name)
continue
endif
let plug = g:plugs[name]
if get(s:loaded, name, 0) || !has_key(plug, 'on') && !has_key(plug, 'for')
let s:loaded[name] = 1
......@@ -264,7 +275,7 @@ function! plug#end()
syntax enable
end
else
call s:reload()
call s:reload_plugins()
endif
endfunction
......@@ -272,9 +283,13 @@ function! s:loaded_names()
return filter(copy(g:plugs_order), 'get(s:loaded, v:val, 0)')
endfunction
function! s:reload()
function! s:load_plugin(spec)
call s:source(s:rtp(a:spec), 'plugin/**/*.vim', 'after/plugin/**/*.vim')
endfunction
function! s:reload_plugins()
for name in s:loaded_names()
call s:source(s:rtp(g:plugs[name]), 'plugin/**/*.vim', 'after/plugin/**/*.vim')
call s:load_plugin(g:plugs[name])
endfor
endfunction
......@@ -602,6 +617,7 @@ 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
......@@ -621,6 +637,7 @@ function! s:syntax()
hi def link plugUpdate Type
hi def link plugError Error
hi def link plugDeleted Ignore
hi def link plugRelDate Comment
hi def link plugEdge PreProc
hi def link plugSha Identifier
......@@ -698,6 +715,12 @@ 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
......@@ -713,10 +736,9 @@ function! s:prepare(...)
let s:plug_buf = winbufnr(0)
call s:assign_name()
silent! unmap <buffer> <cr>
silent! unmap <buffer> L
silent! unmap <buffer> o
silent! unmap <buffer> X
for k in ['<cr>', 'L', 'o', 'X', 'd', 'dd']
execute 'silent! unmap <buffer>' k
endfor
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap cursorline modifiable
setf vim-plug
if exists('g:syntax_on')
......@@ -782,7 +804,12 @@ function! s:do(pull, force, todo)
let error = ''
let type = type(spec.do)
if type == s:TYPE.string
let error = s:bang(spec.do)
if spec.do[0] == ':'
call s:load_plugin(spec)
execute spec.do[1:]
else
let error = s:bang(spec.do)
endif
elseif type == s:TYPE.funcref
try
let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged')
......@@ -793,6 +820,7 @@ function! s:do(pull, force, todo)
else
let error = 'Invalid hook type'
endif
call s:switch_in()
call setline(4, empty(error) ? (getline(4) . 'OK')
\ : ('x' . getline(4)[1:] . error))
if !empty(error)
......@@ -1016,18 +1044,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 = printf('%s %s: %s', v:shell_error ? 'x': '-', name, s:lastline(out))
let msg = s:format_message(v:shell_error ? 'x': '-', name, out)
if v:shell_error
call add(s:update.errors, name)
call s:regress_bar()
execute pos 'd _'
silent execute pos 'd _'
call append(4, msg) | 4
elseif !empty(out)
call setline(pos, msg)
call setline(pos, msg[0])
endif
redraw
endfor
4 d _
silent 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.')
......@@ -1144,7 +1172,7 @@ function! s:log(bullet, name, lines)
if s:switch_in()
let pos = s:logpos(a:name)
if pos > 0
execute pos 'd _'
silent execute pos 'd _'
if pos > winheight('.')
let pos = 4
endif
......@@ -1970,16 +1998,48 @@ function! s:clean(force)
if empty(todo)
call append(line('$'), 'Already clean.')
else
if a:force || s:ask('Proceed?')
for dir in todo
call s:rm_rf(dir)
endfor
call append(3, ['Removed.', ''])
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)
else
call append(3, ['Cancelled.', ''])
call setline(4, '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
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()
......@@ -2121,11 +2181,15 @@ function! s:preview_commit()
return
endif
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
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
setlocal nomodifiable
nnoremap <silent> <buffer> q :q<cr>
wincmd p
......@@ -2211,7 +2275,7 @@ function! s:revert()
setlocal modifiable
normal! "_dap
setlocal nomodifiable
echo 'Reverted.'
echo 'Reverted'
endfunction
function! s:snapshot(force, ...) abort
......
setlocal colorcolumn=+1
setlocal spell spelllang=en_gb
autocmd CursorHold *.md w
autocmd CursorHold *.markdown w
autocmd CursorHold <buffer> update
highlight ColorColumn ctermbg=grey guibg=grey
inoremap 1-- <!-- section -->
......@@ -13,6 +13,7 @@ inoremap <buffer> glf \gls{fr}
highlight ColorColumn ctermbg=grey guibg=grey
"let g:vimtex_latexmk_options ='-pdflatex="xelatex -shell-escape %O %S " -pdf -dvi- -ps- -synctex=1'
let g:vimtex_latexmk_options ='-pdf'
"let g:LatexBox_latexmk_options = ' -xelatex '
"let g:LatexBox_latexmk_async = 1
"let g:LatexBox_latexmk_preview_continuously = 1
......
......@@ -71,3 +71,4 @@ manpage
manpages
filetype
QEMU
deduplication
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment