Last active
September 17, 2016 16:11
-
-
Save Tehnix/3af3aa41eb15302ea9072a86d177edb1 to your computer and use it in GitHub Desktop.
Perform a git pull to update the layers repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! s:scratch_buffer() | |
rightbelow new | |
setlocal nobuflisted buftype=nofile bufhidden=wipe noswapfile | |
return bufnr('%') | |
endfunction | |
let s:update_output = ["Updating SpaceNeovim layers"] | |
function! s:update_job_control(job_id, data, event) | |
if a:event == 'stdout' || a:event == 'stderr' | |
let s:update_output += a:data | |
call nvim_buf_set_lines(self.buf, 0, -1, v:true, s:update_output) | |
else | |
set nomodifiable | |
endif | |
endfunction | |
let s:update_callbacks = { | |
\ 'on_stdout': function('s:update_job_control') | |
\, 'on_stderr': function('s:update_job_control') | |
\, 'on_exit': function('s:update_job_control') | |
\} | |
function! UpdateSpaceneovimLayers() | |
let s:config_dir = $HOME . '/.config/nvim' | |
let s:spacevim_layers_dir = expand(resolve(s:config_dir . '/spaceneovim-layers')) | |
let scratch_buffer = s:scratch_buffer() | |
call nvim_buf_set_lines(scratch_buffer, 0, -1, v:true, s:update_output) | |
let update_layers = jobstart([ | |
\ 'git' | |
\, 'pull' | |
\, 'origin' | |
\, 'master' | |
\], extend({'cwd': s:spacevim_layers_dir, 'buf': scratch_buffer}, s:update_callbacks)) | |
wincmd k | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment