diff options
| -rw-r--r-- | .vimrc | 40 |
1 files changed, 40 insertions, 0 deletions
@@ -215,3 +215,43 @@ function! SpawnBufferLine() endfunction set tabline=%!SpawnBufferLine() " Assign the tabline + +" Add UpdateVimPackages command using the internal package system of vim +function! UpdatePackages() + " Gather all top-level package directories from both start and opt + let l:packages = globpath('~/.vim/pack/*/start/*', '', 0, 1) + globpath('~/.vim/pack/*/opt/*', '', 0, 1) + + " Open a new tab for output + tabnew | setlocal buftype=nofile | setlocal bufhidden=delete | setlocal noswapfile + setlocal nonumber " Disable line numbers + setlocal norelativenumber " Disable relative line numbers + call setline(1, ['Updating Vim Packages...'] + repeat([''], 9)) + + let l:output = [] + for package in l:packages + let l:cmd = 'cd ' . package . ' && git pull' + let l:result = system(l:cmd) + + " Remove trailing newlines from the command output + let l:result = substitute(l:result, '\n\+$', '', '') + + " Extract text between slashes from package directory + let l:package_name = matchstr(package, '/\zs[^/]\+/$') + let l:package_name = substitute(l:package_name, '/\zs$\S\+$\ze/', '\1', '') + " Remove the last slash if it exists + let l:package_name = substitute(l:package_name, '/\s*$', '', '') + +" Append the full command output to the list + call add(l:output, package_name . ': ' . l:result) + endfor + + " Show the collected output starting from line 3 + call setline(3, l:output) +endfunction + +command! UpdateVimPackages call UpdatePackages() + +" To add plugins see examples below +" git clone https://github.com/BourgeoisBear/clrzr ~/.vim/pack/plugins/start/clrzr +" +" git clone https://github.com/morhetz/gruvbox ~/.vim/pack/colorschemes/opt/gruvbox |
