From fe6d28af40c616f512945d8973373c4cabe1c07d Mon Sep 17 00:00:00 2001 From: Thomas Ruoff Date: Wed, 2 Nov 2016 23:47:52 +0100 Subject: [PATCH 1/6] pretty sure I do not need this here --- vimrc | 2 -- 1 file changed, 2 deletions(-) diff --git a/vimrc b/vimrc index db7c9be..c464991 100644 --- a/vimrc +++ b/vimrc @@ -1,7 +1,5 @@ set encoding=utf-8 scriptencoding utf-8 -set fileencoding=utf-8 -set fileencodings=utf-8 call plug#begin('~/.vim/plugged') From bbec5eb06f4842928106bc24cd6d32f9932e374b Mon Sep 17 00:00:00 2001 From: Thomas Ruoff Date: Wed, 2 Nov 2016 23:50:45 +0100 Subject: [PATCH 2/6] clean out plugins not really sure if needed --- vimrc | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/vimrc b/vimrc index c464991..27c83b8 100644 --- a/vimrc +++ b/vimrc @@ -13,22 +13,13 @@ Plug 'Raimondi/delimitMate' Plug 'editorconfig/editorconfig-vim' -Plug 'Shougo/unite.vim' -Plug 'ctrlpvim/ctrlp.vim' - -Plug 'scrooloose/nerdtree' -Plug 'scrooloose/nerdcommenter' - Plug 'Valloric/YouCompleteMe', { 'do': './install.sh --tern-completer' } -Plug 'mbbill/undotree' - Plug 'nathanaelkane/vim-indent-guides' Plug 'SirVer/ultisnips' Plug 'honza/vim-snippets' -Plug 'sheerun/vim-polyglot' Plug 'scrooloose/syntastic' Plug 'tpope/vim-fugitive' @@ -38,8 +29,6 @@ Plug 'airblade/vim-gitgutter' Plug 'inside/vim-search-pulse' Plug 'mileszs/ack.vim' -Plug 'BufOnly.vim' - Plug 'itchyny/lightline.vim' Plug 'chriskempson/base16-vim' From 54cb579bb199b76efbecc66b130f62680ee4f1c3 Mon Sep 17 00:00:00 2001 From: Thomas Ruoff Date: Wed, 2 Nov 2016 23:51:58 +0100 Subject: [PATCH 3/6] use vim-jsx, as it extends the filetype remove javascript specific settings --- vimrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vimrc b/vimrc index 27c83b8..9882387 100644 --- a/vimrc +++ b/vimrc @@ -33,9 +33,9 @@ Plug 'itchyny/lightline.vim' Plug 'chriskempson/base16-vim' -Plug 'pangloss/vim-javascript', { 'for': 'javascript' } -Plug 'marijnh/tern_for_vim', { 'do': 'npm install', 'for': 'javascript' } -Plug 'mxw/vim-jsx', { 'for': 'javascript' } +Plug 'pangloss/vim-javascript' +Plug 'marijnh/tern_for_vim', { 'do': 'npm install' } +Plug 'mxw/vim-jsx' Plug 'suan/vim-instant-markdown', { 'for': 'markdown' } Plug 'xuhdev/vim-latex-live-preview', { 'for': 'tex' } From d4496601d76c9b82e1f544bc22c80db6397cb8f7 Mon Sep 17 00:00:00 2001 From: Thomas Ruoff Date: Wed, 2 Nov 2016 23:54:42 +0100 Subject: [PATCH 4/6] clean up a little --- vimrc | 123 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 64 insertions(+), 59 deletions(-) diff --git a/vimrc b/vimrc index 9882387..be857ba 100644 --- a/vimrc +++ b/vimrc @@ -43,7 +43,7 @@ Plug 'xuhdev/vim-latex-live-preview', { 'for': 'tex' } call plug#end() "" enable local .vimrc -set exrc " Enable use of directory-specific .vimrc +set exrc " Enable use of directory-specific .vimrc set secure " Only run autocommands owned by me "" Tabs. May be overriten by autocmd rules @@ -59,13 +59,49 @@ set hidden set hlsearch set smartcase -"" Directories for swp files +"" find +set path+=** + +"" Display all matching files when we tab complete +set wildmenu + +"set wildignorecase +set wildignore+=.git,.hg,.svn +set wildignore+=*.aux,*.out,*.toc +set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest,*.rbc,*.class +set wildignore+=*.ai,*.bmp,*.gif,*.ico,*.jpg,*.jpeg,*.png,*.psd,*.webp +set wildignore+=*.avi,*.m4a,*.mp3,*.oga,*.ogg,*.wav,*.webm +set wildignore+=*.eot,*.otf,*.ttf,*.woff +set wildignore+=*.doc,*.pdf +set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz +set wildignore+=*.swp,.lock,.DS_Store,._* + +"" saving +set fileformats=unix,dos,mac +set fileformat=unix + +"" backups + +" Use backup files when writing (create new file, replace old one with new +" one) +set writebackup +" but do not leave around backup.xyz~ files after that set nobackup +" backupcopy=yes is the default, just be explicit. We need this for +" webpack-dev-server and hot module reloading -- preserves special file types +" like symlinks +set backupcopy=yes nobackup + +" swap files set noswapfile -set fileformats=unix,dos,mac +" persistent undo +set undodir=~/.vim/undos +set undofile +set undolevels=1000 +set undoreload=10000 -" session management +"" session management let g:session_directory = "~/.vim/session" let g:session_autoload = "no" let g:session_autosave = "no" @@ -81,6 +117,9 @@ set modelines=10 "" Visual settings syntax enable set synmaxcol=512 + +set title + set cursorline set number @@ -99,50 +138,42 @@ if has("gui_running") set guioptions -=r endif -set title -set titleold="Terminal" -set titlestring=%F +" Display unprintable chars +set listchars=tab:▸\ ,extends:❯,precedes:❮,nbsp:␣,trail:· +set showbreak=↳ "" disable visual bell set visualbell set t_vb= -"" enable spelling +"" spelling set spelllang=en,de -" Spelling highlights. Use underline in term to prevent cursorline highlights -" from interfering -if !has("gui_running") - hi clear SpellBad - hi SpellBad cterm=underline ctermfg=red - hi clear SpellCap - hi SpellCap cterm=underline ctermfg=blue - hi clear SpellLocal - hi SpellLocal cterm=underline ctermfg=blue - hi clear SpellRare - hi SpellRare cterm=underline ctermfg=blue -endif - -" Display unprintable chars -set listchars=tab:▸\ ,extends:❯,precedes:❮,nbsp:␣ -set showbreak=↳ - " Open all folds initially set foldmethod=indent set foldlevelstart=99 " Writes to the unnamed register also writes to the * and + registers. This " makes it easy to interact with the system clipboard +set clipboard^=unnamed if has ('unnamedplus') - set clipboard=unnamedplus -else - set clipboard=unnamed + set clipboard^=unnamedplus endif +" diff +set fillchars+=diff:⣿ +set diffopt=vertical " Use in vertical diff mode +set diffopt+=filler " blank lines to keep sides aligned +set diffopt+=iwhite " Ignore whitespace changes + + " " KEY MAPPINGS " +set notimeout +set ttimeout + "" MAP LEADER noremap , \ let mapleader = "," @@ -181,8 +212,6 @@ map : :b# "" delete buffer map bd :bd -"" change directory to current buffer -map cd :cd %:p:h "" indent visual selected code without unselecting and going back to normal mode vmap > >gv vmap < r :%s#\<=expand("")\># -"" strip all trailing whitespace in the current file -nnoremap W :%s/\s\+$//e:let @/='' - "" fast editing of the .vimrc nmap ev :e $MYVIMRC nmap sv :so $MYVIMRC @@ -221,10 +247,6 @@ nmap ii :set invrelativenumber "" 0: Run the visually selected code in node and replace it with the output vnoremap 0 :!node -"" +/-: Increment number -nnoremap + -nnoremap - - " debugging, use leader-DD to start, do a slow action, then leader-DQ to " finish. Your output will be in profile.log nnoremap DD :exe ":profile start profile.log":exe ":profile func *":exe ":profile file *" @@ -242,18 +264,6 @@ cnoreabbrev W w cnoreabbrev Q q cnoreabbrev Qall qall -" session management -nnoremap so :OpenSession -nnoremap ss :SaveSession -nnoremap sd :DeleteSession -nnoremap sc :CloseSession - -" persistent undo -set undodir=~/.vim/undos -set undofile -set undolevels=1000 -set undoreload=10000 - " " Plugin Configuration " @@ -270,7 +280,6 @@ let g:syntastic_check_on_open = 1 let g:syntastic_check_on_wq = 0 " local linter support - let g:syntastic_javascript_checkers = [] function! CheckJavaScriptLinter(filepath, linter) @@ -309,16 +318,9 @@ nmap j ]e vmap k [egv vmap j ]egv -"" Make Ctrl-P plugin a lot faster for Git projects -let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f'] -let g:ctrlp_use_caching = 0 - "" Indent Guides nmap g :IndentGuidesToggle -"" Gundo -nmap u :UndotreeToggle - "" YouCompleteMe let g:ycm_key_list_select_completion = ['', ''] let g:ycm_key_list_previous_completion = ['', ''] @@ -333,8 +335,11 @@ let g:UltiSnipsJumpForwardTrigger="" let g:tex_flavor = "latex" let g:livepreview_previewer = 'zathura' -" JSX -let g:jsx_ext_required = 0 " Allow JSX in normal JS files +" markdown +let g:markdown_fenced_languages = [ + \ 'html', + \ 'javascript', 'js=javascript', 'json=javascript' + \ ] " " Autocmd Rules From c059dc18a914c17c67cf2d3fe2e5544b088681ad Mon Sep 17 00:00:00 2001 From: Thomas Ruoff Date: Wed, 2 Nov 2016 23:55:39 +0100 Subject: [PATCH 5/6] update vim-plug --- vim/autoload/plug.vim | 259 ++++++++++++++++++++++++++++-------------- 1 file changed, 173 insertions(+), 86 deletions(-) diff --git a/vim/autoload/plug.vim b/vim/autoload/plug.vim index d6f7afc..4a1a57b 100644 --- a/vim/autoload/plug.vim +++ b/vim/autoload/plug.vim @@ -98,6 +98,7 @@ let s:plug_buf = get(s:, 'plug_buf', -1) let s:mac_gui = has('gui_macvim') && has('gui_running') let s:is_win = has('win32') || has('win64') let s:nvim = has('nvim') && exists('*jobwait') && !s:is_win +let s:vim8 = has('patch-8.0.0039') && exists('*job_start') let s:me = resolve(expand(':p')) let s:base_spec = { 'branch': 'master', 'frozen': 0 } let s:TYPE = { @@ -202,7 +203,9 @@ function! plug#end() endif let lod = { 'ft': {}, 'map': {}, 'cmd': {} } - filetype off + if exists('g:did_load_filetypes') + filetype off + endif for name in g:plugs_order if !has_key(g:plugs, name) continue @@ -256,8 +259,8 @@ function! plug#end() for [mode, map_prefix, key_prefix] in \ [['i', '', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']] execute printf( - \ '%snoremap %s %s:call lod_map(%s, %s, "%s")', - \ mode, map, map_prefix, string(map), string(names), key_prefix) + \ '%snoremap %s %s:call lod_map(%s, %s, %s, "%s")', + \ mode, map, map_prefix, string(map), string(names), mode != 'i', key_prefix) endfor endfor @@ -398,7 +401,7 @@ function! s:reorg_rtp() let s:middle = get(s:, 'middle', &rtp) let rtps = map(s:loaded_names(), 's:rtp(g:plugs[v:val])') - let afters = filter(map(copy(rtps), 'globpath(v:val, "after")'), 'isdirectory(v:val)') + let afters = filter(map(copy(rtps), 'globpath(v:val, "after")'), '!empty(v:val)') let rtp = join(map(rtps, 'escape(v:val, ",")'), ',') \ . ','.s:middle.',' \ . join(map(afters, 'escape(v:val, ",")'), ',') @@ -497,7 +500,7 @@ function! s:lod_cmd(cmd, bang, l1, l2, args, names) execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args) endfunction -function! s:lod_map(map, names, prefix) +function! s:lod_map(map, names, with_prefix, prefix) call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) call s:dobufread(a:names) let extra = '' @@ -508,14 +511,19 @@ function! s:lod_map(map, names, prefix) endif let extra .= nr2char(c) endwhile - if v:count - call feedkeys(v:count, 'n') + + if a:with_prefix + let prefix = v:count ? v:count : '' + let prefix .= '"'.v:register.a:prefix + if mode(1) == 'no' + if v:operator == 'c' + let prefix = "\" . prefix + endif + let prefix .= v:operator + endif + call feedkeys(prefix, 'n') endif - call feedkeys('"'.v:register, 'n') - if mode(1) == 'no' - call feedkeys(v:operator) - endif - call feedkeys(a:prefix . substitute(a:map, '^', "\", '') . extra) + call feedkeys(substitute(a:map, '^', "\", '') . extra) endfunction function! plug#(repo, ...) @@ -568,8 +576,7 @@ function! s:infer_properties(name, repo) let fmt = get(g:, 'plug_url_format', 'https://git::@github.com/%s.git') let uri = printf(fmt, repo) endif - let dir = s:dirpath( fnamemodify(join([g:plug_home, a:name], '/'), ':p') ) - return { 'dir': dir, 'uri': uri } + return { 'dir': s:dirpath(g:plug_home.'/'.a:name), 'uri': uri } endif endfunction @@ -723,10 +730,14 @@ function! s:prepare(...) call s:job_abort() if s:switch_in() - normal q + if b:plug_preview == 1 + pc + endif + enew + else + call s:new_window() endif - call s:new_window() nnoremap q :if b:plug_preview==1pcendifbd if a:0 == 0 call s:finish_bindings() @@ -739,7 +750,7 @@ function! s:prepare(...) for k in ['', 'L', 'o', 'X', 'd', 'dd'] execute 'silent! unmap ' k endfor - setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap cursorline modifiable + setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline modifiable setf vim-plug if exists('g:syntax_on') call s:syntax() @@ -806,7 +817,15 @@ function! s:do(pull, force, todo) if type == s:TYPE.string if spec.do[0] == ':' call s:load_plugin(spec) - execute spec.do[1:] + try + execute spec.do[1:] + catch + let error = v:exception + endtry + if !s:plug_window_exists() + cd - + throw 'Warning: vim-plug was terminated by the post-update hook of '.name + endif else let error = s:bang(spec.do) endif @@ -933,8 +952,9 @@ function! s:update_impl(pull, force, args) abort call s:warn('echom', '[vim-plug] Update Neovim for parallel installer') endif - let python = (has('python') || has('python3')) && (!s:nvim || has('vim_starting')) - let ruby = has('ruby') && !s:nvim && (v:version >= 703 || v:version == 702 && has('patch374')) && !(s:is_win && has('gui_running')) && s:check_ruby() + let use_job = s:nvim || s:vim8 + let python = (has('python') || has('python3')) && !use_job + let ruby = has('ruby') && !use_job && (v:version >= 703 || v:version == 702 && has('patch374')) && !(s:is_win && has('gui_running')) && s:check_ruby() let s:update = { \ 'start': reltime(), @@ -944,7 +964,7 @@ function! s:update_impl(pull, force, args) abort \ 'pull': a:pull, \ 'force': a:force, \ 'new': {}, - \ 'threads': (python || ruby || s:nvim) ? min([len(todo), threads]) : 1, + \ 'threads': (python || ruby || use_job) ? min([len(todo), threads]) : 1, \ 'bar': '', \ 'fin': 0 \ } @@ -958,7 +978,7 @@ function! s:update_impl(pull, force, args) abort \ '--depth 1' . (s:git_version_requirement(1, 7, 10) ? ' --no-single-branch' : '') : '' " Python version requirement (>= 2.7) - if python && !has('python3') && !ruby && !s:nvim && s:update.threads > 1 + if python && !has('python3') && !ruby && !use_job && s:update.threads > 1 redir => pyv silent python import platform; print platform.python_version() redir END @@ -999,6 +1019,12 @@ function! s:update_impl(pull, force, args) abort endtry else call s:update_vim() + while use_job && has('vim_starting') + sleep 100m + if s:update.fin + break + endif + endwhile endif endfunction @@ -1014,7 +1040,7 @@ function! s:update_finish() if s:switch_in() call append(3, '- Updating ...') | 4 for [name, spec] in items(filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && (s:update.force || s:update.pull || has_key(s:update.new, v:key))')) - let pos = s:logpos(name) + let [pos, _] = s:logpos(name) if !pos continue endif @@ -1056,7 +1082,13 @@ function! s:update_finish() redraw endfor 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")')) + try + 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")')) + catch + call s:warn('echom', v:exception) + call s:warn('echo', '') + return + endtry call s:finish(s:update.pull) call setline(1, 'Updated. Elapsed time: ' . split(reltimestr(reltime(s:update.start)))[0] . ' sec.') call s:switch_out('normal! gg') @@ -1064,12 +1096,16 @@ function! s:update_finish() endfunction function! s:job_abort() - if !s:nvim || !exists('s:jobs') + if (!s:nvim && !s:vim8) || !exists('s:jobs') return endif for [name, j] in items(s:jobs) - silent! call jobstop(j.jobid) + if s:nvim + silent! call jobstop(j.jobid) + elseif s:vim8 + silent! call job_stop(j.jobid) + endif if j.new call s:system('rm -rf ' . s:shellesc(g:plugs[name].dir)) endif @@ -1077,59 +1113,88 @@ function! s:job_abort() let s:jobs = {} endfunction -" When a:event == 'stdout', data = list of strings -" When a:event == 'exit', data = returncode -function! s:job_handler(job_id, data, event) abort - if !s:plug_window_exists() " plug window closed - return s:job_abort() - endif +function! s:last_non_empty_line(lines) + let len = len(a:lines) + for idx in range(len) + let line = a:lines[len-idx-1] + if !empty(line) + return line + endif + endfor + return '' +endfunction - if a:event == 'stdout' - let complete = empty(a:data[-1]) - let lines = map(filter(a:data, 'len(v:val) > 0'), 'split(v:val, "[\r\n]")[-1]') - call extend(self.lines, lines) - let self.result = join(self.lines, "\n") - if !complete - call remove(self.lines, -1) - endif - " To reduce the number of buffer updates - let self.tick = get(self, 'tick', -1) + 1 - if self.tick % len(s:jobs) == 0 - call s:log(self.new ? '+' : '*', self.name, self.result) - endif - elseif a:event == 'exit' - let self.running = 0 - if a:data != 0 - let self.error = 1 - endif - call s:reap(self.name) - call s:tick() +function! s:job_out_cb(self, data) abort + let self = a:self + let data = remove(self.lines, -1) . a:data + let lines = map(split(data, "\n", 1), 'split(v:val, "\r", 1)[-1]') + call extend(self.lines, lines) + " 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) + call s:log(bullet, self.name, result) endif endfunction +function! s:job_exit_cb(self, data) abort + let a:self.running = 0 + let a:self.error = a:data != 0 + call s:reap(a:self.name) + call s:tick() +endfunction + +function! s:job_cb(fn, job, ch, data) + if !s:plug_window_exists() " plug window closed + return s:job_abort() + endif + call call(a:fn, [a:job, a:data]) +endfunction + +function! s:nvim_cb(job_id, data, event) abort + return a:event == 'stdout' ? + \ s:job_cb('s:job_out_cb', self, 0, join(a:data, "\n")) : + \ s:job_cb('s:job_exit_cb', self, 0, a:data) +endfunction + function! s:spawn(name, cmd, opts) - let job = { 'name': a:name, 'running': 1, 'error': 0, 'lines': [], 'result': '', - \ 'new': get(a:opts, 'new', 0), - \ 'on_stdout': function('s:job_handler'), - \ 'on_exit' : function('s:job_handler'), - \ } + let job = { 'name': a:name, 'running': 1, 'error': 0, 'lines': [''], + \ 'new': get(a:opts, 'new', 0) } let s:jobs[a:name] = job + let argv = add(s:is_win ? ['cmd', '/c'] : ['sh', '-c'], + \ has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd) if s:nvim - let argv = [ 'sh', '-c', - \ (has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd) ] + call extend(job, { + \ 'on_stdout': function('s:nvim_cb'), + \ 'on_exit': function('s:nvim_cb'), + \ }) let jid = jobstart(argv, job) if jid > 0 let job.jobid = jid else let job.running = 0 let job.error = 1 - let job.result = jid < 0 ? 'sh is not executable' : - \ 'Invalid arguments (or job table is full)' + let job.lines = [jid < 0 ? argv[0].' is not executable' : + \ 'Invalid arguments (or job table is full)'] + endif + elseif s:vim8 + let jid = job_start(argv, { + \ 'out_cb': function('s:job_cb', ['s:job_out_cb', job]), + \ 'exit_cb': function('s:job_cb', ['s:job_exit_cb', job]), + \ 'out_mode': 'raw' + \}) + if job_status(jid) == 'run' + let job.jobid = jid + else + let job.running = 0 + let job.error = 1 + let job.lines = ['Failed to start job'] endif else let params = has_key(a:opts, 'dir') ? [a:cmd, a:opts.dir] : [a:cmd] - let job.result = call('s:system', params) + let job.lines = s:lines(call('s:system', params)) let job.error = v:shell_error != 0 let job.running = 0 endif @@ -1144,7 +1209,9 @@ function! s:reap(name) endif let s:update.bar .= job.error ? 'x' : '=' - call s:log(job.error ? 'x' : '-', a:name, empty(job.result) ? 'OK' : job.result) + let bullet = job.error ? 'x' : '-' + let result = job.error ? join(job.lines, "\n") : s:last_non_empty_line(job.lines) + call s:log(bullet, a:name, empty(result) ? 'OK' : result) call s:bar() call remove(s:jobs, a:name) @@ -1163,23 +1230,31 @@ endfunction function! s:logpos(name) for i in range(4, line('$')) if getline(i) =~# '^[-+x*] '.a:name.':' - return i + for j in range(i + 1, line('$')) + if getline(j) !~ '^ ' + return [i, j - 1] + endif + endfor + return [i, i] endif endfor + return [0, 0] endfunction function! s:log(bullet, name, lines) if s:switch_in() - let pos = s:logpos(a:name) - if pos > 0 - silent execute pos 'd _' - if pos > winheight('.') - let pos = 4 + let [b, e] = s:logpos(a:name) + if b > 0 + silent execute printf('%d,%d d _', b, e) + if b > winheight('.') + let b = 4 endif else - let pos = 4 + let b = 4 endif - call append(pos - 1, s:format_message(a:bullet, a:name, a:lines)) + " FIXME For some reason, nomodifiable is set after :d in vim8 + setlocal modifiable + call append(b - 1, s:format_message(a:bullet, a:name, a:lines)) call s:switch_out() endif endfunction @@ -1193,12 +1268,12 @@ endfunction function! s:tick() let pull = s:update.pull - let prog = s:progress_opt(s:nvim) + let prog = s:progress_opt(s:nvim || s:vim8) while 1 " Without TCO, Vim stack is bound to explode if empty(s:update.todo) if empty(s:jobs) && !s:update.fin - let s:update.fin = 1 call s:update_finish() + let s:update.fin = 1 endif return endif @@ -1218,10 +1293,10 @@ while 1 " Without TCO, Vim stack is bound to explode let fetch_opt = (has_tag && !empty(globpath(spec.dir, '.git/shallow'))) ? '--depth 99999999' : '' call s:spawn(name, printf('git fetch %s %s 2>&1', fetch_opt, prog), { 'dir': spec.dir }) else - let s:jobs[name] = { 'running': 0, 'result': 'Already installed', 'error': 0 } + let s:jobs[name] = { 'running': 0, 'lines': ['Already installed'], 'error': 0 } endif else - let s:jobs[name] = { 'running': 0, 'result': error, 'error': 1 } + let s:jobs[name] = { 'running': 0, 'lines': s:lines(error), 'error': 1 } endif else call s:spawn(name, @@ -1507,10 +1582,12 @@ class Plugin(object): return result[-1] def update(self): - match = re.compile(r'git::?@') - actual_uri = re.sub(match, '', self.repo_uri()) - expect_uri = re.sub(match, '', self.args['uri']) - if actual_uri != expect_uri: + actual_uri = self.repo_uri() + expect_uri = self.args['uri'] + regex = re.compile(r'^(?:\w+://)?(?:[^@/]*@)?([^:/]*(?::[0-9]*)?)[:/](.*?)(?:\.git)?/?$') + ma = regex.match(actual_uri) + mb = regex.match(expect_uri) + if ma is None or mb is None or ma.groups() != mb.groups(): msg = ['', 'Invalid URI: {0}'.format(actual_uri), 'Expected {0}'.format(expect_uri), @@ -1669,6 +1746,11 @@ function! s:update_ruby() end end + def compare_git_uri a, b + regex = %r{^(?:\w+://)?(?:[^@/]*@)?([^:/]*(?::[0-9]*)?)[:/](.*?)(?:\.git)?/?$} + regex.match(a).to_a.drop(1) == regex.match(b).to_a.drop(1) + end + require 'thread' require 'fileutils' require 'timeout' @@ -1770,9 +1852,8 @@ function! s:update_ruby() main = Thread.current threads = [] watcher = Thread.new { - while VIM::evaluate('getchar(1)') - sleep 0.1 - end + require 'io/console' # >= Ruby 1.9 + nil until IO.console.getch == 3.chr mtx.synchronize do running = false threads.each { |t| t.raise Interrupt } @@ -1810,7 +1891,7 @@ function! s:update_ruby() else [false, [data.chomp, "PlugClean required."].join($/)] end - elsif current_uri.sub(/git::?@/, '') != uri.sub(/git::?@/, '') + elsif !compare_git_uri(current_uri, uri) [false, ["Invalid URI: #{current_uri}", "Expected: #{uri}", "PlugClean required."].join($/)] @@ -1856,9 +1937,15 @@ function! s:progress_bar(line, bar, total) endfunction function! s:compare_git_uri(a, b) - let a = substitute(a:a, 'git:\{1,2}@', '', '') - let b = substitute(a:b, 'git:\{1,2}@', '', '') - return a ==# b + " See `git help clone' + " https:// [user@] github.com[:port] / junegunn/vim-plug [.git] + " [git@] github.com[:port] : junegunn/vim-plug [.git] + " file:// / junegunn/vim-plug [/] + " / junegunn/vim-plug [/] + let pat = '^\%(\w\+://\)\='.'\%([^@/]*@\)\='.'\([^:/]*\%(:[0-9]*\)\=\)'.'[:/]'.'\(.\{-}\)'.'\%(\.git\)\=/\?$' + let ma = matchlist(a:a, pat) + let mb = matchlist(a:b, pat) + return ma[1:2] ==# mb[1:2] endfunction function! s:format_message(bullet, name, message) From f110122f9f5756494c0e27e206f06b5ef288f3cd Mon Sep 17 00:00:00 2001 From: Thomas Ruoff Date: Tue, 6 Sep 2016 17:56:28 +0200 Subject: [PATCH 6/6] add abbrev to add date in uttr format --- vimrc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vimrc b/vimrc index be857ba..5f980f8 100644 --- a/vimrc +++ b/vimrc @@ -264,6 +264,8 @@ cnoreabbrev W w cnoreabbrev Q q cnoreabbrev Qall qall +iab xnow =strftime("%Y-%m-%d %H:%M") + " " Plugin Configuration "