diff --git a/cava/.config/cava/config b/cava/.config/cava/config index 9f30648..06892bc 100644 --- a/cava/.config/cava/config +++ b/cava/.config/cava/config @@ -7,19 +7,20 @@ ; mode = waves # Framerate Default: 60. Accepts only non-negative values. -; framerate = 60 +; framerate = 60 # Sensitivity in %. If you think the bars are to low/response is to littei, try # increasing this value 200 means double height. Accepts only non-negative values. -sensitivity = 1.5 +# sensitivity = 4 +sensitivity = 4 # Autosens will atempt to decrease sensitivity if cava peaks. 1 = on, 0 = off autosens = 0 # The number of bars. 0 (default) sets it to auto (fil upp console). # width of bras and space between bars in number of characters. Default witdth 3 and space 1. -; bars = 0 -bar_width = 2 +; bars = 35 +bar_width = 1 bar_spacing = 1 @@ -65,28 +66,31 @@ higher_cutoff_freq = 10000 # visual styles, may be 'stereo' or 'mono'. # Stereo mirrors both channels with low frequencies in center. # Mono avrages both channels and outputs left to right lowest to highest frequencies -style = mono +style = stereo [color] # supported colors are: red, green, yellow, magenta, cyan, white, blue, black. ; background = black -foreground = red +; foreground = red +gradient = 1 +gradient_color_1 = '#ff0000' +gradient_color_2 = '#220000' [smoothing] # multiplier for the integral smoothing calculations. Takes values from 0 - 0.99. # Higher values means smoother, but less precise. 0 to disable. -; integral = 0.7 +integral = 0 # disables or enables the so-called "Monstercat smoothing". Default: 1. Set to 0 to disable. -; monstercat = 1 +monstercat = 1 # Set gravity multiplier for "drop off". Higher values means bars will drop faster. # Accepts only non-negative values. 0.5 means half gravity, 2 means double. Set to 0 to disable "drop off". -gravity = 3 +gravity = 100 # In bar height, bars that whould have been lower that this will not be drawn. @@ -99,7 +103,7 @@ gravity = 3 # remember to uncomment more then one key! More keys = more precision. # Look at readme.md on github for further explanations and examples. ; 1 = 1 # bass -; 2 = 1 -; 3 = 1 # midtone -; 4 = 1 +; 2 = 3 +; 3 = 2 # midtone +; 4 = 2 ; 5 = 1 # treble diff --git a/gtk/.config/gtk-3.0/gtk.css b/gtk/.config/gtk-3.0/gtk.css index cb13745..c59a153 100644 --- a/gtk/.config/gtk-3.0/gtk.css +++ b/gtk/.config/gtk-3.0/gtk.css @@ -1,22 +1,30 @@ -/* .header-bar.default-decoration { */ -/* padding-top: 3px; */ -/* padding-bottom: 3px; */ -/* } */ -/* */ -/* .header-bar.default-decoration .button.titlebutton { */ -/* padding-top: 2px; */ -/* padding-bottom: 2px; */ -/* } */ +window.ssd separator:first-child + headerbar:backdrop, +window.ssd separator:first-child + headerbar, +window.ssd headerbar:first-child:backdrop, +window.ssd headerbar:first-child, +window.ssd headerbar:last-child:backdrop, +window.ssd headerbar:last-child, +window.ssd stack headerbar:first-child:backdrop, +window.ssd stack headerbar:first-child, +window.ssd stack headerbar:last-child:backdrop, +window.ssd stack headerbar:last-child, +window.ssd decoration, +window.ssd headerbar.titlebar { + border-radius: 0; +} -/* .window-frame:backdrop, */ -/* .window-frame, */ -/* .window-frame.tiled, */ -/* .window-frame.popup{ */ -/* box-shadow:none;} */ -/* */ -/* .window-frame.tooltip.csd, */ -/* .window-frame.popup.csd, */ -/* .window-frame.popup { */ -/* border-radius:0px; */ -/* box-shadow: none; */ -/* margin: 0px;} */ +window.ssd headerbar * { + margin-top: -100px; + color: #222d32; /* May need to tweak, this matches Adwaita Dark */ +} + +window.ssd headerbar.titlebar, +window.ssd headerbar.titlebar button.titlebutton { + border: none; + font-size: 0; + height: 0; + margin: 0; + max-height: 0; + min-height: 0; + padding: 0; +} diff --git a/nvim/.config/nvim/autoload/plug.vim b/nvim/.config/nvim/autoload/plug.vim index b3bc1a6..143c377 100644 --- a/nvim/.config/nvim/autoload/plug.vim +++ b/nvim/.config/nvim/autoload/plug.vim @@ -18,7 +18,7 @@ " " Any valid git URL is allowed " Plug 'https://github.com/junegunn/vim-github-dashboard.git' " -" " Group dependencies, vim-snippets depends on ultisnips +" " Multiple Plug commands can be written in a single line using | separators " Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' " " " On-demand loading @@ -40,7 +40,7 @@ " " Unmanaged plugin (manually installed and updated) " Plug '~/my-prototype-plugin' " -" " Add plugins to &runtimepath +" " Initialize plugin system " call plug#end() " " Then reload .vimrc and :PlugInstall to install plugins. @@ -61,7 +61,7 @@ " More information: https://github.com/junegunn/vim-plug " " -" Copyright (c) 2016 Junegunn Choi +" Copyright (c) 2017 Junegunn Choi " " MIT License " @@ -97,7 +97,8 @@ let s:plug_tab = get(s:, 'plug_tab', -1) 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:nvim = has('nvim-0.2') || (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 = { @@ -120,6 +121,9 @@ function! plug#begin(...) else return s:err('Unable to determine plug home. Try calling plug#begin() with a path argument.') endif + if fnamemodify(home, ':t') ==# 'plugin' && fnamemodify(home, ':h') ==# s:first_rtp + return s:err('Invalid plug home. '.home.' is a standard Vim runtime path and is not allowed.') + endif let g:plug_home = home let g:plugs = {} @@ -171,14 +175,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() @@ -194,8 +206,13 @@ 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 + 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 @@ -211,6 +228,7 @@ function! plug#end() endif call add(s:triggers[name].map, cmd) elseif cmd =~# '^[A-Z]' + let cmd = substitute(cmd, '!*$', '', '') if exists(':'.cmd) != 2 call s:assoc(lod.cmd, cmd, name) endif @@ -237,7 +255,7 @@ function! plug#end() for [cmd, names] in items(lod.cmd) execute printf( - \ 'command! -nargs=* -range -bang %s call s:lod_cmd(%s, "", , , , %s)', + \ 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "", , , , %s)', \ cmd, string(cmd), string(names)) endfor @@ -245,8 +263,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 @@ -264,7 +282,7 @@ function! plug#end() syntax enable end else - call s:reload() + call s:reload_plugins() endif endfunction @@ -272,9 +290,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 @@ -294,7 +316,7 @@ endfunction function! s:git_version_requirement(...) if !exists('s:git_version') - let s:git_version = map(split(split(s:system('git --version'))[-1], '\.'), 'str2nr(v:val)') + let s:git_version = map(split(split(s:system('git --version'))[2], '\.'), 'str2nr(v:val)') endif return s:version_requirement(s:git_version, a:000) endfunction @@ -383,7 +405,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, ",")'), ',') @@ -397,7 +419,23 @@ function! s:reorg_rtp() endfunction function! s:doautocmd(...) - execute 'doautocmd' ((v:version > 703 || has('patch442')) ? '' : '') join(a:000) + if exists('#'.join(a:000, '#')) + execute 'doautocmd' ((v:version > 703 || has('patch442')) ? '' : '') join(a:000) + endif +endfunction + +function! s:dobufread(names) + for name in a:names + let path = s:rtp(g:plugs[name]).'/**' + for dir in ['ftdetect', 'ftplugin'] + if len(finddir(dir, path)) + if exists('#BufRead') + doautocmd BufRead + endif + return + endif + endfor + endfor endfunction function! plug#load(...) @@ -407,18 +445,21 @@ function! plug#load(...) if !exists('g:plugs') return s:err('plug#begin was not called') endif - let unknowns = filter(copy(a:000), '!has_key(g:plugs, v:val)') + let names = a:0 == 1 && type(a:1) == s:TYPE.list ? a:1 : a:000 + let unknowns = filter(copy(names), '!has_key(g:plugs, v:val)') if !empty(unknowns) let s = len(unknowns) > 1 ? 's' : '' return s:err(printf('Unknown plugin%s: %s', s, join(unknowns, ', '))) end - for name in a:000 - call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) - endfor - if exists('#BufRead') - doautocmd BufRead - endif - return 1 + let unloaded = filter(copy(names), '!get(s:loaded, v:val, 0)') + if !empty(unloaded) + for name in unloaded + call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + endfor + call s:dobufread(unloaded) + return 1 + end + return 0 endfunction function! s:remove_triggers(name) @@ -453,9 +494,7 @@ function! s:lod(names, types, ...) endif call s:source(rtp, a:2) endif - if exists('#User#'.name) - call s:doautocmd('User', name) - endif + call s:doautocmd('User', name) endfor endfunction @@ -463,21 +502,19 @@ function! s:lod_ft(pat, names) let syn = 'syntax/'.a:pat.'.vim' call s:lod(a:names, ['plugin', 'after/plugin'], syn, 'after/'.syn) execute 'autocmd! PlugLOD FileType' a:pat - if exists('#filetypeplugin#FileType') - doautocmd filetypeplugin FileType - endif - if exists('#filetypeindent#FileType') - doautocmd filetypeindent FileType - endif + call s:doautocmd('filetypeplugin', 'FileType') + call s:doautocmd('filetypeindent', 'FileType') endfunction function! s:lod_cmd(cmd, bang, l1, l2, args, names) call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + call s:dobufread(a: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 = '' while 1 let c = getchar(0) @@ -486,7 +523,19 @@ function! s:lod_map(map, names, prefix) endif let extra .= nr2char(c) endwhile - call feedkeys(a:prefix . substitute(a:map, '^', "\", '') . extra) + + 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(substitute(a:map, '^', "\", '') . extra) endfunction function! plug#(repo, ...) @@ -534,13 +583,12 @@ function! s:infer_properties(name, repo) let uri = repo else if repo !~ '/' - let repo = 'vim-scripts/'. repo + throw printf('Invalid argument: %s (implicit `vim-scripts'' expansion is deprecated)', repo) endif 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 @@ -557,7 +605,7 @@ function! plug#helptags() return s:err('plug#begin was not called') endif for spec in values(g:plugs) - let docd = join([spec.dir, 'doc'], '/') + let docd = join([s:rtp(spec), 'doc'], '/') if isdirectory(docd) silent! execute 'helptags' s:esc(docd) endif @@ -581,13 +629,14 @@ function! s:syntax() syn match plugTag /(tag: [^)]\+)/ syn match plugInstall /\(^+ \)\@<=[^:]*/ syn match plugUpdate /\(^* \)\@<=[^:]*/ - syn match plugCommit /^ \X*[0-9a-f]\{7} .*/ contains=plugRelDate,plugEdge,plugTag + syn match plugCommit /^ \X*[0-9a-f]\{7,9} .*/ contains=plugRelDate,plugEdge,plugTag syn match plugEdge /^ \X\+$/ syn match plugEdge /^ \X*/ contained nextgroup=plugSha - syn match plugSha /[0-9a-f]\{7}/ contained + syn match plugSha /[0-9a-f]\{7,9}/ contained 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 @@ -607,6 +656,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 @@ -684,12 +734,22 @@ 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 + 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() @@ -699,11 +759,10 @@ function! s:prepare(...) let s:plug_buf = winbufnr(0) call s:assign_name() - silent! unmap - silent! unmap L - silent! unmap o - silent! unmap X - setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap cursorline modifiable + for k in ['', 'L', 'o', 'X', 'd', 'dd'] + execute 'silent! unmap ' k + endfor + setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline modifiable nospell setf vim-plug if exists('g:syntax_on') call s:syntax() @@ -723,8 +782,10 @@ function! s:assign_name() endfunction function! s:chsh(swap) - let prev = [&shell, &shellredir] - if !s:is_win && a:swap + let prev = [&shell, &shellcmdflag, &shellredir] + if s:is_win + set shell=cmd.exe shellcmdflag=/c shellredir=>%s\ 2>&1 + elseif a:swap set shell=sh shellredir=>%s\ 2>&1 endif return prev @@ -732,15 +793,23 @@ endfunction function! s:bang(cmd, ...) try - let [sh, shrd] = s:chsh(a:0) + let [sh, shellcmdflag, shrd] = s:chsh(a:0) " FIXME: Escaping is incomplete. We could use shellescape with eval, " but it won't work on Windows. let cmd = a:0 ? s:with_cd(a:cmd, a:1) : a:cmd - let g:_plug_bang = '!'.escape(cmd, '#!%') + if s:is_win + let batchfile = tempname().'.bat' + call writefile(['@echo off', cmd], batchfile) + let cmd = batchfile + endif + let g:_plug_bang = (s:is_win && has('gui_running') ? 'silent ' : '').'!'.escape(cmd, '#!%') execute "normal! :execute g:_plug_bang\\" finally unlet g:_plug_bang - let [&shell, &shellredir] = [sh, shrd] + let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] + if s:is_win + call delete(batchfile) + endif endtry return v:shell_error ? 'Exit status: ' . v:shell_error : '' endfunction @@ -768,7 +837,24 @@ 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] == ':' + if !get(s:loaded, name, 0) + let s:loaded[name] = 1 + call s:reorg_rtp() + endif + call s:load_plugin(spec) + 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 elseif type == s:TYPE.funcref try let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged') @@ -779,6 +865,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) @@ -799,7 +886,7 @@ function! s:checkout(spec) let output = s:system('git rev-parse HEAD', a:spec.dir) if !v:shell_error && !s:hash_match(sha, s:lines(output)[0]) let output = s:system( - \ 'git fetch --depth 999999 && git checkout '.s:esc(sha), a:spec.dir) + \ 'git fetch --depth 999999 && git checkout '.s:esc(sha).' --', a:spec.dir) endif return output endfunction @@ -846,17 +933,19 @@ function! s:names(...) endfunction function! s:check_ruby() - silent! ruby require 'thread'; VIM::command('let g:plug_ruby = 1') - if get(g:, 'plug_ruby', 0) - unlet g:plug_ruby - return 1 + silent! ruby require 'thread'; VIM::command("let g:plug_ruby = '#{RUBY_VERSION}'") + if !exists('g:plug_ruby') + redraw! + return s:warn('echom', 'Warning: Ruby interface is broken') endif - redraw! - return s:warn('echom', 'Warning: Ruby interface is broken') + let ruby_version = split(g:plug_ruby, '\.') + unlet g:plug_ruby + return s:version_requirement(ruby_version, [1, 8, 7]) endfunction function! s:update_impl(pull, force, args) abort - let args = copy(a:args) + let sync = index(a:args, '--sync') >= 0 || has('vim_starting') + let args = filter(copy(a:args), 'v:val != "--sync"') let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ? \ remove(args, -1) : get(g:, 'plug_threads', 16) @@ -890,8 +979,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')) && threads > 1 && s:check_ruby() let s:update = { \ 'start': reltime(), @@ -901,7 +991,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 \ } @@ -914,8 +1004,12 @@ function! s:update_impl(pull, force, args) abort let s:clone_opt = get(g:, 'plug_shallow', 1) ? \ '--depth 1' . (s:git_version_requirement(1, 7, 10) ? ' --no-single-branch' : '') : '' + if has('win32unix') + let s:clone_opt .= ' -c core.eol=lf -c core.autocrlf=input' + endif + " 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 @@ -956,6 +1050,12 @@ function! s:update_impl(pull, force, args) abort endtry else call s:update_vim() + while use_job && sync + sleep 100m + if s:update.fin + break + endif + endwhile endif endfunction @@ -971,7 +1071,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 @@ -981,7 +1081,7 @@ function! s:update_finish() elseif has_key(spec, 'tag') let tag = spec.tag if tag =~ '\*' - let tags = s:lines(s:system('git tag --list '.string(tag).' --sort -version:refname 2>&1', spec.dir)) + let tags = s:lines(s:system('git tag --list '.s:shellesc(tag).' --sort -version:refname 2>&1', spec.dir)) if !v:shell_error && !empty(tags) let tag = tags[0] call s:log4(name, printf('Latest tag for %s -> %s', spec.tag, tag)) @@ -989,11 +1089,11 @@ function! s:update_finish() endif endif call s:log4(name, 'Checking out '.tag) - let out = s:system('git checkout -q '.s:esc(tag).' 2>&1', spec.dir) + let out = s:system('git checkout -q '.s:esc(tag).' -- 2>&1', spec.dir) else let branch = s:esc(get(spec, 'branch', 'master')) call s:log4(name, 'Merging origin/'.branch) - let out = s:system('git checkout -q '.branch.' 2>&1' + let out = s:system('git checkout -q '.branch.' -- 2>&1' \. (has_key(s:update.new, name) ? '' : ('&& git merge --ff-only origin/'.branch.' 2>&1')), spec.dir) endif if !v:shell_error && filereadable(spec.dir.'/.gitmodules') && @@ -1001,19 +1101,25 @@ 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 _ - 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")')) + silent 4 d _ + 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') @@ -1021,12 +1127,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 @@ -1034,59 +1144,92 @@ 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) dict 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': [''], + \ 'batchfile': (s:is_win && (s:nvim || s:vim8)) ? tempname().'.bat' : '', + \ 'new': get(a:opts, 'new', 0) } let s:jobs[a:name] = job + let cmd = has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd + if !empty(job.batchfile) + call writefile(['@echo off', cmd], job.batchfile) + let cmd = job.batchfile + endif + let argv = add(s:is_win ? ['cmd', '/c'] : ['sh', '-c'], 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(s:is_win ? join(argv, ' ') : 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', [cmd])) let job.error = v:shell_error != 0 let job.running = 0 endif @@ -1101,9 +1244,14 @@ 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() + if has_key(job, 'batchfile') && !empty(job.batchfile) + call delete(job.batchfile) + endif call remove(s:jobs, a:name) endfunction @@ -1120,23 +1268,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 - 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 @@ -1150,12 +1306,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 @@ -1175,10 +1331,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, @@ -1464,10 +1620,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), @@ -1626,6 +1784,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' @@ -1638,6 +1801,7 @@ function! s:update_ruby() tries = VIM::evaluate('get(g:, "plug_retries", 2)') + 1 nthr = VIM::evaluate('s:update.threads').to_i maxy = VIM::evaluate('winheight(".")').to_i + vim7 = VIM::evaluate('v:version').to_i <= 703 && RUBY_PLATFORM =~ /darwin/ cd = iswin ? 'cd /d' : 'cd' tot = VIM::evaluate('len(s:update.todo)') || 0 bar = '' @@ -1727,12 +1891,17 @@ function! s:update_ruby() main = Thread.current threads = [] watcher = Thread.new { - while VIM::evaluate('getchar(1)') - sleep 0.1 + if vim7 + while VIM::evaluate('getchar(1)') + sleep 0.1 + end + else + require 'io/console' # >= Ruby 1.9 + nil until IO.console.getch == 3.chr end mtx.synchronize do running = false - threads.each { |t| t.raise Interrupt } + threads.each { |t| t.raise Interrupt } unless vim7 end threads.each { |t| t.join rescue nil } main.kill @@ -1767,7 +1936,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($/)] @@ -1800,8 +1969,19 @@ function! s:update_ruby() EOF endfunction +function! s:shellesc_cmd(arg) + let escaped = substitute(a:arg, '[&|<>()@^]', '^&', 'g') + let escaped = substitute(escaped, '%', '%%', 'g') + let escaped = substitute(escaped, '"', '\\^&', 'g') + let escaped = substitute(escaped, '\(\\\+\)\(\\^\)', '\1\1\2', 'g') + return '^"'.substitute(escaped, '\(\\\+\)$', '\1\1', '').'^"' +endfunction + function! s:shellesc(arg) - return '"'.escape(a:arg, '"').'"' + if &shell =~# 'cmd.exe$' + return s:shellesc_cmd(a:arg) + endif + return shellescape(a:arg) endfunction function! s:glob_dir(path) @@ -1813,9 +1993,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) @@ -1833,11 +2019,19 @@ endfunction function! s:system(cmd, ...) try - let [sh, shrd] = s:chsh(1) + let [sh, shellcmdflag, shrd] = s:chsh(1) let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd + if s:is_win + let batchfile = tempname().'.bat' + call writefile(['@echo off', cmd], batchfile) + let cmd = batchfile + endif return system(s:is_win ? '('.cmd.')' : cmd) finally - let [&shell, &shellredir] = [sh, shrd] + let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] + if s:is_win + call delete(batchfile) + endif endtry endfunction @@ -1872,7 +2066,7 @@ function! s:git_validate(spec, check_branch) " Check tag if has_key(a:spec, 'tag') let tag = s:system_chomp('git describe --exact-match --tags HEAD 2>&1', a:spec.dir) - if a:spec.tag !=# tag + if a:spec.tag !=# tag && a:spec.tag !~ '\*' let err = printf('Invalid tag: %s (expected: %s). Try PlugUpdate.', \ (empty(tag) ? 'N/A' : tag), a:spec.tag) endif @@ -1882,10 +2076,21 @@ function! s:git_validate(spec, check_branch) \ branch, a:spec.branch) endif if empty(err) - let commits = len(s:lines(s:system(printf('git rev-list origin/%s..HEAD', a:spec.branch), a:spec.dir))) - if !v:shell_error && commits - let err = join([printf('Diverged from origin/%s by %d commit(s).', a:spec.branch, commits), - \ 'Reinstall after PlugClean.'], "\n") + let [ahead, behind] = split(s:lastline(s:system(printf( + \ 'git rev-list --count --left-right HEAD...origin/%s', + \ a:spec.branch), a:spec.dir)), '\t') + if !v:shell_error && ahead + if behind + " Only mention PlugClean if diverged, otherwise it's likely to be + " pushable (and probably not that messed up). + let err = printf( + \ "Diverged from origin/%s (%d commit(s) ahead and %d commit(s) behind!\n" + \ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', a:spec.branch, ahead, behind) + else + let err = printf("Ahead of origin/%s by %d commit(s).\n" + \ .'Cannot update until local changes are pushed.', + \ a:spec.branch, ahead) + endif endif endif endif @@ -1955,16 +2160,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 d :set opfunc=delete_opg@ + nmap dd d_ + xnoremap d :call delete_op(visualmode(), 1) + 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() @@ -2009,15 +2246,16 @@ function! s:status() let unloaded = 0 let [cnt, total] = [0, len(g:plugs)] for [name, spec] in items(g:plugs) + let is_dir = isdirectory(spec.dir) if has_key(spec, 'uri') - if isdirectory(spec.dir) + if is_dir let [err, _] = s:git_validate(spec, 1) let [valid, msg] = [empty(err), empty(err) ? 'OK' : err] else let [valid, msg] = [0, 'Not found. Try PlugInstall.'] endif else - if isdirectory(spec.dir) + if is_dir let [valid, msg] = [1, 'OK'] else let [valid, msg] = [0, 'Not found.'] @@ -2026,7 +2264,7 @@ function! s:status() let cnt += 1 let ecnt += !valid " `s:loaded` entry can be missing if PlugUpgraded - if valid && get(s:loaded, name, -1) == 0 + if is_dir && get(s:loaded, name, -1) == 0 let unloaded = 1 let msg .= ' (not loaded)' endif @@ -2096,7 +2334,7 @@ function! s:preview_commit() let b:plug_preview = !s:is_preview_window_open() endif - let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-f]\{7}') + let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-f]\{7,9}') if empty(sha) return endif @@ -2106,11 +2344,29 @@ 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 + try + let [sh, shellcmdflag, shrd] = s:chsh(1) + let cmd = 'cd '.s:shellesc(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha + if s:is_win + let batchfile = tempname().'.bat' + call writefile(['@echo off', cmd], batchfile) + let cmd = batchfile + endif + execute 'silent %!' cmd + finally + let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] + if s:is_win + call delete(batchfile) + endif + endtry setlocal nomodifiable nnoremap q :q wincmd p @@ -2151,7 +2407,7 @@ function! s:diff() call s:append_ul(2, origin ? 'Pending updates:' : 'Last update:') for [k, v] in plugs let range = origin ? '..origin/'.v.branch : 'HEAD@{1}..' - let diff = s:system_chomp('git log --graph --color=never --pretty=format:"%x01%h%x01%d%x01%s%x01%cr" '.s:shellesc(range), v.dir) + let diff = s:system_chomp('git log --graph --color=never '.join(map(['--pretty=format:%x01%h%x01%d%x01%s%x01%cr', range], 's:shellesc(v:val)')), v.dir) if !empty(diff) let ref = has_key(v, 'tag') ? (' (tag: '.v.tag.')') : has_key(v, 'commit') ? (' '.v.commit) : '' call append(5, extend(['', '- '.k.':'.ref], map(s:lines(diff), 's:format_git_log(v:val)'))) @@ -2192,11 +2448,11 @@ function! s:revert() return endif - call s:system('git reset --hard HEAD@{1} && git checkout '.s:esc(g:plugs[name].branch), g:plugs[name].dir) + call s:system('git reset --hard HEAD@{1} && git checkout '.s:esc(g:plugs[name].branch).' --', g:plugs[name].dir) setlocal modifiable normal! "_dap setlocal nomodifiable - echo 'Reverted.' + echo 'Reverted' endfunction function! s:snapshot(force, ...) abort diff --git a/nvim/.config/nvim/autoload/plug.vim.old b/nvim/.config/nvim/autoload/plug.vim.old index 9cb02f7..e0dc78f 100644 --- a/nvim/.config/nvim/autoload/plug.vim.old +++ b/nvim/.config/nvim/autoload/plug.vim.old @@ -18,7 +18,7 @@ " " Any valid git URL is allowed " Plug 'https://github.com/junegunn/vim-github-dashboard.git' " -" " Group dependencies, vim-snippets depends on ultisnips +" " Multiple Plug commands can be written in a single line using | separators " Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' " " " On-demand loading @@ -28,6 +28,9 @@ " " Using a non-master branch " Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' } " +" " Using a tagged release; wildcard allowed (requires git 1.9.2 or above) +" Plug 'fatih/vim-go', { 'tag': '*' } +" " " Plugin options " Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' } " @@ -37,7 +40,7 @@ " " Unmanaged plugin (manually installed and updated) " Plug '~/my-prototype-plugin' " -" " Add plugins to &runtimepath +" " Initialize plugin system " call plug#end() " " Then reload .vimrc and :PlugInstall to install plugins. @@ -58,7 +61,7 @@ " More information: https://github.com/junegunn/vim-plug " " -" Copyright (c) 2015 Junegunn Choi +" Copyright (c) 2017 Junegunn Choi " " MIT License " @@ -94,7 +97,8 @@ let s:plug_tab = get(s:, 'plug_tab', -1) 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:nvim = has('nvim-0.2') || (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 = { @@ -117,6 +121,9 @@ function! plug#begin(...) else return s:err('Unable to determine plug home. Try calling plug#begin() with a path argument.') endif + if fnamemodify(home, ':t') ==# 'plugin' && fnamemodify(home, ':h') ==# s:first_rtp + return s:err('Invalid plug home. '.home.' is a standard Vim runtime path and is not allowed.') + endif let g:plug_home = home let g:plugs = {} @@ -128,7 +135,7 @@ function! plug#begin(...) endfunction function! s:define_commands() - command! -nargs=+ -bar Plug call s:Plug() + command! -nargs=+ -bar Plug call plug#() if !executable('git') return s:err('`git` executable not found. Most commands will not be available. To suppress this message, prepend `silent!` to `call plug#begin(...)`.') endif @@ -168,14 +175,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() @@ -191,8 +206,13 @@ 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 + 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 @@ -208,6 +228,7 @@ function! plug#end() endif call add(s:triggers[name].map, cmd) elseif cmd =~# '^[A-Z]' + let cmd = substitute(cmd, '!*$', '', '') if exists(':'.cmd) != 2 call s:assoc(lod.cmd, cmd, name) endif @@ -222,7 +243,9 @@ function! plug#end() if has_key(plug, 'for') let types = s:to_a(plug.for) if !empty(types) + augroup filetypedetect call s:source(s:rtp(plug), 'ftdetect/**/*.vim', 'after/ftdetect/**/*.vim') + augroup END endif for type in types call s:assoc(lod.ft, type, name) @@ -232,7 +255,7 @@ function! plug#end() for [cmd, names] in items(lod.cmd) execute printf( - \ 'command! -nargs=* -range -bang %s call s:lod_cmd(%s, "", , , , %s)', + \ 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "", , , , %s)', \ cmd, string(cmd), string(names)) endfor @@ -240,8 +263,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 @@ -259,7 +282,7 @@ function! plug#end() syntax enable end else - call s:reload() + call s:reload_plugins() endif endfunction @@ -267,9 +290,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 @@ -289,7 +316,7 @@ endfunction function! s:git_version_requirement(...) if !exists('s:git_version') - let s:git_version = map(split(split(s:system('git --version'))[-1], '\.'), 'str2nr(v:val)') + let s:git_version = map(split(split(s:system('git --version'))[2], '\.'), 'str2nr(v:val)') endif return s:version_requirement(s:git_version, a:000) endfunction @@ -337,7 +364,12 @@ function! s:err(msg) echohl ErrorMsg echom '[vim-plug] '.a:msg echohl None - return 0 +endfunction + +function! s:warn(cmd, msg) + echohl WarningMsg + execute a:cmd 'a:msg' + echohl None endfunction function! s:esc(path) @@ -373,7 +405,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, ",")'), ',') @@ -386,6 +418,26 @@ function! s:reorg_rtp() endif endfunction +function! s:doautocmd(...) + if exists('#'.join(a:000, '#')) + execute 'doautocmd' ((v:version > 703 || has('patch442')) ? '' : '') join(a:000) + endif +endfunction + +function! s:dobufread(names) + for name in a:names + let path = s:rtp(g:plugs[name]).'/**' + for dir in ['ftdetect', 'ftplugin'] + if len(finddir(dir, path)) + if exists('#BufRead') + doautocmd BufRead + endif + return + endif + endfor + endfor +endfunction + function! plug#load(...) if a:0 == 0 return s:err('Argument missing: plugin name(s) required') @@ -393,18 +445,21 @@ function! plug#load(...) if !exists('g:plugs') return s:err('plug#begin was not called') endif - let unknowns = filter(copy(a:000), '!has_key(g:plugs, v:val)') + let names = a:0 == 1 && type(a:1) == s:TYPE.list ? a:1 : a:000 + let unknowns = filter(copy(names), '!has_key(g:plugs, v:val)') if !empty(unknowns) let s = len(unknowns) > 1 ? 's' : '' return s:err(printf('Unknown plugin%s: %s', s, join(unknowns, ', '))) end - for name in a:000 - call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) - endfor - if exists('#BufRead') - doautocmd BufRead - endif - return 1 + let unloaded = filter(copy(names), '!get(s:loaded, v:val, 0)') + if !empty(unloaded) + for name in unloaded + call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + endfor + call s:dobufread(unloaded) + return 1 + end + return 0 endfunction function! s:remove_triggers(name) @@ -439,9 +494,7 @@ function! s:lod(names, types, ...) endif call s:source(rtp, a:2) endif - if exists('#User#'.name) - execute 'doautocmd User' name - endif + call s:doautocmd('User', name) endfor endfunction @@ -449,21 +502,19 @@ function! s:lod_ft(pat, names) let syn = 'syntax/'.a:pat.'.vim' call s:lod(a:names, ['plugin', 'after/plugin'], syn, 'after/'.syn) execute 'autocmd! PlugLOD FileType' a:pat - if exists('#filetypeplugin#FileType') - doautocmd filetypeplugin FileType - endif - if exists('#filetypeindent#FileType') - doautocmd filetypeindent FileType - endif + call s:doautocmd('filetypeplugin', 'FileType') + call s:doautocmd('filetypeindent', 'FileType') endfunction function! s:lod_cmd(cmd, bang, l1, l2, args, names) call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + call s:dobufread(a: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 = '' while 1 let c = getchar(0) @@ -472,10 +523,22 @@ function! s:lod_map(map, names, prefix) endif let extra .= nr2char(c) endwhile - call feedkeys(a:prefix . substitute(a:map, '^', "\", '') . extra) + + 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(substitute(a:map, '^', "\", '') . extra) endfunction -function! s:Plug(repo, ...) +function! plug#(repo, ...) if a:0 > 1 return s:err('Invalid number of arguments (1..2)') endif @@ -520,13 +583,12 @@ function! s:infer_properties(name, repo) let uri = repo else if repo !~ '/' - let repo = 'vim-scripts/'. repo + throw printf('Invalid argument: %s (implicit `vim-scripts'' expansion is deprecated)', repo) endif 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 @@ -563,17 +625,18 @@ function! s:syntax() syn match plugStar /^*/ syn match plugMessage /\(^- \)\@<=.*/ syn match plugName /\(^- \)\@<=[^ ]*:/ - syn match plugSha /\%(: \)\@<=[0-9a-z]\{4,}$/ + syn match plugSha /\%(: \)\@<=[0-9a-f]\{4,}$/ syn match plugTag /(tag: [^)]\+)/ syn match plugInstall /\(^+ \)\@<=[^:]*/ syn match plugUpdate /\(^* \)\@<=[^:]*/ - syn match plugCommit /^ \X*[0-9a-z]\{7} .*/ contains=plugRelDate,plugEdge,plugTag + syn match plugCommit /^ \X*[0-9a-f]\{7,9} .*/ contains=plugRelDate,plugEdge,plugTag syn match plugEdge /^ \X\+$/ syn match plugEdge /^ \X*/ contained nextgroup=plugSha - syn match plugSha /[0-9a-z]\{7}/ contained + syn match plugSha /[0-9a-f]\{7,9}/ contained 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 @@ -593,6 +656,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 @@ -656,7 +720,7 @@ function! s:switch_out(...) endfunction function! s:finish_bindings() - nnoremap R :silent! call retry() + nnoremap R :call retry() nnoremap D :PlugDiff nnoremap S :PlugStatus nnoremap U :call status_update() @@ -670,12 +734,22 @@ 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 + 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() @@ -685,11 +759,10 @@ function! s:prepare(...) let s:plug_buf = winbufnr(0) call s:assign_name() - silent! unmap - silent! unmap L - silent! unmap o - silent! unmap X - setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap cursorline modifiable + for k in ['', 'L', 'o', 'X', 'd', 'dd'] + execute 'silent! unmap ' k + endfor + setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline modifiable nospell setf vim-plug if exists('g:syntax_on') call s:syntax() @@ -708,6 +781,38 @@ function! s:assign_name() silent! execute 'f' fnameescape(name) endfunction +function! s:chsh(swap) + let prev = [&shell, &shellredir] + if !s:is_win && a:swap + set shell=sh shellredir=>%s\ 2>&1 + endif + return prev +endfunction + +function! s:bang(cmd, ...) + try + let [sh, shrd] = s:chsh(a:0) + " FIXME: Escaping is incomplete. We could use shellescape with eval, + " but it won't work on Windows. + let cmd = a:0 ? s:with_cd(a:cmd, a:1) : a:cmd + let g:_plug_bang = '!'.escape(cmd, '#!%') + execute "normal! :execute g:_plug_bang\\" + finally + unlet g:_plug_bang + let [&shell, &shellredir] = [sh, shrd] + endtry + return v:shell_error ? 'Exit status: ' . v:shell_error : '' +endfunction + +function! s:regress_bar() + let bar = substitute(getline(2)[1:-2], '.*\zs=', 'x', '') + call s:progress_bar(2, bar, len(bar)) +endfunction + +function! s:is_updated(dir) + return !empty(s:system_chomp('git log --pretty=format:"%h" "HEAD...HEAD@{1}"', a:dir)) +endfunction + function! s:do(pull, force, todo) for [name, spec] in items(a:todo) if !isdirectory(spec.dir) @@ -715,24 +820,31 @@ function! s:do(pull, force, todo) endif let installed = has_key(s:update.new, name) let updated = installed ? 0 : - \ (a:pull && index(s:update.errors, name) < 0 && !empty(s:system_chomp('git log --pretty=format:"%h" "HEAD...HEAD@{1}"', spec.dir))) + \ (a:pull && index(s:update.errors, name) < 0 && s:is_updated(spec.dir)) if a:force || installed || updated execute 'cd' s:esc(spec.dir) call append(3, '- Post-update hook for '. name .' ... ') let error = '' let type = type(spec.do) if type == s:TYPE.string - try - " FIXME: Escaping is incomplete. We could use shellescape with eval, - " but it won't work on Windows. - let g:_plug_do = '!'.escape(spec.do, '#!%') - execute "normal! :execute g:_plug_do\\" - finally - if v:shell_error - let error = 'Exit status: ' . v:shell_error + if spec.do[0] == ':' + if !get(s:loaded, name, 0) + let s:loaded[name] = 1 + call s:reorg_rtp() endif - unlet g:_plug_do - endtry + call s:load_plugin(spec) + 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 elseif type == s:TYPE.funcref try let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged') @@ -743,8 +855,13 @@ 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) + call add(s:update.errors, name) + call s:regress_bar() + endif cd - endif endfor @@ -754,32 +871,14 @@ function! s:hash_match(a, b) return stridx(a:a, a:b) == 0 || stridx(a:b, a:a) == 0 endfunction -function! s:checkout(plugs) - for [name, spec] in items(a:plugs) - let sha = spec.commit - call append(3, '- Checking out '.sha[:6].' of '.name.' ... ') - redraw - - let error = [] - let output = s:lines(s:system('git rev-parse HEAD', spec.dir)) - if v:shell_error - let error = output - elseif !s:hash_match(sha, output[0]) - let output = s:lines(s:system( - \ 'git fetch --depth 999999 && git checkout '.sha, spec.dir)) - if v:shell_error - let error = output - endif - endif - if empty(error) - call setline(4, getline(4) . 'OK') - else - call setline(4, 'x'.getline(4)[1:] . 'Error') - for line in reverse(error) - call append(4, ' '.line) - endfor - endif - endfor +function! s:checkout(spec) + let sha = a:spec.commit + let output = s:system('git rev-parse HEAD', a:spec.dir) + if !v:shell_error && !s:hash_match(sha, s:lines(output)[0]) + let output = s:system( + \ 'git fetch --depth 999999 && git checkout '.s:esc(sha).' --', a:spec.dir) + endif + return output endfunction function! s:finish(pull) @@ -788,7 +887,7 @@ function! s:finish(pull) let s = new_frozen > 1 ? 's' : '' call append(3, printf('- Installed %d frozen plugin%s', new_frozen, s)) endif - call append(3, '- Finishing ... ') + call append(3, '- Finishing ... ') | 4 redraw call plug#helptags() call plug#end() @@ -810,6 +909,7 @@ function! s:retry() if empty(s:update.errors) return endif + echo call s:update_impl(s:update.pull, s:update.force, \ extend(copy(s:update.errors), [s:update.threads])) endfunction @@ -822,8 +922,20 @@ function! s:names(...) return sort(filter(keys(g:plugs), 'stridx(v:val, a:1) == 0 && s:is_managed(v:val)')) endfunction +function! s:check_ruby() + silent! ruby require 'thread'; VIM::command("let g:plug_ruby = '#{RUBY_VERSION}'") + if !exists('g:plug_ruby') + redraw! + return s:warn('echom', 'Warning: Ruby interface is broken') + endif + let ruby_version = split(g:plug_ruby, '\.') + unlet g:plug_ruby + return s:version_requirement(ruby_version, [1, 8, 7]) +endfunction + function! s:update_impl(pull, force, args) abort - let args = copy(a:args) + let sync = index(a:args, '--sync') >= 0 || has('vim_starting') + let args = filter(copy(a:args), 'v:val != "--sync"') let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ? \ remove(args, -1) : get(g:, 'plug_threads', 16) @@ -832,10 +944,7 @@ function! s:update_impl(pull, force, args) abort \ filter(managed, 'index(args, v:key) >= 0') if empty(todo) - echohl WarningMsg - echo 'No plugin to '. (a:pull ? 'update' : 'install') . '.' - echohl None - return + return s:warn('echo', 'No plugin to '. (a:pull ? 'update' : 'install')) endif if !s:is_win && s:git_version_requirement(2, 3) @@ -857,13 +966,12 @@ function! s:update_impl(pull, force, args) abort endif if has('nvim') && !exists('*jobwait') && threads > 1 - echohl WarningMsg - echomsg 'vim-plug: update Neovim for parallel installer' - echohl None + 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')) + 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')) && threads > 1 && s:check_ruby() let s:update = { \ 'start': reltime(), @@ -873,7 +981,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 \ } @@ -886,8 +994,12 @@ function! s:update_impl(pull, force, args) abort let s:clone_opt = get(g:, 'plug_shallow', 1) ? \ '--depth 1' . (s:git_version_requirement(1, 7, 10) ? ' --no-single-branch' : '') : '' + if has('win32unix') + let s:clone_opt .= ' -c core.eol=lf -c core.autocrlf=input' + endif + " 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 @@ -928,16 +1040,76 @@ function! s:update_impl(pull, force, args) abort endtry else call s:update_vim() + while use_job && sync + sleep 100m + if s:update.fin + break + endif + endwhile endif endfunction +function! s:log4(name, msg) + call setline(4, printf('- %s (%s)', a:msg, a:name)) + redraw +endfunction + function! s:update_finish() if exists('s:git_terminal_prompt') let $GIT_TERMINAL_PROMPT = s:git_terminal_prompt endif if s:switch_in() - call s:checkout(filter(copy(s:update.all), 'has_key(v:val, "commit")')) - call s:do(s:update.pull, s:update.force, filter(copy(s:update.all), 'has_key(v:val, "do")')) + 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) + if !pos + continue + endif + if has_key(spec, 'commit') + call s:log4(name, 'Checking out '.spec.commit) + let out = s:checkout(spec) + elseif has_key(spec, 'tag') + let tag = spec.tag + if tag =~ '\*' + let tags = s:lines(s:system('git tag --list '.s:shellesc(tag).' --sort -version:refname 2>&1', spec.dir)) + if !v:shell_error && !empty(tags) + let tag = tags[0] + call s:log4(name, printf('Latest tag for %s -> %s', spec.tag, tag)) + call append(3, '') + endif + endif + call s:log4(name, 'Checking out '.tag) + let out = s:system('git checkout -q '.s:esc(tag).' -- 2>&1', spec.dir) + else + let branch = s:esc(get(spec, 'branch', 'master')) + call s:log4(name, 'Merging origin/'.branch) + let out = s:system('git checkout -q '.branch.' -- 2>&1' + \. (has_key(s:update.new, name) ? '' : ('&& git merge --ff-only origin/'.branch.' 2>&1')), spec.dir) + endif + if !v:shell_error && filereadable(spec.dir.'/.gitmodules') && + \ (s:update.force || has_key(s:update.new, name) || s:is_updated(spec.dir)) + 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 = s:format_message(v:shell_error ? 'x': '-', name, out) + if v:shell_error + call add(s:update.errors, name) + call s:regress_bar() + silent execute pos 'd _' + call append(4, msg) | 4 + elseif !empty(out) + call setline(pos, msg[0]) + endif + redraw + endfor + silent 4 d _ + 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') @@ -945,12 +1117,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 @@ -958,59 +1134,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) dict 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(s:is_win ? join(argv, ' ') : 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 @@ -1025,7 +1230,9 @@ function! s:reap(name) endif let s:update.bar .= job.error ? 'x' : '=' - call s:log(job.error ? 'x' : '-', a:name, 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) @@ -1042,26 +1249,33 @@ function! s:bar() endfunction function! s:logpos(name) - for i in range(1, line('$')) + 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 + return [0, 0] endfunction function! s:log(bullet, name, lines) if s:switch_in() - let pos = s:logpos(a:name) - if pos > 0 - 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 @@ -1075,12 +1289,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 @@ -1093,30 +1307,24 @@ while 1 " Without TCO, Vim stack is bound to explode redraw let has_tag = has_key(spec, 'tag') - let checkout = s:shellesc(has_tag ? spec.tag : spec.branch) - let merge = s:shellesc(has_tag ? spec.tag : 'origin/'.spec.branch) - if !new - let error = s:git_validate(spec, 0) + let [error, _] = s:git_validate(spec, 0) if empty(error) if pull let fetch_opt = (has_tag && !empty(globpath(spec.dir, '.git/shallow'))) ? '--depth 99999999' : '' - call s:spawn(name, - \ printf('(git fetch %s %s 2>&1 && git checkout -q %s 2>&1 && git merge --ff-only %s 2>&1 && git submodule update --init --recursive 2>&1)', - \ fetch_opt, prog, checkout, merge), { 'dir': spec.dir }) + 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, - \ printf('git clone %s %s --recursive %s -b %s %s 2>&1', + \ printf('git clone %s %s %s %s 2>&1', \ has_tag ? '' : s:clone_opt, \ prog, \ s:shellesc(spec.uri), - \ checkout, \ s:shellesc(s:trim(spec.dir))), { 'new': 1 }) endif @@ -1345,10 +1553,7 @@ class Plugin(object): self.args = args self.buf_q = buf_q self.lock = lock - tag = args.get('tag', 0) - self.checkout = esc(tag if tag else args['branch']) - self.merge = esc(tag if tag else 'origin/' + args['branch']) - self.tag = tag + self.tag = args.get('tag', 0) def manage(self): try: @@ -1384,24 +1589,26 @@ class Plugin(object): self.write(Action.INSTALL, self.name, ['Installing ...']) callback = functools.partial(self.write, Action.INSTALL, self.name) - cmd = 'git clone {0} {1} --recursive {2} -b {3} {4} 2>&1'.format( + cmd = 'git clone {0} {1} {2} {3} 2>&1'.format( '' if self.tag else G_CLONE_OPT, G_PROGRESS, self.args['uri'], - self.checkout, esc(target)) + esc(target)) com = Command(cmd, None, G_TIMEOUT, callback, clean(target)) result = com.execute(G_RETRIES) self.write(Action.DONE, self.name, result[-1:]) def repo_uri(self): - cmd = 'git rev-parse --abbrev-ref HEAD 2>&1 && git config remote.origin.url' + cmd = 'git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url' command = Command(cmd, self.args['dir'], G_TIMEOUT,) result = command.execute(G_RETRIES) 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), @@ -1412,11 +1619,7 @@ class Plugin(object): self.write(Action.UPDATE, self.name, ['Updating ...']) callback = functools.partial(self.write, Action.UPDATE, self.name) fetch_opt = '--depth 99999999' if self.tag and os.path.isfile(os.path.join(self.args['dir'], '.git/shallow')) else '' - cmds = ['git fetch {0} {1}'.format(fetch_opt, G_PROGRESS), - 'git checkout -q {0}'.format(self.checkout), - 'git merge --ff-only {0}'.format(self.merge), - 'git submodule update --init --recursive'] - cmd = ' 2>&1 && '.join(cmds) + cmd = 'git fetch {0} {1} 2>&1'.format(fetch_opt, G_PROGRESS) com = Command(cmd, self.args['dir'], G_TIMEOUT, callback) result = com.execute(G_RETRIES) self.write(Action.DONE, self.name, result[-1:]) @@ -1508,7 +1711,7 @@ def main(): while not buf_q.empty() or thr.active_count() != start_cnt: try: action, name, msg = buf_q.get(True, 0.25) - buf.write(action, name, msg) + buf.write(action, name, ['OK'] if not msg else msg) buf_q.task_done() except queue.Empty: pass @@ -1564,6 +1767,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' @@ -1576,6 +1784,7 @@ function! s:update_ruby() tries = VIM::evaluate('get(g:, "plug_retries", 2)') + 1 nthr = VIM::evaluate('s:update.threads').to_i maxy = VIM::evaluate('winheight(".")').to_i + vim7 = VIM::evaluate('v:version').to_i <= 703 && RUBY_PLATFORM =~ /darwin/ cd = iswin ? 'cd /d' : 'cd' tot = VIM::evaluate('len(s:update.todo)') || 0 bar = '' @@ -1602,7 +1811,7 @@ function! s:update_ruby() end result = if type || type.nil? - ["#{b} #{name}: #{result.lines.to_a.last}"] + ["#{b} #{name}: #{result.lines.to_a.last || 'OK'}"] elsif result =~ /^Interrupted|^Timeout/ ["#{b} #{name}: #{result}"] else @@ -1665,12 +1874,17 @@ function! s:update_ruby() main = Thread.current threads = [] watcher = Thread.new { - while VIM::evaluate('getchar(1)') - sleep 0.1 + if vim7 + while VIM::evaluate('getchar(1)') + sleep 0.1 + end + else + require 'io/console' # >= Ruby 1.9 + nil until IO.console.getch == 3.chr end mtx.synchronize do running = false - threads.each { |t| t.raise Interrupt } + threads.each { |t| t.raise Interrupt } unless vim7 end threads.each { |t| t.join rescue nil } main.kill @@ -1692,15 +1906,12 @@ function! s:update_ruby() threads << Thread.new { while pair = take1.call name = pair.first - dir, uri, branch, tag = pair.last.values_at *%w[dir uri branch tag] - checkout = esc(tag ? tag : branch) - merge = esc(tag ? tag : "origin/#{branch}") - subm = "git submodule update --init --recursive 2>&1" + dir, uri, tag = pair.last.values_at *%w[dir uri tag] exists = File.directory? dir ok, result = if exists chdir = "#{cd} #{iswin ? dir : esc(dir)}" - ret, data = bt.call "#{chdir} && git rev-parse --abbrev-ref HEAD 2>&1 && git config remote.origin.url", nil, nil, nil + ret, data = bt.call "#{chdir} && git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url", nil, nil, nil current_uri = data.lines.to_a.last if !ret if data =~ /^Interrupted|^Timeout/ @@ -1708,7 +1919,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($/)] @@ -1716,7 +1927,7 @@ function! s:update_ruby() if pull log.call name, 'Updating ...', :update fetch_opt = (tag && File.exist?(File.join(dir, '.git/shallow'))) ? '--depth 99999999' : '' - bt.call "#{chdir} && git fetch #{fetch_opt} #{progress} 2>&1 && git checkout -q #{checkout} 2>&1 && git merge --ff-only #{merge} 2>&1 && #{subm}", name, :update, nil + bt.call "#{chdir} && git fetch #{fetch_opt} #{progress} 2>&1", name, :update, nil else [true, skip] end @@ -1724,7 +1935,7 @@ function! s:update_ruby() else d = esc dir.sub(%r{[\\/]+$}, '') log.call name, 'Installing ...', :install - bt.call "git clone #{clone_opt unless tag} #{progress} --recursive #{uri} -b #{checkout} #{d} 2>&1", name, :install, proc { + bt.call "git clone #{clone_opt unless tag} #{progress} #{uri} #{d} 2>&1", name, :install, proc { FileUtils.rm_rf dir } end @@ -1754,9 +1965,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) @@ -1774,10 +1991,7 @@ endfunction function! s:system(cmd, ...) try - let [sh, shrd] = [&shell, &shellredir] - if !s:is_win - set shell=sh shellredir=>%s\ 2>&1 - endif + let [sh, shrd] = s:chsh(1) let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd return system(s:is_win ? '('.cmd.')' : cmd) finally @@ -1793,7 +2007,7 @@ endfunction function! s:git_validate(spec, check_branch) let err = '' if isdirectory(a:spec.dir) - let result = s:lines(s:system('git rev-parse --abbrev-ref HEAD 2>&1 && git config remote.origin.url', a:spec.dir)) + let result = s:lines(s:system('git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url', a:spec.dir)) let remote = result[-1] if v:shell_error let err = join([remote, 'PlugClean required.'], "\n") @@ -1816,7 +2030,7 @@ function! s:git_validate(spec, check_branch) " Check tag if has_key(a:spec, 'tag') let tag = s:system_chomp('git describe --exact-match --tags HEAD 2>&1', a:spec.dir) - if a:spec.tag !=# tag + if a:spec.tag !=# tag && a:spec.tag !~ '\*' let err = printf('Invalid tag: %s (expected: %s). Try PlugUpdate.', \ (empty(tag) ? 'N/A' : tag), a:spec.tag) endif @@ -1825,11 +2039,29 @@ function! s:git_validate(spec, check_branch) let err = printf('Invalid branch: %s (expected: %s). Try PlugUpdate.', \ branch, a:spec.branch) endif + if empty(err) + let [ahead, behind] = split(s:lastline(s:system(printf( + \ 'git rev-list --count --left-right HEAD...origin/%s', + \ a:spec.branch), a:spec.dir)), '\t') + if !v:shell_error && ahead + if behind + " Only mention PlugClean if diverged, otherwise it's likely to be + " pushable (and probably not that messed up). + let err = printf( + \ "Diverged from origin/%s (%d commit(s) ahead and %d commit(s) behind!\n" + \ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', a:spec.branch, ahead, behind) + else + let err = printf("Ahead of origin/%s by %d commit(s).\n" + \ .'Cannot update until local changes are pushed.', + \ a:spec.branch, ahead) + endif + endif + endif endif else let err = 'Not found' endif - return err + return [err, err =~# 'PlugClean'] endfunction function! s:rm_rf(dir) @@ -1840,15 +2072,23 @@ endfunction function! s:clean(force) call s:prepare() - call append(0, 'Searching for unused plugins in '.g:plug_home) + call append(0, 'Searching for invalid plugins in '.g:plug_home) call append(1, '') " List of valid directories let dirs = [] + let errs = {} let [cnt, total] = [0, len(g:plugs)] for [name, spec] in items(g:plugs) - if !s:is_managed(name) || empty(s:git_validate(spec, 0)) + if !s:is_managed(name) call add(dirs, spec.dir) + else + let [err, clean] = s:git_validate(spec, 1) + if clean + let errs[spec.dir] = s:lines(err)[0] + else + call add(dirs, spec.dir) + endif endif let cnt += 1 call s:progress_bar(2, repeat('=', cnt), total) @@ -1872,25 +2112,60 @@ function! s:clean(force) if !has_key(allowed, f) && isdirectory(f) call add(todo, f) call append(line('$'), '- ' . f) + if has_key(errs, f) + call append(line('$'), ' ' . errs[f]) + endif let found = filter(found, 'stridx(v:val, f) != 0') end endwhile - normal! G + 4 redraw 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(line('$'), '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(line('$'), 'Cancelled.') + call setline(4, 'Cancelled.') + nnoremap d :set opfunc=delete_opg@ + nmap dd d_ + xnoremap d :call delete_op(visualmode(), 1) + echo 'Delete the lines (d{motion}) to delete the corresponding directories' endif endif - normal! G + 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() @@ -1937,7 +2212,7 @@ function! s:status() for [name, spec] in items(g:plugs) if has_key(spec, 'uri') if isdirectory(spec.dir) - let err = s:git_validate(spec, 1) + let [err, _] = s:git_validate(spec, 1) let [valid, msg] = [empty(err), empty(err) ? 'OK' : err] else let [valid, msg] = [0, 'Not found. Try PlugInstall.'] @@ -2001,7 +2276,6 @@ function! s:is_preview_window_open() wincmd p return 1 endif - return 0 endfunction function! s:find_name(lnum) @@ -2023,7 +2297,7 @@ function! s:preview_commit() let b:plug_preview = !s:is_preview_window_open() endif - let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-z]\{7}') + let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-f]\{7,9}') if empty(sha) return endif @@ -2033,11 +2307,20 @@ 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 --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 + try + let [sh, shrd] = s:chsh(1) + execute 'silent %!cd' s:shellesc(g:plugs[name].dir) '&& git show --no-color --pretty=medium' sha + finally + let [&shell, &shellredir] = [sh, shrd] + endtry setlocal nomodifiable nnoremap q :q wincmd p @@ -2119,11 +2402,11 @@ function! s:revert() return endif - call s:system('git reset --hard HEAD@{1} && git checkout '.s:esc(g:plugs[name].branch), g:plugs[name].dir) + call s:system('git reset --hard HEAD@{1} && git checkout '.s:esc(g:plugs[name].branch).' --', g:plugs[name].dir) setlocal modifiable normal! "_dap setlocal nomodifiable - echo 'Reverted.' + echo 'Reverted' endfunction function! s:snapshot(force, ...) abort @@ -2173,4 +2456,3 @@ endif let &cpo = s:cpo_save unlet s:cpo_save - diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim index 686bc99..30acca1 100644 --- a/nvim/.config/nvim/init.vim +++ b/nvim/.config/nvim/init.vim @@ -1,16 +1,15 @@ call plug#begin('~/.dotfiles/nvim/.config/nvim/plugged') -Plug 'kien/ctrlp.vim' -Plug 'FelikZ/ctrlp-py-matcher' +" Plug 'kien/ctrlp.vim' +" Plug 'FelikZ/ctrlp-py-matcher' Plug 'Raimondi/delimitMate' Plug 'morhetz/gruvbox' -Plug 'Yggdroot/indentLine' +" Plug 'Yggdroot/indentLine' Plug 'scrooloose/nerdtree' Plug 'godlygeek/tabular' " Plug 'majutsushi/tagbar' Plug 'tomtom/tcomment_vim' Plug 'bling/vim-airline' Plug 'tommcdo/vim-exchange' -Plug 'justinmk/vim-matchparenalways' Plug 'tpope/vim-surround' Plug 'christoomey/vim-tmux-navigator' Plug 'MarcWeber/vim-addon-mw-utils' @@ -29,23 +28,44 @@ Plug 'Valloric/YouCompleteMe' Plug 'moll/vim-bbye' Plug 'tpope/vim-fugitive' Plug 'tikhomirov/vim-glsl' +Plug 'rust-lang/rust.vim' +Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } +Plug 'digitaltoad/vim-pug' call plug#end() -let g:ctrlp_custom_ignore = '\v[\/](bin|docs)$' +silent! so .vimlocal + +" let g:ctrlp_custom_ignore = '\v[\/](bin|build|docs)$' +map :call fzf#run(fzf#wrap('custom', {'source': 'ag -g ""'}, 0)) +let g:fzf_layout = { 'down': '~20%' } +let g:fzf_colors = +\ { 'fg': ['fg', 'Normal'], + \ 'bg': ['bg', 'Normal'], + \ 'hl': ['fg', 'Comment'], + \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], + \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], + \ 'hl+': ['fg', 'Statement'], + \ 'info': ['fg', 'PreProc'], + \ 'border': ['fg', 'Ignore'], + \ 'prompt': ['fg', 'Conditional'], + \ 'pointer': ['fg', 'Exception'], + \ 'marker': ['fg', 'Keyword'], + \ 'spinner': ['fg', 'Label'], + \ 'header': ['fg', 'Comment'] } + let delimitMate_expand_cr = 1 +set mouse=a + colorscheme gruvbox set t_Co=256 set t_ZH= set t_ZR= set background=dark -" let g:indentLine_char = '│' -" let g:indentLine_color_term = 239 set list lcs=tab:\│\ -" map :NERDTreeToggle map :NERDTreeToggle " map :TagbarToggle @@ -78,6 +98,8 @@ let g:UltiSnipsExpandTrigger="" syntax on filetype plugin indent on +au BufRead,BufNewFile *.lang setfiletype lang + set smartindent set number set relativenumber @@ -102,23 +124,26 @@ map 10k map :Bdelete -autocmd FileType go let &makeprg="go run %:p:h/*.go" -autocmd FileType go map :Make +" autocmd FileType go let &makeprg="go run %:p:h/*.go" +" autocmd FileType go map :Make +" +" autocmd FileType tex map :Dispatch arara % +" +" autocmd FileType cpp map :Make +" autocmd FileType cpp map :Make clean all -autocmd FileType tex map :Dispatch arara % - -autocmd FileType cpp map :Make -autocmd FileType cpp map :Make clean all - -if filereadable(expand("%:p:h")."/CMake/defualt/Makefile") - let &makeprg="cd CMake/default && make" - autocmd FileType cpp map :Make debug -endif -if filereadable(expand("%:p:h")."/build/cmake/Makefile") - let &makeprg="cd build/cmake && make" - autocmd FileType cpp map :Start cd build/cmake && ./run-engine.sh; echo "\nPress [enter] to close" && read - autocmd FileType cpp map :Start cd build/cmake && ./debug-engine.sh -endif +" if filereadable(expand("%:p:h")."/CMake/default/Makefile") +" let &makeprg="cd CMake/default && make" +" autocmd FileType cpp map :Make debug +" endif +" if filereadable(expand("%:p:h")."/build/cmake/Makefile") +" function KeyBind(platform) +" let &makeprg="cd cmake/configs/".a:platform." && make" +" execute 'autocmd FileType cpp map :Start cd cmake/configs/'.a:platform.' && ./run-engine.sh; echo "\nPress [enter] to close" && read' +" execute 'autocmd FileType cpp map :Start cd cmake/configs/'.a:platform.' && ./debug-engine.sh' +" endfunction +" call KeyBind("linux") +" endif map :call ToggleQuickfixList() " map :grep -F TODO -R ./src/**/*.cpp ./include/**/*.h :cw diff --git a/nvim/.config/nvim/plugged/YouCompleteMe b/nvim/.config/nvim/plugged/YouCompleteMe index cb57569..d183f11 160000 --- a/nvim/.config/nvim/plugged/YouCompleteMe +++ b/nvim/.config/nvim/plugged/YouCompleteMe @@ -1 +1 @@ -Subproject commit cb5756943fdd3ba062f101a5aba34acdd34d1356 +Subproject commit d183f11fa72471ed6c4df595b4047dfff98abf75 diff --git a/nvim/.config/nvim/plugged/ctrlp-py-matcher b/nvim/.config/nvim/plugged/ctrlp-py-matcher index 8a80326..a0710a4 160000 --- a/nvim/.config/nvim/plugged/ctrlp-py-matcher +++ b/nvim/.config/nvim/plugged/ctrlp-py-matcher @@ -1 +1 @@ -Subproject commit 8a803267a741cff3d6147650745f83c8f2125578 +Subproject commit a0710a4937ab9dc10bc0a8b56b41fcc88534147c diff --git a/nvim/.config/nvim/plugged/delimitMate b/nvim/.config/nvim/plugged/delimitMate index 8bc47fd..728b57a 160000 --- a/nvim/.config/nvim/plugged/delimitMate +++ b/nvim/.config/nvim/plugged/delimitMate @@ -1 +1 @@ -Subproject commit 8bc47fd1c40cdad9ea1f36c0cf13592c70ea65e9 +Subproject commit 728b57a6564c1d2bdfb9b9e0f2f8c5ba3d7e0c5c diff --git a/nvim/.config/nvim/plugged/gruvbox b/nvim/.config/nvim/plugged/gruvbox index 91bae68..16504d3 160000 --- a/nvim/.config/nvim/plugged/gruvbox +++ b/nvim/.config/nvim/plugged/gruvbox @@ -1 +1 @@ -Subproject commit 91bae6876031ececf151cc4f28aa5fb8c93681e4 +Subproject commit 16504d394e145e0372d2491e02769d241350399a diff --git a/nvim/.config/nvim/plugged/indentLine b/nvim/.config/nvim/plugged/indentLine index 2a26173..86b9824 160000 --- a/nvim/.config/nvim/plugged/indentLine +++ b/nvim/.config/nvim/plugged/indentLine @@ -1 +1 @@ -Subproject commit 2a2617310b0fb4c0daf02be2ba465fada257f2d0 +Subproject commit 86b9824b89cf52d4b748ea2a27885607c98c881a diff --git a/nvim/.config/nvim/plugged/nerdtree b/nvim/.config/nvim/plugged/nerdtree index 35c8591..68572ef 160000 --- a/nvim/.config/nvim/plugged/nerdtree +++ b/nvim/.config/nvim/plugged/nerdtree @@ -1 +1 @@ -Subproject commit 35c859179da4ad4f96eb8255e428904436a0b4b4 +Subproject commit 68572ef46143c5c7d420a6ec86f1ec4595765ce5 diff --git a/nvim/.config/nvim/plugged/rust.vim b/nvim/.config/nvim/plugged/rust.vim new file mode 160000 index 0000000..8e75da9 --- /dev/null +++ b/nvim/.config/nvim/plugged/rust.vim @@ -0,0 +1 @@ +Subproject commit 8e75da9834abb22f8d7ece3f4ca4324a14fa18a6 diff --git a/nvim/.config/nvim/plugged/tabular b/nvim/.config/nvim/plugged/tabular index 60f2564..00e1e7f 160000 --- a/nvim/.config/nvim/plugged/tabular +++ b/nvim/.config/nvim/plugged/tabular @@ -1 +1 @@ -Subproject commit 60f25648814f0695eeb6c1040d97adca93c4e0bb +Subproject commit 00e1e7fcdbc6d753e0bc8043e0d2546fa81bf367 diff --git a/nvim/.config/nvim/plugged/tcomment_vim b/nvim/.config/nvim/plugged/tcomment_vim index 7c42777..a48da32 160000 --- a/nvim/.config/nvim/plugged/tcomment_vim +++ b/nvim/.config/nvim/plugged/tcomment_vim @@ -1 +1 @@ -Subproject commit 7c4277754b6b77fb80b47cd4a7384d1e2d6c1538 +Subproject commit a48da32365498162579bc6384584596aa7f36b1d diff --git a/nvim/.config/nvim/plugged/tlib_vim b/nvim/.config/nvim/plugged/tlib_vim index 34b1329..c96db61 160000 --- a/nvim/.config/nvim/plugged/tlib_vim +++ b/nvim/.config/nvim/plugged/tlib_vim @@ -1 +1 @@ -Subproject commit 34b13299b5da7ad66ea387027d458bd54127687c +Subproject commit c96db6151fde9d06a8fed71b7df05c6dbb3f14fe diff --git a/nvim/.config/nvim/plugged/ultisnips b/nvim/.config/nvim/plugged/ultisnips index 3c420ed..423f264 160000 --- a/nvim/.config/nvim/plugged/ultisnips +++ b/nvim/.config/nvim/plugged/ultisnips @@ -1 +1 @@ -Subproject commit 3c420ed63f54a3359d5bc4e500cb9abd0c9177c5 +Subproject commit 423f264e753cec260b4f14455126e6db7ba429af diff --git a/nvim/.config/nvim/plugged/vim-airline b/nvim/.config/nvim/plugged/vim-airline index eaf2034..c2ffb8b 160000 --- a/nvim/.config/nvim/plugged/vim-airline +++ b/nvim/.config/nvim/plugged/vim-airline @@ -1 +1 @@ -Subproject commit eaf2034163b9b9dab2217d10c48ae0d52e90d07b +Subproject commit c2ffb8b3ec114301795036f7bf22995746d2acaf diff --git a/nvim/.config/nvim/plugged/vim-cpp b/nvim/.config/nvim/plugged/vim-cpp new file mode 160000 index 0000000..83469fd --- /dev/null +++ b/nvim/.config/nvim/plugged/vim-cpp @@ -0,0 +1 @@ +Subproject commit 83469fd71b0b1a8b2e20762814fcc24c7625e2d0 diff --git a/nvim/.config/nvim/plugged/vim-cpp-enhanced-highlight b/nvim/.config/nvim/plugged/vim-cpp-enhanced-highlight new file mode 160000 index 0000000..6307292 --- /dev/null +++ b/nvim/.config/nvim/plugged/vim-cpp-enhanced-highlight @@ -0,0 +1 @@ +Subproject commit 63072927d28348864a0372f5d091ff9585535ff3 diff --git a/nvim/.config/nvim/plugged/vim-dispatch b/nvim/.config/nvim/plugged/vim-dispatch index fc8d1e6..c5b1bbe 160000 --- a/nvim/.config/nvim/plugged/vim-dispatch +++ b/nvim/.config/nvim/plugged/vim-dispatch @@ -1 +1 @@ -Subproject commit fc8d1e68cd58fb3ffdd56109bf855cda92b10b70 +Subproject commit c5b1bbe1662d76c0aa9f6d325c3fb1b8db62ba02 diff --git a/nvim/.config/nvim/plugged/vim-exchange b/nvim/.config/nvim/plugged/vim-exchange index 9373a84..05d82b8 160000 --- a/nvim/.config/nvim/plugged/vim-exchange +++ b/nvim/.config/nvim/plugged/vim-exchange @@ -1 +1 @@ -Subproject commit 9373a8471cd968e5e4605c3487f80c9364d412b2 +Subproject commit 05d82b87711c6c8b9b7389bfb91c24bc4f62aa87 diff --git a/nvim/.config/nvim/plugged/vim-fugitive b/nvim/.config/nvim/plugged/vim-fugitive index bdd2168..f3ccb0c 160000 --- a/nvim/.config/nvim/plugged/vim-fugitive +++ b/nvim/.config/nvim/plugged/vim-fugitive @@ -1 +1 @@ -Subproject commit bdd216827ae53cdf70d933bb30762da9bf42cad4 +Subproject commit f3ccb0c12ee4985b8808f83059830a24cc92821c diff --git a/nvim/.config/nvim/plugged/vim-matchparenalways b/nvim/.config/nvim/plugged/vim-matchparenalways index 8fe2597..d2f514d 160000 --- a/nvim/.config/nvim/plugged/vim-matchparenalways +++ b/nvim/.config/nvim/plugged/vim-matchparenalways @@ -1 +1 @@ -Subproject commit 8fe259720a96d4930696d8497be0d89657125990 +Subproject commit d2f514ded8061ccb91230f1c096c63bda974c8a1 diff --git a/nvim/.config/nvim/plugged/vim-pug b/nvim/.config/nvim/plugged/vim-pug new file mode 160000 index 0000000..ddc5592 --- /dev/null +++ b/nvim/.config/nvim/plugged/vim-pug @@ -0,0 +1 @@ +Subproject commit ddc5592f8c36bf4bd915c16b38b8c76292c2b975 diff --git a/nvim/.config/nvim/plugged/vim-snippets b/nvim/.config/nvim/plugged/vim-snippets index 042aec6..71d91ae 160000 --- a/nvim/.config/nvim/plugged/vim-snippets +++ b/nvim/.config/nvim/plugged/vim-snippets @@ -1 +1 @@ -Subproject commit 042aec6f06e958d74f072855bfd365a671aaf49b +Subproject commit 71d91aec383ad3b72d8830db5d50d9bf4a8563f6 diff --git a/nvim/.config/nvim/plugged/vim-surround b/nvim/.config/nvim/plugged/vim-surround index 2d05440..e49d6c2 160000 --- a/nvim/.config/nvim/plugged/vim-surround +++ b/nvim/.config/nvim/plugged/vim-surround @@ -1 +1 @@ -Subproject commit 2d05440ad23f97a7874ebd9b5de3a0e65d25d85c +Subproject commit e49d6c2459e0f5569ff2d533b4df995dd7f98313 diff --git a/nvim/.config/nvim/plugged/vim-tmux-navigator b/nvim/.config/nvim/plugged/vim-tmux-navigator index eaa5289..d724094 160000 --- a/nvim/.config/nvim/plugged/vim-tmux-navigator +++ b/nvim/.config/nvim/plugged/vim-tmux-navigator @@ -1 +1 @@ -Subproject commit eaa5289b5161ef2c24fb66364ad563ea4ef5b170 +Subproject commit d724094e7128acd7375cc758008f1e1688130877 diff --git a/nvim/.config/nvim/plugged/vim-unimpaired b/nvim/.config/nvim/plugged/vim-unimpaired index 11dc568..1ac95a8 160000 --- a/nvim/.config/nvim/plugged/vim-unimpaired +++ b/nvim/.config/nvim/plugged/vim-unimpaired @@ -1 +1 @@ -Subproject commit 11dc568dbfd7a56866a4354c737515769f08e9fe +Subproject commit 1ac95a86c0facb1be8abec924cf79fd642cec386 diff --git a/nvim/.config/nvim/syntax/c.vim b/nvim/.config/nvim/syntax/c.vim new file mode 100644 index 0000000..e57c3c2 --- /dev/null +++ b/nvim/.config/nvim/syntax/c.vim @@ -0,0 +1,491 @@ +" Vim syntax file +" Language: C +" Maintainer: Bram Moolenaar +" Last Change: 2016 Nov 17 + +" Quit when a (custom) syntax file was already loaded +if exists("b:current_syntax") + finish +endif + +let s:cpo_save = &cpo +set cpo&vim + +let s:ft = matchstr(&ft, '^\([^.]\)\+') + +" A bunch of useful C keywords +syn keyword cStatement goto break return continue asm +syn keyword cLabel case default +syn keyword cConditional if else switch +syn keyword cRepeat while for do + +syn keyword cTodo contained TODO FIXME XXX +syn match cTodo contained "@todo" +syn match cTodo contained "@note" + +" It's easy to accidentally add a space after a backslash that was intended +" for line continuation. Some compilers allow it, which makes it +" unpredictable and should be avoided. +syn match cBadContinuation contained "\\\s\+$" + +" cCommentGroup allows adding matches for special things in comments +syn cluster cCommentGroup contains=cTodo,cBadContinuation + +" String and Character constants +" Highlight special characters (those which have a backslash) differently +syn match cSpecial display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)" +if !exists("c_no_utf") + syn match cSpecial display contained "\\\(u\x\{4}\|U\x\{8}\)" +endif + +if !exists("c_no_cformat") + " Highlight % items in strings. + if !exists("c_no_c99") " ISO C99 + syn match cFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlLjzt]\|ll\|hh\)\=\([aAbdiuoxXDOUfFeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained + else + syn match cFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([bdiuoxXDOUfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained + endif + syn match cFormat display "%%" contained +endif + +" cCppString: same as cString, but ends at end of line +if s:ft ==# "cpp" && !exists("cpp_no_cpp11") && !exists("c_no_cformat") + " ISO C++11 + syn region cString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend + syn region cCppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell +elseif s:ft ==# "c" && !exists("c_no_c11") && !exists("c_no_cformat") + " ISO C99 + syn region cString start=+\%(L\|U\|u8\)\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend + syn region cCppString start=+\%(L\|U\|u8\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell +else + " older C or C++ + syn match cFormat display "%%" contained + syn region cString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend + syn region cCppString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell +endif + +syn region cCppSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppSkip + +syn cluster cStringGroup contains=cCppString,cCppSkip + +syn match cCharacter "L\='[^\\]'" +syn match cCharacter "L'[^']*'" contains=cSpecial +if exists("c_gnu") + syn match cSpecialError "L\='\\[^'\"?\\abefnrtv]'" + syn match cSpecialCharacter "L\='\\['\"?\\abefnrtv]'" +else + syn match cSpecialError "L\='\\[^'\"?\\abfnrtv]'" + syn match cSpecialCharacter "L\='\\['\"?\\abfnrtv]'" +endif +syn match cSpecialCharacter display "L\='\\\o\{1,3}'" +syn match cSpecialCharacter display "'\\x\x\{1,2}'" +syn match cSpecialCharacter display "L'\\x\x\+'" + +if (s:ft ==# "c" && !exists("c_no_c11")) || (s:ft ==# "cpp" && !exists("cpp_no_cpp11")) + " ISO C11 or ISO C++ 11 + if exists("c_no_cformat") + syn region cString start=+\%(U\|u8\=\)"+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,@Spell extend + else + syn region cString start=+\%(U\|u8\=\)"+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend + endif + syn match cCharacter "[Uu]'[^\\]'" + syn match cCharacter "[Uu]'[^']*'" contains=cSpecial + if exists("c_gnu") + syn match cSpecialError "[Uu]'\\[^'\"?\\abefnrtv]'" + syn match cSpecialCharacter "[Uu]'\\['\"?\\abefnrtv]'" + else + syn match cSpecialError "[Uu]'\\[^'\"?\\abfnrtv]'" + syn match cSpecialCharacter "[Uu]'\\['\"?\\abfnrtv]'" + endif + syn match cSpecialCharacter display "[Uu]'\\\o\{1,3}'" + syn match cSpecialCharacter display "[Uu]'\\x\x\+'" +endif + +"when wanted, highlight trailing white space +if exists("c_space_errors") + if !exists("c_no_trail_space_error") + syn match cSpaceError display excludenl "\s\+$" + endif + if !exists("c_no_tab_space_error") + syn match cSpaceError display " \+\t"me=e-1 + endif +endif + +" This should be before cErrInParen to avoid problems with #define ({ xxx }) +if exists("c_curly_error") + syn match cCurlyError "}" + syn region cBlock start="{" end="}" contains=ALLBUT,cBadBlock,cCurlyError,@cParenGroup,cErrInParen,cCppParen,cErrInBracket,cCppBracket,@cStringGroup,@Spell fold +else + syn region cBlock start="{" end="}" transparent fold +endif + +" Catch errors caused by wrong parenthesis and brackets. +" Also accept <% for {, %> for }, <: for [ and :> for ] (C99) +" But avoid matching <::. +syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserLabel,cBitField,cOctalZero,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom +if exists("c_no_curly_error") + if s:ft ==# 'cpp' && !exists("cpp_no_cpp11") + syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,@cStringGroup,@Spell + " cCppParen: same as cParen but ends at end-of-line; used in cDefine + syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell + syn match cParenError display ")" + syn match cErrInParen display contained "^^<%\|^%>" + else + syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,@cStringGroup,@Spell + " cCppParen: same as cParen but ends at end-of-line; used in cDefine + syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell + syn match cParenError display ")" + syn match cErrInParen display contained "^[{}]\|^<%\|^%>" + endif +elseif exists("c_no_bracket_error") + if s:ft ==# 'cpp' && !exists("cpp_no_cpp11") + syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,@cStringGroup,@Spell + " cCppParen: same as cParen but ends at end-of-line; used in cDefine + syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell + syn match cParenError display ")" + syn match cErrInParen display contained "<%\|%>" + else + syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,@cStringGroup,@Spell + " cCppParen: same as cParen but ends at end-of-line; used in cDefine + syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell + syn match cParenError display ")" + syn match cErrInParen display contained "[{}]\|<%\|%>" + endif +else + if s:ft ==# 'cpp' && !exists("cpp_no_cpp11") + syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,@cStringGroup,@Spell + " cCppParen: same as cParen but ends at end-of-line; used in cDefine + syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell + syn match cParenError display "[\])]" + syn match cErrInParen display contained "<%\|%>" + syn region cBracket transparent start='\[\|<::\@!' end=']\|:>' contains=ALLBUT,@cParenGroup,cErrInParen,cCppParen,cCppBracket,@cStringGroup,@Spell + else + syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,@cStringGroup,@Spell + " cCppParen: same as cParen but ends at end-of-line; used in cDefine + syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell + syn match cParenError display "[\])]" + syn match cErrInParen display contained "[\]{}]\|<%\|%>" + syn region cBracket transparent start='\[\|<::\@!' end=']\|:>' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cErrInParen,cCppParen,cCppBracket,@cStringGroup,@Spell + endif + " cCppBracket: same as cParen but ends at end-of-line; used in cDefine + syn region cCppBracket transparent start='\[\|<::\@!' skip='\\$' excludenl end=']\|:>' end='$' contained contains=ALLBUT,@cParenGroup,cErrInParen,cParen,cBracket,cString,@Spell + syn match cErrInBracket display contained "[);{}]\|<%\|%>" +endif + +if s:ft ==# 'c' || exists("cpp_no_cpp11") + syn region cBadBlock keepend start="{" end="}" contained containedin=cParen,cBracket,cBadBlock transparent fold +endif + +"integer number, or floating point number without a dot and with "f". +syn case ignore +syn match cNumbers display transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctalError,cOctal +" Same, but without octal error (for comments) +syn match cNumbersCom display contained transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctal +syn match cNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>" +"hex number +syn match cNumber display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>" +" Flag the first zero of an octal number as something special +syn match cOctal display contained "0\o\+\(u\=l\{0,2}\|ll\=u\)\>" contains=cOctalZero +syn match cOctalZero display contained "\<0" +syn match cFloat display contained "\d\+f" +"floating point number, with dot, optional exponent +syn match cFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=" +"floating point number, starting with a dot, optional exponent +syn match cFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>" +"floating point number, without dot, with exponent +syn match cFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>" +if !exists("c_no_c99") + "hexadecimal floating point number, optional leading digits, with dot, with exponent + syn match cFloat display contained "0x\x*\.\x\+p[-+]\=\d\+[fl]\=\>" + "hexadecimal floating point number, with leading digits, optional dot, with exponent + syn match cFloat display contained "0x\x\+\.\=p[-+]\=\d\+[fl]\=\>" +endif + +" flag an octal number with wrong digits +syn match cOctalError display contained "0\o*[89]\d*" +syn case match + +if exists("c_comment_strings") + " A comment can contain cString, cCharacter and cNumber. + " But a "*/" inside a cString in a cComment DOES end the comment! So we + " need to use a special type of cString: cCommentString, which also ends on + " "*/", and sees a "*" at the start of the line as comment again. + " Unfortunately this doesn't very well work for // type of comments :-( + syn match cCommentSkip contained "^\s*\*\($\|\s\+\)" + syn region cCommentString contained start=+L\=\\\@" skip="\\$" end="$" keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError +syn match cPreConditMatch display "^\s*\zs\(%:\|#\)\s*\(else\|endif\)\>" +if !exists("c_no_if0") + syn cluster cCppOutInGroup contains=cCppInIf,cCppInElse,cCppInElse2,cCppOutIf,cCppOutIf2,cCppOutElse,cCppInSkip,cCppOutSkip + syn region cCppOutWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0\+\s*\($\|//\|/\*\|&\)" end=".\@=\|$" contains=cCppOutIf,cCppOutElse,@NoSpell fold + syn region cCppOutIf contained start="0\+" matchgroup=cCppOutWrapper end="^\s*\zs\(%:\|#\)\s*endif\>" contains=cCppOutIf2,cCppOutElse + if !exists("c_no_if0_fold") + syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell fold + else + syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell + endif + syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\zs\(%:\|#\)\s*\(else\|elif\)" end="^\s*\zs\(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit + syn region cCppInWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0*[1-9]\d*\s*\($\|//\|/\*\||\)" end=".\@=\|$" contains=cCppInIf,cCppInElse fold + syn region cCppInIf contained matchgroup=cCppInWrapper start="\d\+" end="^\s*\zs\(%:\|#\)\s*endif\>" contains=TOP,cPreCondit + if !exists("c_no_if0_fold") + syn region cCppInElse contained start="^\s*\zs\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 fold + else + syn region cCppInElse contained start="^\s*\zs\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 + endif + syn region cCppInElse2 contained matchgroup=cCppInWrapper start="^\s*\zs\(%:\|#\)\s*\(else\|elif\)\([^/]\|/[^/*]\)*" end="^\s*\zs\(%:\|#\)\s*endif\>"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell + syn region cCppOutSkip contained start="^\s*\zs\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\zs\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppOutSkip + syn region cCppInSkip contained matchgroup=cCppInWrapper start="^\s*\zs\(%:\|#\)\s*\(if\s\+\(\d\+\s*\($\|//\|/\*\||\|&\)\)\@!\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\zs\(%:\|#\)\s*endif\>" containedin=cCppOutElse,cCppInIf,cCppInSkip contains=TOP,cPreProc +endif +syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+ +syn match cIncluded display contained "<[^>]*>" +syn match cInclude display "^\s*\zs\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded +"syn match cLineSkip "\\$" +syn cluster cPreProcGroup contains=cPreCondit,cIncluded,cInclude,cDefine,cErrInParen,cErrInBracket,cUserLabel,cSpecial,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cString,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cParen,cBracket,cMulti,cBadBlock +syn region cDefine start="^\s*\zs\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell +syn region cPreProc start="^\s*\zs\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell + +" Highlight User Labels +syn cluster cMultiGroup contains=cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cCppParen,cCppBracket,cCppString +if s:ft ==# 'c' || exists("cpp_no_cpp11") + syn region cMulti transparent start='?' skip='::' end=':' contains=ALLBUT,@cMultiGroup,@Spell,@cStringGroup +endif +" Avoid matching foo::bar() in C++ by requiring that the next char is not ':' +syn cluster cLabelGroup contains=cUserLabel +syn match cUserCont display "^\s*\zs\I\i*\s*:$" contains=@cLabelGroup +syn match cUserCont display ";\s*\zs\I\i*\s*:$" contains=@cLabelGroup +if s:ft ==# 'cpp' + syn match cUserCont display "^\s*\zs\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup + syn match cUserCont display ";\s*\zs\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup +else + syn match cUserCont display "^\s*\zs\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup + syn match cUserCont display ";\s*\zs\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup +endif + +syn match cUserLabel display "\I\i*" contained + +" Avoid recognizing most bitfields as labels +syn match cBitField display "^\s*\zs\I\i*\s*:\s*[1-9]"me=e-1 contains=cType +syn match cBitField display ";\s*\zs\I\i*\s*:\s*[1-9]"me=e-1 contains=cType + +if exists("c_minlines") + let b:c_minlines = c_minlines +else + if !exists("c_no_if0") + let b:c_minlines = 50 " #if 0 constructs can be long + else + let b:c_minlines = 15 " mostly for () constructs + endif +endif +if exists("c_curly_error") + syn sync fromstart +else + exec "syn sync ccomment cComment minlines=" . b:c_minlines +endif + +" Define the default highlighting. +" Only used when an item doesn't have highlighting yet +hi def link cFormat cSpecial +hi def link cCppString cString +hi def link cCommentL cComment +hi def link cCommentStart cComment +hi def link cLabel Label +hi def link cUserLabel Label +hi def link cConditional Conditional +hi def link cRepeat Repeat +hi def link cCharacter Character +hi def link cSpecialCharacter cSpecial +hi def link cNumber Number +hi def link cOctal Number +hi def link cOctalZero PreProc " link this to Error if you want +hi def link cFloat Float +hi def link cOctalError cError +hi def link cParenError cError +hi def link cErrInParen cError +hi def link cErrInBracket cError +hi def link cCommentError cError +hi def link cCommentStartError cError +hi def link cSpaceError cError +hi def link cSpecialError cError +hi def link cCurlyError cError +hi def link cOperator Operator +hi def link cStructure Structure +hi def link cStorageClass StorageClass +hi def link cInclude Include +hi def link cPreProc PreProc +hi def link cDefine Macro +hi def link cIncluded cString +hi def link cError Error +hi def link cStatement Statement +hi def link cCppInWrapper cCppOutWrapper +hi def link cCppOutWrapper cPreCondit +hi def link cPreConditMatch cPreCondit +hi def link cPreCondit PreCondit +hi def link cType Type +hi def link cConstant Constant +hi def link cCommentString cString +hi def link cComment2String cString +hi def link cCommentSkip cComment +hi def link cString String +hi def link cComment Comment +hi def link cSpecial SpecialChar +hi def link cTodo Todo +hi def link cBadContinuation Error +hi def link cCppOutSkip cCppOutIf2 +hi def link cCppInElse2 cCppOutIf2 +hi def link cCppOutIf2 cCppOut +hi def link cCppOut Comment + +let b:current_syntax = "c" + +unlet s:ft + +let &cpo = s:cpo_save +unlet s:cpo_save +" vim: ts=8 diff --git a/nvim/.config/nvim/syntax/cpp.vim b/nvim/.config/nvim/syntax/cpp.vim new file mode 100644 index 0000000..a1f4170 --- /dev/null +++ b/nvim/.config/nvim/syntax/cpp.vim @@ -0,0 +1,119 @@ +" Vim syntax file +" Language: C++ +" Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp) +" Previous Maintainer: Ken Shan +" Last Change: 2015 Nov 10 + +" For version 5.x: Clear all syntax items +" For version 6.x: Quit when a syntax file was already loaded +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +" Read the C syntax to start with +if version < 600 + so :p:h/c.vim +else + runtime! syntax/c.vim + unlet b:current_syntax +endif + +" C++ extensions +syn keyword cppStatement new delete this friend using +syn keyword cppAccess public protected private +syn keyword cppModifier inline virtual explicit export +syn keyword cppType bool wchar_t +syn keyword cppExceptions throw try catch +syn keyword cppOperator operator typeid +syn keyword cppOperator and bitor or xor compl bitand and_eq or_eq xor_eq not not_eq +syn match cppCast "\<\(const\|static\|dynamic\|reinterpret\)_cast\s*<"me=e-1 +syn match cppCast "\<\(const\|static\|dynamic\|reinterpret\)_cast\s*$" +syn keyword cppStorageClass mutable +syn keyword cppStructure class typename template namespace +syn keyword cppBoolean true false +syn keyword cppConstant __cplusplus + +" C++ 11 extensions +if !exists("cpp_no_cpp11") + syn keyword cppModifier override final + syn keyword cppType nullptr_t + syn keyword cppExceptions noexcept + syn keyword cppStorageClass constexpr decltype thread_local + syn keyword cppConstant nullptr + syn keyword cppConstant ATOMIC_FLAG_INIT ATOMIC_VAR_INIT + syn keyword cppConstant ATOMIC_BOOL_LOCK_FREE ATOMIC_CHAR_LOCK_FREE + syn keyword cppConstant ATOMIC_CHAR16_T_LOCK_FREE ATOMIC_CHAR32_T_LOCK_FREE + syn keyword cppConstant ATOMIC_WCHAR_T_LOCK_FREE ATOMIC_SHORT_LOCK_FREE + syn keyword cppConstant ATOMIC_INT_LOCK_FREE ATOMIC_LONG_LOCK_FREE + syn keyword cppConstant ATOMIC_LLONG_LOCK_FREE ATOMIC_POINTER_LOCK_FREE + syn region cppRawString matchgroup=cppRawStringDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"+ contains=@Spell +endif + +" C++ 14 extensions +if !exists("cpp_no_cpp14") + syn match cppNumber display "\<0b[01]\+\(u\=l\{0,2}\|ll\=u\)\>" +endif + +" The minimum and maximum operators in GNU C++ +syn match cppMinMax "[<>]?" + +" Default highlighting +if version >= 508 || !exists("did_cpp_syntax_inits") + if version < 508 + let did_cpp_syntax_inits = 1 + command -nargs=+ HiLink hi link + else + command -nargs=+ HiLink hi def link + endif + HiLink cppAccess cppStatement + HiLink cppCast cppStatement + HiLink cppExceptions Exception + HiLink cppOperator Operator + HiLink cppStatement Statement + HiLink cppModifier Type + HiLink cppType Type + HiLink cppStorageClass StorageClass + HiLink cppStructure Structure + HiLink cppBoolean Boolean + HiLink cppConstant Constant + HiLink cppRawStringDelimiter Delimiter + HiLink cppRawString String + HiLink cppNumber Number + delcommand HiLink +endif + + +function! RawStringEnableCodeSnip(filetype,start,end,textSnipHl) abort + let ft=toupper(a:filetype) + let group='textGroup'.ft + if exists('b:current_syntax') + let s:current_syntax=b:current_syntax + " Remove current syntax definition, as some syntax files (e.g. cpp.vim) + " do nothing if b:current_syntax is defined. + unlet b:current_syntax + endif + execute 'syntax include @'.group.' syntax/'.a:filetype.'.vim' + try + execute 'syntax include @'.group.' after/syntax/'.a:filetype.'.vim' + catch + endtry + if exists('s:current_syntax') + let b:current_syntax=s:current_syntax + else + unlet b:current_syntax + endif + execute 'syntax region textSnip'.ft.' + \ matchgroup='.a:textSnipHl.' + \ start=+'.a:start.'+ end=+'.a:end.'+ + \ contains=@'.group +endfunction + + +call RawStringEnableCodeSnip("chaiscript", 'R"chaiscript(', ')chaiscript"', 'cppRawString') +call RawStringEnableCodeSnip("lua", 'R"lua(', ')lua"', 'cppRawString') + +let b:current_syntax = "cpp" + +" vim: ts=8 diff --git a/nvim/.config/nvim/syntax/lang.vim b/nvim/.config/nvim/syntax/lang.vim new file mode 100644 index 0000000..d5285ae --- /dev/null +++ b/nvim/.config/nvim/syntax/lang.vim @@ -0,0 +1,39 @@ +" quit when a syntax file was already loaded +if exists("b:current_syntax") + finish +endif +" @todo \ at end of line should continue on next line + +" Hello this is a test to see if it auto wraps the text when the text has been +" going on for way too long + +" syn match langSpecial display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)" +" We only highlight valid escape characters as for now it just ignores unknown +" thing +syn match langSpecial display contained "\\[abfnrtv]" +syn match langError "^.\+" +syn keyword langTodo contained TODO FIXME XXX NOTE +syn match langTodo contained "@todo" +syn match langTodo contained "@note" +syn region langSection start="^\s*\[" end="\]" +syn match langKey "^.\{-}\ze=" +syn match langValue "[#=]\zs.*$" contains=langSub,langSpecial,langValue +syn match langValue contained "\\\n.\+" contains=langValue +" syn match langSub "{[^}]\+}" " This is for fmt support +syn match langSub "{\d\+}" +syn match langComment "[#;].*$" contains=langTodo + +hi def link langTodo Todo +hi def link langSpecial Special +hi def link langSection Type +hi def link langKey Identifier +hi def link langValue String +hi def link langValue2 String +hi def link langSub Constant +hi def link langComment Comment +hi def link langError Error + + +let b:current_syntax = "lang" + +" vim: sts=2 sw=2 et diff --git a/scripts/current_song b/scripts/current_song new file mode 100755 index 0000000..102cabe --- /dev/null +++ b/scripts/current_song @@ -0,0 +1,20 @@ +META=$(qdbus org.mpris.MediaPlayer2.mopidy /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata) +TITLE=$(echo "$META" | grep title | cut -d " " -f2-) +ARTIST=$(echo "$META" | grep artist | cut -d " " -f2-) +FILE=$(echo ~/.lyrics/$ARTIST - $TITLE.txt) +TRACKLIST=$(cat "$FILE") + +POSITION=$(qdbus org.mpris.MediaPlayer2.mopidy /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Position) + +PLAYING="Intro" + +for TRACK in `echo "$TRACKLIST" | grep -oP "\[\d{2}:\d{2}\]" | sed "s/\[//g"`; do + MIN=$(echo $TRACK | grep -oP "\d{2}(?=:)" | sed 's/^0*//') + SEC=$(echo $TRACK | grep -oP "\d{2}(?=])" | sed 's/^0*//') + TIME=$(echo "$((MIN*60*1000000+SEC*1000000))") + if [ $POSITION -gt $TIME ]; then + PLAYING=$(echo "$TRACKLIST" | grep "$TRACK") + fi +done + +echo "$PLAYING" diff --git a/scripts/dmenu_run_perso b/scripts/dmenu_run_perso new file mode 100755 index 0000000..96137fd --- /dev/null +++ b/scripts/dmenu_run_perso @@ -0,0 +1,5 @@ +#!/bin/sh +# colors taken from the solarized color scheme, see .Xresources + +dmenu_run -b -i -nb "#FDF6E3" -nf "#839496" -sf "#FFFFFF" -sb "#DC322F" -fn 'Source Code Pro-9' + diff --git a/scripts/podcasts b/scripts/podcasts new file mode 100755 index 0000000..53177a8 --- /dev/null +++ b/scripts/podcasts @@ -0,0 +1,168 @@ +#!/bin/bash +# GUID=0d7c1b6929d53 +GUID=70998f4a07e13 + +function get_first_number { + printf "%03.f" $(echo $1 | sed -r 's/\./_/g' | sed -r 's/^([^.]+).*$/\1/; s/^[^0-9]*([0-9]+).*$/\1/') + # echo $1 | sed -r 's/\./_/' | sed -r 's/^([^.]+).*$/\1/; s/^[^0-9]*([0-9]+).*$/\1/' +} + +# $1 = SEARCH +function get_tracklist_url { + LINKS=$(curl -F 'search_selection=9' -F 'main_search='"$1" https://www.1001tracklists.com/search/result.php --silent |\ + grep -o ' "/home/tim/Muziek/$FEED_NAME/$ARTIST - $ALBUM $1.txt" + else + echo "FAILED: $(parse_json "$JSON" "message")" + fi +} + +# $1 = FILE +# $2 = NUMVER +function tag_file { + # id3 -M -d -t "$ALBUM $NUMBER" -a "$ARTIST" -l "$ALBUM" -n $2 $1 + # id3v2 --APIC cover.jpg $1 + echo "Tagging $1 $2" + tageditor --set --force-rewrite --remove-other-fields title="$ALBUM $2" artist="$ARTIST" album="$ALBUM" cover=cover.jpg --files "$1" -v + tageditor --set --force-rewrite track="$2" --files "$1" -v + # Maybe we should check if the file is a mp3 + # id3ted -T $2 $1 + rm $1.bak 2> /dev/null +} + +# $1 = SONG +# $2 = NUMBER +function rename_file { + + FILENAME=$(echo "$ALBUM" "$2") + FILENAME=$(echo "${FILENAME// /_}.${1##*.}") + + echo "$1 -> $FILENAME" + + mv "$1" "$FILENAME" 2> /dev/null +} + +function do_feed { + echo "$ARTIST - $ALBUM" + #Check if there are new episodes + NEW_EPISODE_COUNT=$(podfox update $FEED_NAME | grep "new episode." | wc -l) + SONGS="" + + if [ -z $(echo $NEW_EPISODE_COUNT | grep 0) ]; then + echo "Downloading new episodes" + SONGS=$(podfox download $FEED_NAME --how-many=$NEW_EPISODE_COUNT) + fi + + for SONG in `find . | grep -e "mp3" -e "m4a"`; do + NUMBER=$(get_first_number "$SONG") + + if [ ! -f "/home/tim/Muziek/$FEED_NAME/$ARTIST - $ALBUM $NUMBER.txt" ]; then + # This should be a seperate loop, that downloads all missing tracklists + # echo "Tracklist disabled" + echo $SONG $NUMBER + write_tracklist $NUMBER + fi + done + + for SONG in `echo $SONGS | sed 's/ /\n/g' | grep -v "http" | grep -e ".mp3" -e ".m4a"`; do + # Now all we need to do is use podfox to figure out if there are new podcasts and tag those + NUMBER=$(get_first_number "$SONG") + + tag_file "$SONG" "$NUMBER" + + rename_file "$SONG" "$NUMBER" + done +} + +# function do_feed2 { +# echo "$ARTIST - $ALBUM" +# #Check if there are new episodes +# # NEW_EPISODE_COUNT=$(podfox update $FEED_NAME | grep "new episode." | wc -l) +# NEW_EPISODE_COUNT=0 +# SONGS="" +# +# if [ -z $(echo $NEW_EPISODE_COUNT | grep 0) ]; then +# echo "Downloading new episodes" +# SONGS=$(podfox download $FEED_NAME --how-many=$NEW_EPISODE_COUNT) +# fi +# +# for SONG in `find . | grep -e "mp3" -e "m4a"`; do +# NUMBER=$(get_first_number "$SONG") +# +# if [ ! -f "/home/tim/.lyrics/$ARTIST - $ALBUM $NUMBER.txt" ]; then +# # This should be a seperate loop, that downloads all missing tracklists +# # echo "Tracklist disabled" +# echo $SONG $NUMBER +# write_tracklist $NUMBER +# fi +# done +# +# for SONG in `echo $SONGS | sed 's/ /\n/g' | grep -v "http" | grep -e ".mp3" -e ".m4a"`; do +# # Now all we need to do is use podfox to figure out if there are new podcasts and tag those +# NUMBER=$(get_first_number "$SONG") +# +# tag_file "$SONG" "$NUMBER" +# +# rename_file "$SONG" "$NUMBER" +# done +# } + +ARTIST="Oliver Heldens" +ALBUM="Heldeep Radio" +SEARCH_BASE="Oliver Heldens Heldeep Radio" +FEED_NAME="heldeep" +cd /home/tim/Muziek/heldeep +do_feed + +ARTIST="Sam Feldt" +ALBUM="Heartfeldt Radio" +SEARCH_BASE="Sam Feldt Heartfeldt Radio" +FEED_NAME="heartfeldt" +cd /home/tim/Muziek/heartfeldt +do_feed + +# ARTIST="Mr. Belt & Wezol" +# ALBUM="Music Club" +# SEARCH_BASE="Mr. Belt Wezol Music Club" +# FEED_NAME="music-club" +# cd /home/tim/Muziek/music-club +# do_feed2 + +ARTIST="Mr. Belt & Wezol" +ALBUM="The Cuckoo's Nest" +SEARCH_BASE="Mr. Belt Wezol The Cuckoos Nest" +FEED_NAME="cuckoos-nest" +cd /home/tim/Muziek/cuckoos-nest +do_feed + +mopidy local scan diff --git a/scripts/start-ncmpcpp b/scripts/start-ncmpcpp new file mode 100755 index 0000000..0fb78fc --- /dev/null +++ b/scripts/start-ncmpcpp @@ -0,0 +1,3 @@ +/usr/lib/gnome-terminal/gnome-terminal-server --app-id nl.ncmpcpp --name ncmpcpp & +sleep 0.2 +gnome-terminal --app-id nl.ncmpcpp -e ncmpcpp diff --git a/scripts/start-vim b/scripts/start-vim new file mode 100755 index 0000000..8397e53 --- /dev/null +++ b/scripts/start-vim @@ -0,0 +1,3 @@ +/usr/lib/gnome-terminal/gnome-terminal-server --app-id nl.vim --name vim & +sleep 0.2 +gnome-terminal --app-id nl.vim --title "Vim" -e "nvim \"$@\"" diff --git a/zsh/.zshrc b/zsh/.zshrc index 07cdc29..48c7558 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -16,9 +16,11 @@ export TERM="screen-256color" export SAL_USE_VCLPLUGIN="gtk" export GOPATH="$HOME/.local/go" export PATH="$HOME/.local/go/bin:$PATH" +export USE_CCACHE=1 #setting aliases alias cl="clear" +alias mtgames.nl="gnome-terminal -x ssh server@188.166.73.149 -t tmux a" alias vim="nvim" alias tmux="tmux -2" alias attach="tmux a" @@ -26,3 +28,9 @@ alias wcp="wc -l **/src/**/*.cpp **/include/**/*.h" #start tmux if [ -z "$TMUX" ]; then tmux; exit; fi + +export FZF_DEFAULT_OPTS='--height 20%' +export FZF_DEFAULT_COMMAND='ag -g ""' +export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" + +[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh