Explorar el Código

Update vim-plug, simplify vim plugins

Weiyi Lou hace 1 año
padre
commit
ed92083caf
Se han modificado 4 ficheros con 46 adiciones y 22 borrados
  1. 2 5
      Makefile
  2. 0 3
      install
  3. 43 10
      vim/autoload/plug.vim
  4. 1 4
      vim/plugins.vim

+ 2 - 5
Makefile

@@ -4,7 +4,7 @@
 # Groups of targets
 all = git bash zsh tmux ack vimperator tridactyl vim
 rm-all = rm-git rm-bash rm-zsh rm-tmux rm-ack rm-vimperator rm-tridactyl rm-vim
-aux = help install uninstall upgrade show-versions submodules xdg
+aux = help install uninstall upgrade show-versions xdg
 .PHONY: $(all) $(rm-all) $(aux)
 
 # Auto-Documenting Section. Displays a target list with `##` descriptions.
@@ -28,9 +28,6 @@ show-versions: ## List versions of installed software.
 
 # Setup Tasks {{{
 
-submodules:
-	@cd ~/dotfiles && git submodule sync && git submodule update --init
-
 xdg:
 	@mkdir -p $(XDG_CONFIG_HOME)
 
@@ -61,7 +58,7 @@ rm-zsh:
 	rm ~/.zshenv
 	rm ~/.zshrc
 
-tmux: submodules
+tmux:
 	@./bin/linkup ~/dotfiles/tmux/tmux.conf ~/.tmux.conf
 rm-tmux:
 	rm ~/.tmux.conf

+ 0 - 3
install

@@ -5,9 +5,6 @@ IFS=$'\n\t'
 
 # dotfiles installer for when `make` is not available.
 
-# Initialise submodules
-(cd ~/dotfiles && git submodule sync && git submodule update --init)
-
 # XDG folder
 mkdir -p ${XDG_CONFIG_HOME:=$HOME/.config}
 

+ 43 - 10
vim/autoload/plug.vim

@@ -783,10 +783,11 @@ endfunction
 function! s:syntax()
   syntax clear
   syntax region plug1 start=/\%1l/ end=/\%2l/ contains=plugNumber
-  syntax region plug2 start=/\%2l/ end=/\%3l/ contains=plugBracket,plugX
+  syntax region plug2 start=/\%2l/ end=/\%3l/ contains=plugBracket,plugX,plugAbort
   syn match plugNumber /[0-9]\+[0-9.]*/ contained
   syn match plugBracket /[[\]]/ contained
   syn match plugX /x/ contained
+  syn match plugAbort /\~/ contained
   syn match plugDash /^-\{1}\ /
   syn match plugPlus /^+/
   syn match plugStar /^*/
@@ -811,6 +812,7 @@ function! s:syntax()
   hi def link plug2       Repeat
   hi def link plugH2      Type
   hi def link plugX       Exception
+  hi def link plugAbort   Ignore
   hi def link plugBracket Structure
   hi def link plugNumber  Number
 
@@ -908,7 +910,7 @@ function! s:prepare(...)
     endif
   endfor
 
-  call s:job_abort()
+  call s:job_abort(0)
   if s:switch_in()
     if b:plug_preview == 1
       pc
@@ -944,6 +946,8 @@ function! s:close_pane()
   if b:plug_preview == 1
     pc
     let b:plug_preview = -1
+  elseif exists('s:jobs') && !empty(s:jobs)
+    call s:job_abort(1)
   else
     bd
   endif
@@ -1326,7 +1330,12 @@ function! s:update_finish()
   endif
 endfunction
 
-function! s:job_abort()
+function! s:mark_aborted(name, message)
+  let attrs = { 'running': 0, 'error': 1, 'abort': 1, 'lines': [a:message] }
+  let s:jobs[a:name] = extend(get(s:jobs, a:name, {}), attrs)
+endfunction
+
+function! s:job_abort(cancel)
   if (!s:nvim && !s:vim8) || !exists('s:jobs')
     return
   endif
@@ -1340,8 +1349,18 @@ function! s:job_abort()
     if j.new
       call s:rm_rf(g:plugs[name].dir)
     endif
+    if a:cancel
+      call s:mark_aborted(name, 'Aborted')
+    endif
   endfor
-  let s:jobs = {}
+
+  if a:cancel
+    for todo in values(s:update.todo)
+      let todo.abort = 1
+    endfor
+  else
+    let s:jobs = {}
+  endif
 endfunction
 
 function! s:last_non_empty_line(lines)
@@ -1355,6 +1374,16 @@ function! s:last_non_empty_line(lines)
   return ''
 endfunction
 
+function! s:bullet_for(job, ...)
+  if a:job.running
+    return a:job.new ? '+' : '*'
+  endif
+  if get(a:job, 'abort', 0)
+    return '~'
+  endif
+  return a:job.error ? 'x' : get(a:000, 0, '-')
+endfunction
+
 function! s:job_out_cb(self, data) abort
   let self = a:self
   let data = remove(self.lines, -1) . a:data
@@ -1363,10 +1392,9 @@ function! s:job_out_cb(self, data) abort
   " To reduce the number of buffer updates
   let self.tick = get(self, 'tick', -1) + 1
   if !self.running || self.tick % len(s:jobs) == 0
-    let bullet = self.running ? (self.new ? '+' : '*') : (self.error ? 'x' : '-')
     let result = self.error ? join(self.lines, "\n") : s:last_non_empty_line(self.lines)
     if len(result)
-      call s:log(bullet, self.name, result)
+      call s:log(s:bullet_for(self), self.name, result)
     endif
   endif
 endfunction
@@ -1380,7 +1408,7 @@ endfunction
 
 function! s:job_cb(fn, job, ch, data)
   if !s:plug_window_exists() " plug window closed
-    return s:job_abort()
+    return s:job_abort(0)
   endif
   call call(a:fn, [a:job, a:data])
 endfunction
@@ -1452,17 +1480,16 @@ function! s:reap(name)
   endif
 
   let more = len(get(job, 'queue', []))
-  let bullet = job.error ? 'x' : more ? (job.new ? '+' : '*') : '-'
   let result = job.error ? join(job.lines, "\n") : s:last_non_empty_line(job.lines)
   if len(result)
-    call s:log(bullet, a:name, result)
+    call s:log(s:bullet_for(job), a:name, result)
   endif
 
   if !job.error && more
     let job.spec.queue = job.queue
     let s:update.todo[a:name] = job.spec
   else
-    let s:update.bar .= job.error ? 'x' : '='
+    let s:update.bar .= s:bullet_for(job, '=')
     call s:bar()
   endif
 endfunction
@@ -1541,6 +1568,12 @@ while 1 " Without TCO, Vim stack is bound to explode
 
   let name = keys(s:update.todo)[0]
   let spec = remove(s:update.todo, name)
+  if get(spec, 'abort', 0)
+    call s:mark_aborted(name, 'Skipped')
+    call s:reap(name)
+    continue
+  endif
+
   let queue = get(spec, 'queue', [])
   let new = empty(globpath(spec.dir, '.git', 1))
 

+ 1 - 4
vim/plugins.vim

@@ -11,7 +11,6 @@ Plug 'adelarsq/vim-matchit'
 Plug 'haya14busa/vim-asterisk'
 Plug 'junegunn/vim-easy-align'
 Plug 'mbbill/undotree'
-Plug 'scrooloose/nerdcommenter'
 Plug 'tpope/vim-endwise'
 Plug 'tpope/vim-fugitive'
 Plug 'tpope/vim-repeat'
@@ -40,8 +39,6 @@ Plug 'vim-scripts/argtextobj.vim'
 
 " File Browser and Search {{{
 Plug 'ctrlpvim/ctrlp.vim'
-Plug 'junegunn/fzf', { 'do': './install --bin' }
-Plug 'junegunn/fzf.vim'
 if v:version >= 704 || (v:version == 703 && has('patch438'))
   Plug 'justinmk/vim-dirvish'
 else
@@ -50,7 +47,7 @@ endif
 " }}}
 
 " Completion and Snippets {{{
-Plug 'ajh17/VimCompletesMe'
+Plug 'vim-scripts/VimCompletesMe'
 " }}}
 
 " Coding Language Support {{{