diff --git a/git/.config/git/config b/git/.config/git/config
index 0561d80..f6c7d9e 100644
--- a/git/.config/git/config
+++ b/git/.config/git/config
@@ -6,18 +6,16 @@
sshCommand = ssh -F ~/.config/ssh/config -o UserKnownHostsFile='/home/moo/.config/ssh/known_hosts'
quotePath = false
commitGraph = true
- autocrlf = input
[user]
- email = alister@kamikishi.net
+ email = the7772howaboutyou@protonmail.com
name = riomoo
- signingkey = /home/moo/.config/ssh/gpg/alisteratkamikishi/id_ed25519.pub
- #signingkey = 554AF2CEAE26AC80
- #email = the7772howaboutyou@protonmail.com
+ signingkey = /home/moo/.config/ssh/gpg/the7772/id_ed25519.pub
+ #signingkey = FEC86E49B4437D4D
[alias]
resign = "!re() { git rebase --exec 'git commit --amend --no-edit -n -S' -i $1; }; re"
gwtm = worktree add master
- gwtd = worktree add -b dev dev master
+ gwtd = worktree add -b dev dev master
gwtf = worktree add -b feat feat dev
gwtrf = worktree remove feat
gbrf = branch -D feat
@@ -32,7 +30,6 @@
lg2-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(auto)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
lg3-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'
lg4-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'
- ll = log --graph --format=\"%C(yellow)%h%C(red)%d%C(reset) - %C(bold green)(%ar)%C(reset) %s %C(blue)<%an>%C(reset)\"
[push]
@@ -64,3 +61,5 @@
allowedSignersFile = /home/moo/.config/ssh/allowed_signers
[commit]
gpgsign = true
+[init]
+ defaultBranch = main
diff --git a/ssh/.config/ssh/known_hosts b/ssh/.config/ssh/known_hosts
deleted file mode 100644
index 3f19782..0000000
--- a/ssh/.config/ssh/known_hosts
+++ /dev/null
@@ -1 +0,0 @@
-192.168.0.100 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICNFyL6rb/ksObeVeDkUeh2e+g9eAYfD6SRT5hHMjNa8
diff --git a/vim/.config/vim/autoload/plug.vim b/vim/.config/vim/autoload/plug.vim
index 589e4f3..6c0fd20 100644
--- a/vim/.config/vim/autoload/plug.vim
+++ b/vim/.config/vim/autoload/plug.vim
@@ -1,36 +1,67 @@
" vim-plug: Vim plugin manager
" ============================
"
-" 1. Download plug.vim and put it in 'autoload' directory
+" Download plug.vim and put it in ~/.vim/autoload
"
-" # Vim
" curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
"
-" # Neovim
-" sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
-" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
+" Edit your .vimrc
"
-" 2. Add a vim-plug section to your ~/.vimrc (or ~/.config/nvim/init.vim for Neovim)
+" call plug#begin('~/.vim/plugged')
"
-" call plug#begin()
+" " Make sure you use single quotes
"
-" " List your plugins here
-" Plug 'tpope/vim-sensible'
+" " Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
+" Plug 'junegunn/vim-easy-align'
"
+" " Any valid git URL is allowed
+" Plug 'https://github.com/junegunn/vim-github-dashboard.git'
+"
+" " Multiple Plug commands can be written in a single line using | separators
+" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
+"
+" " On-demand loading
+" Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
+" Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
+"
+" " Using a non-default 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' }
+"
+" " Plugin outside ~/.vim/plugged with post-update hook
+" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
+"
+" " Unmanaged plugin (manually installed and updated)
+" Plug '~/my-prototype-plugin'
+"
+" " Initialize plugin system
" call plug#end()
"
-" 3. Reload the file or restart Vim, then you can,
+" Then reload .vimrc and :PlugInstall to install plugins.
"
-" :PlugInstall to install plugins
-" :PlugUpdate to update plugins
-" :PlugDiff to review the changes from the last update
-" :PlugClean to remove plugins no longer in the list
+" Plug options:
"
-" For more information, see https://github.com/junegunn/vim-plug
+"| Option | Description |
+"| ----------------------- | ------------------------------------------------ |
+"| `branch`/`tag`/`commit` | Branch/tag/commit of the repository to use |
+"| `rtp` | Subdirectory that contains Vim plugin |
+"| `dir` | Custom directory for the plugin |
+"| `as` | Use different name for the plugin |
+"| `do` | Post-update hook (string or funcref) |
+"| `on` | On-demand loading: Commands or ``-mappings |
+"| `for` | On-demand loading: File types |
+"| `frozen` | Do not update unless explicitly specified |
+"
+" More information: https://github.com/junegunn/vim-plug
"
"
-" Copyright (c) 2024 Junegunn Choi
+" Copyright (c) 2017 Junegunn Choi
"
" MIT License
"
@@ -207,11 +238,10 @@ endfunction
function! plug#begin(...)
if a:0 > 0
+ let s:plug_home_org = a:1
let home = s:path(s:plug_fnamemodify(s:plug_expand(a:1), ':p'))
elseif exists('g:plug_home')
let home = s:path(g:plug_home)
- elseif has('nvim')
- let home = stdpath('data') . '/plugged'
elseif !empty(&rtp)
let home = s:path(split(&rtp, ',')[0]) . '/plugged'
else
@@ -320,7 +350,7 @@ function! plug#end()
endif
let lod = { 'ft': {}, 'map': {}, 'cmd': {} }
- if get(g:, 'did_load_filetypes', 0)
+ if exists('g:did_load_filetypes')
filetype off
endif
for name in g:plugs_order
@@ -359,9 +389,6 @@ function! plug#end()
if !empty(types)
augroup filetypedetect
call s:source(s:rtp(plug), 'ftdetect/**/*.vim', 'after/ftdetect/**/*.vim')
- if has('nvim-0.5.0')
- call s:source(s:rtp(plug), 'ftdetect/**/*.lua', 'after/ftdetect/**/*.lua')
- endif
augroup END
endif
for type in types
@@ -372,15 +399,13 @@ function! plug#end()
for [cmd, names] in items(lod.cmd)
execute printf(
- \ has('patch-7.4.1898')
- \ ? 'command! -nargs=* -range -bang -complete=file %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))
+ \ 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "", , , , %s)',
+ \ cmd, string(cmd), string(names))
endfor
for [map, names] in items(lod.map)
for [mode, map_prefix, key_prefix] in
- \ [['i', '', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']]
+ \ [['i', '', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']]
execute printf(
\ '%snoremap %s %s:call lod_map(%s, %s, %s, "%s")',
\ mode, map, map_prefix, string(map), string(names), mode != 'i', key_prefix)
@@ -411,9 +436,6 @@ endfunction
function! s:load_plugin(spec)
call s:source(s:rtp(a:spec), 'plugin/**/*.vim', 'after/plugin/**/*.vim')
- if has('nvim-0.5.0')
- call s:source(s:rtp(a:spec), 'plugin/**/*.lua', 'after/plugin/**/*.lua')
- endif
endfunction
function! s:reload_plugins()
@@ -631,9 +653,6 @@ function! s:lod(names, types, ...)
let rtp = s:rtp(g:plugs[name])
for dir in a:types
call s:source(rtp, dir.'/**/*.vim')
- if has('nvim-0.5.0') " see neovim#14686
- call s:source(rtp, dir.'/**/*.lua')
- endif
endfor
if a:0
if !s:source(rtp, a:1) && !empty(s:glob(rtp, a:2))
@@ -653,19 +672,11 @@ function! s:lod_ft(pat, names)
call s:doautocmd('filetypeindent', 'FileType')
endfunction
-if has('patch-7.4.1898')
- function! s:lod_cmd(cmd, bang, l1, l2, args, mods, names)
- call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
- call s:dobufread(a:names)
- execute printf('%s %s%s%s %s', a:mods, (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
- endfunction
-else
- 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
-endif
+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, with_prefix, prefix)
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
@@ -793,11 +804,10 @@ endfunction
function! s:syntax()
syntax clear
syntax region plug1 start=/\%1l/ end=/\%2l/ contains=plugNumber
- syntax region plug2 start=/\%2l/ end=/\%3l/ contains=plugBracket,plugX,plugAbort
+ syntax region plug2 start=/\%2l/ end=/\%3l/ contains=plugBracket,plugX
syn match plugNumber /[0-9]\+[0-9.]*/ contained
syn match plugBracket /[[\]]/ contained
syn match plugX /x/ contained
- syn match plugAbort /\~/ contained
syn match plugDash /^-\{1}\ /
syn match plugPlus /^+/
syn match plugStar /^*/
@@ -822,7 +832,6 @@ function! s:syntax()
hi def link plug2 Repeat
hi def link plugH2 Type
hi def link plugX Exception
- hi def link plugAbort Ignore
hi def link plugBracket Structure
hi def link plugNumber Number
@@ -858,7 +867,7 @@ function! s:lastline(msg)
endfunction
function! s:new_window()
- execute get(g:, 'plug_window', '-tabnew')
+ execute get(g:, 'plug_window', 'vertical topleft new')
endfunction
function! s:plug_window_exists()
@@ -920,7 +929,7 @@ function! s:prepare(...)
endif
endfor
- call s:job_abort(0)
+ call s:job_abort()
if s:switch_in()
if b:plug_preview == 1
pc
@@ -956,8 +965,6 @@ function! s:close_pane()
if b:plug_preview == 1
pc
let b:plug_preview = -1
- elseif exists('s:jobs') && !empty(s:jobs)
- call s:job_abort(1)
else
bd
endif
@@ -1022,11 +1029,6 @@ function! s:is_updated(dir)
endfunction
function! s:do(pull, force, todo)
- if has('nvim')
- " Reset &rtp to invalidate Neovim cache of loaded Lua modules
- " See https://github.com/junegunn/vim-plug/pull/1157#issuecomment-1809226110
- let &rtp = &rtp
- endif
for [name, spec] in items(a:todo)
if !isdirectory(spec.dir)
continue
@@ -1085,21 +1087,15 @@ function! s:hash_match(a, b)
return stridx(a:a, a:b) == 0 || stridx(a:b, a:a) == 0
endfunction
-function! s:disable_credential_helper()
- return s:git_version_requirement(2) && get(g:, 'plug_disable_credential_helper', 1)
-endfunction
-
function! s:checkout(spec)
let sha = a:spec.commit
let output = s:git_revision(a:spec.dir)
- let error = 0
if !empty(output) && !s:hash_match(sha, s:lines(output)[0])
- let credential_helper = s:disable_credential_helper() ? '-c credential.helper= ' : ''
+ let credential_helper = s:git_version_requirement(2) ? '-c credential.helper= ' : ''
let output = s:system(
\ 'git '.credential_helper.'fetch --depth 999999 && git checkout '.plug#shellescape(sha).' --', a:spec.dir)
- let error = v:shell_error
endif
- return [output, error]
+ return output
endfunction
function! s:finish(pull)
@@ -1160,7 +1156,7 @@ function! s:update_impl(pull, force, args) abort
let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ?
\ remove(args, -1) : get(g:, 'plug_threads', 16)
- let managed = filter(deepcopy(g:plugs), 's:is_managed(v:key)')
+ let managed = filter(copy(g:plugs), 's:is_managed(v:key)')
let todo = empty(args) ? filter(managed, '!v:val.frozen || !isdirectory(v:val.dir)') :
\ filter(managed, 'index(args, v:key) >= 0')
@@ -1294,11 +1290,9 @@ function! s:update_finish()
if !pos
continue
endif
- let out = ''
- let error = 0
if has_key(spec, 'commit')
call s:log4(name, 'Checking out '.spec.commit)
- let [out, error] = s:checkout(spec)
+ let out = s:checkout(spec)
elseif has_key(spec, 'tag')
let tag = spec.tag
if tag =~ '\*'
@@ -1311,16 +1305,19 @@ function! s:update_finish()
endif
call s:log4(name, 'Checking out '.tag)
let out = s:system('git checkout -q '.plug#shellescape(tag).' -- 2>&1', spec.dir)
- let error = v:shell_error
+ else
+ let branch = s:git_origin_branch(spec)
+ call s:log4(name, 'Merging origin/'.s:esc(branch))
+ let out = s:system('git checkout -q '.plug#shellescape(branch).' -- 2>&1'
+ \. (has_key(s:update.new, name) ? '' : ('&& git merge --ff-only '.plug#shellescape('origin/'.branch).' 2>&1')), spec.dir)
endif
- if !error && filereadable(spec.dir.'/.gitmodules') &&
+ 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'.s:submodule_opt.' 2>&1', spec.dir)
- let error = v:shell_error
endif
let msg = s:format_message(v:shell_error ? 'x': '-', name, out)
- if error
+ if v:shell_error
call add(s:update.errors, name)
call s:regress_bar()
silent execute pos 'd _'
@@ -1344,12 +1341,7 @@ function! s:update_finish()
endif
endfunction
-function! s:mark_aborted(name, message)
- let attrs = { 'running': 0, 'error': 1, 'abort': 1, 'lines': [a:message] }
- let s:jobs[a:name] = extend(get(s:jobs, a:name, {}), attrs)
-endfunction
-
-function! s:job_abort(cancel)
+function! s:job_abort()
if (!s:nvim && !s:vim8) || !exists('s:jobs')
return
endif
@@ -1363,18 +1355,8 @@ function! s:job_abort(cancel)
if j.new
call s:rm_rf(g:plugs[name].dir)
endif
- if a:cancel
- call s:mark_aborted(name, 'Aborted')
- endif
endfor
-
- if a:cancel
- for todo in values(s:update.todo)
- let todo.abort = 1
- endfor
- else
- let s:jobs = {}
- endif
+ let s:jobs = {}
endfunction
function! s:last_non_empty_line(lines)
@@ -1388,16 +1370,6 @@ function! s:last_non_empty_line(lines)
return ''
endfunction
-function! s:bullet_for(job, ...)
- if a:job.running
- return a:job.new ? '+' : '*'
- endif
- if get(a:job, 'abort', 0)
- return '~'
- endif
- return a:job.error ? 'x' : get(a:000, 0, '-')
-endfunction
-
function! s:job_out_cb(self, data) abort
let self = a:self
let data = remove(self.lines, -1) . a:data
@@ -1406,10 +1378,9 @@ function! s:job_out_cb(self, data) abort
" To reduce the number of buffer updates
let self.tick = get(self, 'tick', -1) + 1
if !self.running || self.tick % len(s:jobs) == 0
+ let bullet = self.running ? (self.new ? '+' : '*') : (self.error ? 'x' : '-')
let result = self.error ? join(self.lines, "\n") : s:last_non_empty_line(self.lines)
- if len(result)
- call s:log(s:bullet_for(self), self.name, result)
- endif
+ call s:log(bullet, self.name, result)
endif
endfunction
@@ -1422,7 +1393,7 @@ endfunction
function! s:job_cb(fn, job, ch, data)
if !s:plug_window_exists() " plug window closed
- return s:job_abort(0)
+ return s:job_abort()
endif
call call(a:fn, [a:job, a:data])
endfunction
@@ -1433,17 +1404,16 @@ function! s:nvim_cb(job_id, data, event) dict abort
\ s:job_cb('s:job_exit_cb', self, 0, a:data)
endfunction
-function! s:spawn(name, spec, queue, opts)
- let job = { 'name': a:name, 'spec': a:spec, 'running': 1, 'error': 0, 'lines': [''],
- \ 'new': get(a:opts, 'new', 0), 'queue': copy(a:queue) }
- let Item = remove(job.queue, 0)
- let argv = type(Item) == s:TYPE.funcref ? call(Item, [a:spec]) : Item
+function! s:spawn(name, cmd, opts)
+ let job = { 'name': a:name, 'running': 1, 'error': 0, 'lines': [''],
+ \ 'new': get(a:opts, 'new', 0) }
let s:jobs[a:name] = job
if s:nvim
if has_key(a:opts, 'dir')
let job.cwd = a:opts.dir
endif
+ let argv = a:cmd
call extend(job, {
\ 'on_stdout': function('s:nvim_cb'),
\ 'on_stderr': function('s:nvim_cb'),
@@ -1459,7 +1429,7 @@ function! s:spawn(name, spec, queue, opts)
\ 'Invalid arguments (or job table is full)']
endif
elseif s:vim8
- let cmd = join(map(copy(argv), 'plug#shellescape(v:val, {"script": 0})'))
+ let cmd = join(map(copy(a:cmd), 'plug#shellescape(v:val, {"script": 0})'))
if has_key(a:opts, 'dir')
let cmd = s:with_cd(cmd, a:opts.dir, 0)
endif
@@ -1479,33 +1449,27 @@ function! s:spawn(name, spec, queue, opts)
let job.lines = ['Failed to start job']
endif
else
- let job.lines = s:lines(call('s:system', has_key(a:opts, 'dir') ? [argv, a:opts.dir] : [argv]))
+ let job.lines = s:lines(call('s:system', has_key(a:opts, 'dir') ? [a:cmd, a:opts.dir] : [a:cmd]))
let job.error = v:shell_error != 0
let job.running = 0
endif
endfunction
function! s:reap(name)
- let job = remove(s:jobs, a:name)
+ let job = s:jobs[a:name]
if job.error
call add(s:update.errors, a:name)
elseif get(job, 'new', 0)
let s:update.new[a:name] = 1
endif
+ let s:update.bar .= job.error ? 'x' : '='
- let more = len(get(job, 'queue', []))
+ let bullet = job.error ? 'x' : '-'
let result = job.error ? join(job.lines, "\n") : s:last_non_empty_line(job.lines)
- if len(result)
- call s:log(s:bullet_for(job), a:name, result)
- endif
+ call s:log(bullet, a:name, empty(result) ? 'OK' : result)
+ call s:bar()
- if !job.error && more
- let job.spec.queue = job.queue
- let s:update.todo[a:name] = job.spec
- else
- let s:update.bar .= s:bullet_for(job, '=')
- call s:bar()
- endif
+ call remove(s:jobs, a:name)
endfunction
function! s:bar()
@@ -1558,16 +1522,6 @@ function! s:update_vim()
call s:tick()
endfunction
-function! s:checkout_command(spec)
- let a:spec.branch = s:git_origin_branch(a:spec)
- return ['git', 'checkout', '-q', a:spec.branch, '--']
-endfunction
-
-function! s:merge_command(spec)
- let a:spec.branch = s:git_origin_branch(a:spec)
- return ['git', 'merge', '--ff-only', 'origin/'.a:spec.branch]
-endfunction
-
function! s:tick()
let pull = s:update.pull
let prog = s:progress_opt(s:nvim || s:vim8)
@@ -1582,39 +1536,24 @@ while 1 " Without TCO, Vim stack is bound to explode
let name = keys(s:update.todo)[0]
let spec = remove(s:update.todo, name)
- if get(spec, 'abort', 0)
- call s:mark_aborted(name, 'Skipped')
- call s:reap(name)
- continue
- endif
+ let new = empty(globpath(spec.dir, '.git', 1))
- let queue = get(spec, 'queue', [])
- let new = empty(globpath(spec.dir, '.git', 1))
-
- if empty(queue)
- call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...')
- redraw
- endif
+ call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...')
+ redraw
let has_tag = has_key(spec, 'tag')
- if len(queue)
- call s:spawn(name, spec, queue, { 'dir': spec.dir })
- elseif !new
+ if !new
let [error, _] = s:git_validate(spec, 0)
if empty(error)
if pull
- let cmd = s:disable_credential_helper() ? ['git', '-c', 'credential.helper=', 'fetch'] : ['git', 'fetch']
+ let cmd = s:git_version_requirement(2) ? ['git', '-c', 'credential.helper=', 'fetch'] : ['git', 'fetch']
if has_tag && !empty(globpath(spec.dir, '.git/shallow'))
call extend(cmd, ['--depth', '99999999'])
endif
if !empty(prog)
call add(cmd, prog)
endif
- let queue = [cmd, split('git remote set-head origin -a')]
- if !has_tag && !has_key(spec, 'commit')
- call extend(queue, [function('s:checkout_command'), function('s:merge_command')])
- endif
- call s:spawn(name, spec, queue, { 'dir': spec.dir })
+ call s:spawn(name, cmd, { 'dir': spec.dir })
else
let s:jobs[name] = { 'running': 0, 'lines': ['Already installed'], 'error': 0 }
endif
@@ -1629,7 +1568,7 @@ while 1 " Without TCO, Vim stack is bound to explode
if !empty(prog)
call add(cmd, prog)
endif
- call s:spawn(name, spec, [extend(cmd, [spec.uri, s:trim(spec.dir)]), function('s:checkout_command'), function('s:merge_command')], { 'new': 1 })
+ call s:spawn(name, extend(cmd, [spec.uri, s:trim(spec.dir)]), { 'new': 1 })
endif
if !s:jobs[name].running
@@ -2328,10 +2267,7 @@ endfunction
function! s:with_cd(cmd, dir, ...)
let script = a:0 > 0 ? a:1 : 1
- let pwsh = s:is_powershell(&shell)
- let cd = s:is_win && !pwsh ? 'cd /d' : 'cd'
- let sep = pwsh ? ';' : '&&'
- return printf('%s %s %s %s', cd, plug#shellescape(a:dir, {'script': script, 'shell': &shell}), sep, a:cmd)
+ return printf('cd%s %s && %s', s:is_win ? ' /d' : '', plug#shellescape(a:dir, {'script': script}), a:cmd)
endfunction
function! s:system(cmd, ...)
@@ -2408,21 +2344,18 @@ function! s:git_validate(spec, check_branch)
\ current_branch, origin_branch)
endif
if empty(err)
- let ahead_behind = split(s:lastline(s:system([
- \ 'git', 'rev-list', '--count', '--left-right',
- \ printf('HEAD...origin/%s', origin_branch)
- \ ], a:spec.dir)), '\t')
- if v:shell_error || len(ahead_behind) != 2
- let err = "Failed to compare with the origin. The default branch might have changed.\nPlugClean required."
- else
- let [ahead, behind] = ahead_behind
- if ahead && behind
+ let [ahead, behind] = split(s:lastline(s:system([
+ \ 'git', 'rev-list', '--count', '--left-right',
+ \ printf('HEAD...origin/%s', origin_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.', origin_branch, ahead, behind)
- elseif ahead
+ else
let err = printf("Ahead of origin/%s by %d commit(s).\n"
\ .'Cannot update until local changes are pushed.',
\ origin_branch, ahead)
@@ -2454,7 +2387,7 @@ function! s:clean(force)
let errs = {}
let [cnt, total] = [0, len(g:plugs)]
for [name, spec] in items(g:plugs)
- if !s:is_managed(name) || get(spec, 'frozen', 0)
+ if !s:is_managed(name)
call add(dirs, spec.dir)
else
let [err, clean] = s:git_validate(spec, 1)
@@ -2686,34 +2619,26 @@ function! s:preview_commit()
let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-f]\{7,9}')
if empty(sha)
- let name = matchstr(getline('.'), '^- \zs[^:]*\ze:$')
- if empty(name)
- return
- endif
- let title = 'HEAD@{1}..'
- let command = 'git diff --no-color HEAD@{1}'
- else
- let title = sha
- let command = 'git show --no-color --pretty=medium '.sha
- let name = s:find_name(line('.'))
+ return
endif
+ let name = s:find_name(line('.'))
if empty(name) || !has_key(g:plugs, name) || !isdirectory(g:plugs[name].dir)
return
endif
- if !s:is_preview_window_open()
- execute get(g:, 'plug_pwindow', 'vertical rightbelow new')
- execute 'e' title
+ if exists('g:plug_pwindow') && !s:is_preview_window_open()
+ execute g:plug_pwindow
+ execute 'e' sha
else
- execute 'pedit' title
+ execute 'pedit' sha
wincmd P
endif
- setlocal previewwindow filetype=git buftype=nofile bufhidden=wipe nobuflisted modifiable
+ setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable
let batchfile = ''
try
let [sh, shellcmdflag, shrd] = s:chsh(1)
- let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && '.command
+ let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha
if s:is_win
let [batchfile, cmd] = s:batchfile(cmd)
endif
@@ -2839,9 +2764,9 @@ function! s:snapshot(force, ...) abort
1
let anchor = line('$') - 3
let names = sort(keys(filter(copy(g:plugs),
- \'has_key(v:val, "uri") && isdirectory(v:val.dir)')))
+ \'has_key(v:val, "uri") && !has_key(v:val, "commit") && isdirectory(v:val.dir)')))
for name in reverse(names)
- let sha = has_key(g:plugs[name], 'commit') ? g:plugs[name].commit : s:git_revision(g:plugs[name].dir)
+ let sha = s:git_revision(g:plugs[name].dir)
if !empty(sha)
call append(anchor, printf("silent! let g:plugs['%s'].commit = '%s'", name, sha))
redraw
diff --git a/vim/.config/vim/autoload/plug.vim.old b/vim/.config/vim/autoload/plug.vim.old
deleted file mode 100644
index 6c0fd20..0000000
--- a/vim/.config/vim/autoload/plug.vim.old
+++ /dev/null
@@ -1,2802 +0,0 @@
-" vim-plug: Vim plugin manager
-" ============================
-"
-" Download plug.vim and put it in ~/.vim/autoload
-"
-" curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
-" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
-"
-" Edit your .vimrc
-"
-" call plug#begin('~/.vim/plugged')
-"
-" " Make sure you use single quotes
-"
-" " Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
-" Plug 'junegunn/vim-easy-align'
-"
-" " Any valid git URL is allowed
-" Plug 'https://github.com/junegunn/vim-github-dashboard.git'
-"
-" " Multiple Plug commands can be written in a single line using | separators
-" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
-"
-" " On-demand loading
-" Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
-" Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
-"
-" " Using a non-default 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' }
-"
-" " Plugin outside ~/.vim/plugged with post-update hook
-" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
-"
-" " Unmanaged plugin (manually installed and updated)
-" Plug '~/my-prototype-plugin'
-"
-" " Initialize plugin system
-" call plug#end()
-"
-" Then reload .vimrc and :PlugInstall to install plugins.
-"
-" Plug options:
-"
-"| Option | Description |
-"| ----------------------- | ------------------------------------------------ |
-"| `branch`/`tag`/`commit` | Branch/tag/commit of the repository to use |
-"| `rtp` | Subdirectory that contains Vim plugin |
-"| `dir` | Custom directory for the plugin |
-"| `as` | Use different name for the plugin |
-"| `do` | Post-update hook (string or funcref) |
-"| `on` | On-demand loading: Commands or ``-mappings |
-"| `for` | On-demand loading: File types |
-"| `frozen` | Do not update unless explicitly specified |
-"
-" More information: https://github.com/junegunn/vim-plug
-"
-"
-" Copyright (c) 2017 Junegunn Choi
-"
-" MIT License
-"
-" Permission is hereby granted, free of charge, to any person obtaining
-" a copy of this software and associated documentation files (the
-" "Software"), to deal in the Software without restriction, including
-" without limitation the rights to use, copy, modify, merge, publish,
-" distribute, sublicense, and/or sell copies of the Software, and to
-" permit persons to whom the Software is furnished to do so, subject to
-" the following conditions:
-"
-" The above copyright notice and this permission notice shall be
-" included in all copies or substantial portions of the Software.
-"
-" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-if exists('g:loaded_plug')
- finish
-endif
-let g:loaded_plug = 1
-
-let s:cpo_save = &cpo
-set cpo&vim
-
-let s:plug_src = 'https://github.com/junegunn/vim-plug.git'
-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')
-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')
-if s:is_win && &shellslash
- set noshellslash
- let s:me = resolve(expand(':p'))
- set shellslash
-else
- let s:me = resolve(expand(':p'))
-endif
-let s:base_spec = { 'branch': '', 'frozen': 0 }
-let s:TYPE = {
-\ 'string': type(''),
-\ 'list': type([]),
-\ 'dict': type({}),
-\ 'funcref': type(function('call'))
-\ }
-let s:loaded = get(s:, 'loaded', {})
-let s:triggers = get(s:, 'triggers', {})
-
-function! s:is_powershell(shell)
- return a:shell =~# 'powershell\(\.exe\)\?$' || a:shell =~# 'pwsh\(\.exe\)\?$'
-endfunction
-
-function! s:isabsolute(dir) abort
- return a:dir =~# '^/' || (has('win32') && a:dir =~? '^\%(\\\|[A-Z]:\)')
-endfunction
-
-function! s:git_dir(dir) abort
- let gitdir = s:trim(a:dir) . '/.git'
- if isdirectory(gitdir)
- return gitdir
- endif
- if !filereadable(gitdir)
- return ''
- endif
- let gitdir = matchstr(get(readfile(gitdir), 0, ''), '^gitdir: \zs.*')
- if len(gitdir) && !s:isabsolute(gitdir)
- let gitdir = a:dir . '/' . gitdir
- endif
- return isdirectory(gitdir) ? gitdir : ''
-endfunction
-
-function! s:git_origin_url(dir) abort
- let gitdir = s:git_dir(a:dir)
- let config = gitdir . '/config'
- if empty(gitdir) || !filereadable(config)
- return ''
- endif
- return matchstr(join(readfile(config)), '\[remote "origin"\].\{-}url\s*=\s*\zs\S*\ze')
-endfunction
-
-function! s:git_revision(dir) abort
- let gitdir = s:git_dir(a:dir)
- let head = gitdir . '/HEAD'
- if empty(gitdir) || !filereadable(head)
- return ''
- endif
-
- let line = get(readfile(head), 0, '')
- let ref = matchstr(line, '^ref: \zs.*')
- if empty(ref)
- return line
- endif
-
- if filereadable(gitdir . '/' . ref)
- return get(readfile(gitdir . '/' . ref), 0, '')
- endif
-
- if filereadable(gitdir . '/packed-refs')
- for line in readfile(gitdir . '/packed-refs')
- if line =~# ' ' . ref
- return matchstr(line, '^[0-9a-f]*')
- endif
- endfor
- endif
-
- return ''
-endfunction
-
-function! s:git_local_branch(dir) abort
- let gitdir = s:git_dir(a:dir)
- let head = gitdir . '/HEAD'
- if empty(gitdir) || !filereadable(head)
- return ''
- endif
- let branch = matchstr(get(readfile(head), 0, ''), '^ref: refs/heads/\zs.*')
- return len(branch) ? branch : 'HEAD'
-endfunction
-
-function! s:git_origin_branch(spec)
- if len(a:spec.branch)
- return a:spec.branch
- endif
-
- " The file may not be present if this is a local repository
- let gitdir = s:git_dir(a:spec.dir)
- let origin_head = gitdir.'/refs/remotes/origin/HEAD'
- if len(gitdir) && filereadable(origin_head)
- return matchstr(get(readfile(origin_head), 0, ''),
- \ '^ref: refs/remotes/origin/\zs.*')
- endif
-
- " The command may not return the name of a branch in detached HEAD state
- let result = s:lines(s:system('git symbolic-ref --short HEAD', a:spec.dir))
- return v:shell_error ? '' : result[-1]
-endfunction
-
-if s:is_win
- function! s:plug_call(fn, ...)
- let shellslash = &shellslash
- try
- set noshellslash
- return call(a:fn, a:000)
- finally
- let &shellslash = shellslash
- endtry
- endfunction
-else
- function! s:plug_call(fn, ...)
- return call(a:fn, a:000)
- endfunction
-endif
-
-function! s:plug_getcwd()
- return s:plug_call('getcwd')
-endfunction
-
-function! s:plug_fnamemodify(fname, mods)
- return s:plug_call('fnamemodify', a:fname, a:mods)
-endfunction
-
-function! s:plug_expand(fmt)
- return s:plug_call('expand', a:fmt, 1)
-endfunction
-
-function! s:plug_tempname()
- return s:plug_call('tempname')
-endfunction
-
-function! plug#begin(...)
- if a:0 > 0
- let s:plug_home_org = a:1
- let home = s:path(s:plug_fnamemodify(s:plug_expand(a:1), ':p'))
- elseif exists('g:plug_home')
- let home = s:path(g:plug_home)
- elseif !empty(&rtp)
- let home = s:path(split(&rtp, ',')[0]) . '/plugged'
- else
- return s:err('Unable to determine plug home. Try calling plug#begin() with a path argument.')
- endif
- if s:plug_fnamemodify(home, ':t') ==# 'plugin' && s:plug_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 = {}
- let g:plugs_order = []
- let s:triggers = {}
-
- call s:define_commands()
- return 1
-endfunction
-
-function! s:define_commands()
- 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
- if has('win32')
- \ && &shellslash
- \ && (&shell =~# 'cmd\(\.exe\)\?$' || s:is_powershell(&shell))
- return s:err('vim-plug does not support shell, ' . &shell . ', when shellslash is set.')
- endif
- if !has('nvim')
- \ && (has('win32') || has('win32unix'))
- \ && !has('multi_byte')
- return s:err('Vim needs +multi_byte feature on Windows to run shell commands. Enable +iconv for best results.')
- endif
- command! -nargs=* -bar -bang -complete=customlist,s:names PlugInstall call s:install(0, [])
- command! -nargs=* -bar -bang -complete=customlist,s:names PlugUpdate call s:update(0, [])
- command! -nargs=0 -bar -bang PlugClean call s:clean(0)
- command! -nargs=0 -bar PlugUpgrade if s:upgrade() | execute 'source' s:esc(s:me) | endif
- command! -nargs=0 -bar PlugStatus call s:status()
- command! -nargs=0 -bar PlugDiff call s:diff()
- command! -nargs=? -bar -bang -complete=file PlugSnapshot call s:snapshot(0, )
-endfunction
-
-function! s:to_a(v)
- return type(a:v) == s:TYPE.list ? a:v : [a:v]
-endfunction
-
-function! s:to_s(v)
- return type(a:v) == s:TYPE.string ? a:v : join(a:v, "\n") . "\n"
-endfunction
-
-function! s:glob(from, pattern)
- return s:lines(globpath(a:from, a:pattern))
-endfunction
-
-function! s:source(from, ...)
- let found = 0
- for pattern in a:000
- for vim in s:glob(a:from, pattern)
- execute 'source' s:esc(vim)
- let found = 1
- endfor
- endfor
- return found
-endfunction
-
-function! s:assoc(dict, key, val)
- let a:dict[a:key] = add(get(a:dict, a:key, []), a:val)
-endfunction
-
-function! s:ask(message, ...)
- call inputsave()
- echohl WarningMsg
- let answer = input(a:message.(a:0 ? ' (y/N/a) ' : ' (y/N) '))
- echohl None
- call inputrestore()
- echo "\r"
- 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! s:lazy(plug, opt)
- return has_key(a:plug, a:opt) &&
- \ (empty(s:to_a(a:plug[a:opt])) ||
- \ !isdirectory(a:plug.dir) ||
- \ len(s:glob(s:rtp(a:plug), 'plugin')) ||
- \ len(s:glob(s:rtp(a:plug), 'after/plugin')))
-endfunction
-
-function! plug#end()
- if !exists('g:plugs')
- return s:err('plug#end() called without calling plug#begin() first')
- endif
-
- if exists('#PlugLOD')
- augroup PlugLOD
- autocmd!
- augroup END
- augroup! PlugLOD
- endif
- let lod = { 'ft': {}, 'map': {}, 'cmd': {} }
-
- 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) || !s:lazy(plug, 'on') && !s:lazy(plug, 'for')
- let s:loaded[name] = 1
- continue
- endif
-
- if has_key(plug, 'on')
- let s:triggers[name] = { 'map': [], 'cmd': [] }
- for cmd in s:to_a(plug.on)
- if cmd =~? '^.\+'
- if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i'))
- call s:assoc(lod.map, cmd, name)
- 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
- call add(s:triggers[name].cmd, cmd)
- else
- call s:err('Invalid `on` option: '.cmd.
- \ '. Should start with an uppercase letter or ``.')
- endif
- endfor
- endif
-
- 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)
- endfor
- endif
- endfor
-
- for [cmd, names] in items(lod.cmd)
- execute printf(
- \ 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "", , , , %s)',
- \ cmd, string(cmd), string(names))
- endfor
-
- for [map, names] in items(lod.map)
- for [mode, map_prefix, key_prefix] in
- \ [['i', '', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']]
- execute printf(
- \ '%snoremap %s %s:call lod_map(%s, %s, %s, "%s")',
- \ mode, map, map_prefix, string(map), string(names), mode != 'i', key_prefix)
- endfor
- endfor
-
- for [ft, names] in items(lod.ft)
- augroup PlugLOD
- execute printf('autocmd FileType %s call lod_ft(%s, %s)',
- \ ft, string(ft), string(names))
- augroup END
- endfor
-
- call s:reorg_rtp()
- filetype plugin indent on
- if has('vim_starting')
- if has('syntax') && !exists('g:syntax_on')
- syntax enable
- end
- else
- call s:reload_plugins()
- endif
-endfunction
-
-function! s:loaded_names()
- return filter(copy(g:plugs_order), 'get(s:loaded, v:val, 0)')
-endfunction
-
-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:load_plugin(g:plugs[name])
- endfor
-endfunction
-
-function! s:trim(str)
- return substitute(a:str, '[\/]\+$', '', '')
-endfunction
-
-function! s:version_requirement(val, min)
- for idx in range(0, len(a:min) - 1)
- let v = get(a:val, idx, 0)
- if v < a:min[idx] | return 0
- elseif v > a:min[idx] | return 1
- endif
- endfor
- return 1
-endfunction
-
-function! s:git_version_requirement(...)
- if !exists('s:git_version')
- 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
-
-function! s:progress_opt(base)
- return a:base && !s:is_win &&
- \ s:git_version_requirement(1, 7, 1) ? '--progress' : ''
-endfunction
-
-function! s:rtp(spec)
- return s:path(a:spec.dir . get(a:spec, 'rtp', ''))
-endfunction
-
-if s:is_win
- function! s:path(path)
- return s:trim(substitute(a:path, '/', '\', 'g'))
- endfunction
-
- function! s:dirpath(path)
- return s:path(a:path) . '\'
- endfunction
-
- function! s:is_local_plug(repo)
- return a:repo =~? '^[a-z]:\|^[%~]'
- endfunction
-
- " Copied from fzf
- function! s:wrap_cmds(cmds)
- let cmds = [
- \ '@echo off',
- \ 'setlocal enabledelayedexpansion']
- \ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds])
- \ + ['endlocal']
- if has('iconv')
- if !exists('s:codepage')
- let s:codepage = libcallnr('kernel32.dll', 'GetACP', 0)
- endif
- return map(cmds, printf('iconv(v:val."\r", "%s", "cp%d")', &encoding, s:codepage))
- endif
- return map(cmds, 'v:val."\r"')
- endfunction
-
- function! s:batchfile(cmd)
- let batchfile = s:plug_tempname().'.bat'
- call writefile(s:wrap_cmds(a:cmd), batchfile)
- let cmd = plug#shellescape(batchfile, {'shell': &shell, 'script': 0})
- if s:is_powershell(&shell)
- let cmd = '& ' . cmd
- endif
- return [batchfile, cmd]
- endfunction
-else
- function! s:path(path)
- return s:trim(a:path)
- endfunction
-
- function! s:dirpath(path)
- return substitute(a:path, '[/\\]*$', '/', '')
- endfunction
-
- function! s:is_local_plug(repo)
- return a:repo[0] =~ '[/$~]'
- endfunction
-endif
-
-function! s:err(msg)
- echohl ErrorMsg
- echom '[vim-plug] '.a:msg
- echohl None
-endfunction
-
-function! s:warn(cmd, msg)
- echohl WarningMsg
- execute a:cmd 'a:msg'
- echohl None
-endfunction
-
-function! s:esc(path)
- return escape(a:path, ' ')
-endfunction
-
-function! s:escrtp(path)
- return escape(a:path, ' ,')
-endfunction
-
-function! s:remove_rtp()
- for name in s:loaded_names()
- let rtp = s:rtp(g:plugs[name])
- execute 'set rtp-='.s:escrtp(rtp)
- let after = globpath(rtp, 'after')
- if isdirectory(after)
- execute 'set rtp-='.s:escrtp(after)
- endif
- endfor
-endfunction
-
-function! s:reorg_rtp()
- if !empty(s:first_rtp)
- execute 'set rtp-='.s:first_rtp
- execute 'set rtp-='.s:last_rtp
- endif
-
- " &rtp is modified from outside
- if exists('s:prtp') && s:prtp !=# &rtp
- call s:remove_rtp()
- unlet! s:middle
- endif
-
- 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")'), '!empty(v:val)')
- let rtp = join(map(rtps, 'escape(v:val, ",")'), ',')
- \ . ','.s:middle.','
- \ . join(map(afters, 'escape(v:val, ",")'), ',')
- let &rtp = substitute(substitute(rtp, ',,*', ',', 'g'), '^,\|,$', '', 'g')
- let s:prtp = &rtp
-
- if !empty(s:first_rtp)
- execute 'set rtp^='.s:first_rtp
- execute 'set rtp+='.s:last_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', 'after/ftdetect', 'after/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')
- endif
- if !exists('g:plugs')
- return s:err('plug#begin was not called')
- endif
- 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
- 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)
- if !has_key(s:triggers, a:name)
- return
- endif
- for cmd in s:triggers[a:name].cmd
- execute 'silent! delc' cmd
- endfor
- for map in s:triggers[a:name].map
- execute 'silent! unmap' map
- execute 'silent! iunmap' map
- endfor
- call remove(s:triggers, a:name)
-endfunction
-
-function! s:lod(names, types, ...)
- for name in a:names
- call s:remove_triggers(name)
- let s:loaded[name] = 1
- endfor
- call s:reorg_rtp()
-
- for name in a:names
- let rtp = s:rtp(g:plugs[name])
- for dir in a:types
- call s:source(rtp, dir.'/**/*.vim')
- endfor
- if a:0
- if !s:source(rtp, a:1) && !empty(s:glob(rtp, a:2))
- execute 'runtime' a:1
- endif
- call s:source(rtp, a:2)
- endif
- call s:doautocmd('User', name)
- endfor
-endfunction
-
-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
- 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, 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)
- if c == 0
- break
- endif
- let extra .= nr2char(c)
- endwhile
-
- 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, ...)
- if a:0 > 1
- return s:err('Invalid number of arguments (1..2)')
- endif
-
- try
- let repo = s:trim(a:repo)
- let opts = a:0 == 1 ? s:parse_options(a:1) : s:base_spec
- let name = get(opts, 'as', s:plug_fnamemodify(repo, ':t:s?\.git$??'))
- let spec = extend(s:infer_properties(name, repo), opts)
- if !has_key(g:plugs, name)
- call add(g:plugs_order, name)
- endif
- let g:plugs[name] = spec
- let s:loaded[name] = get(s:loaded, name, 0)
- catch
- return s:err(repo . ' ' . v:exception)
- endtry
-endfunction
-
-function! s:parse_options(arg)
- let opts = copy(s:base_spec)
- let type = type(a:arg)
- let opt_errfmt = 'Invalid argument for "%s" option of :Plug (expected: %s)'
- if type == s:TYPE.string
- if empty(a:arg)
- throw printf(opt_errfmt, 'tag', 'string')
- endif
- let opts.tag = a:arg
- elseif type == s:TYPE.dict
- for opt in ['branch', 'tag', 'commit', 'rtp', 'dir', 'as']
- if has_key(a:arg, opt)
- \ && (type(a:arg[opt]) != s:TYPE.string || empty(a:arg[opt]))
- throw printf(opt_errfmt, opt, 'string')
- endif
- endfor
- for opt in ['on', 'for']
- if has_key(a:arg, opt)
- \ && type(a:arg[opt]) != s:TYPE.list
- \ && (type(a:arg[opt]) != s:TYPE.string || empty(a:arg[opt]))
- throw printf(opt_errfmt, opt, 'string or list')
- endif
- endfor
- if has_key(a:arg, 'do')
- \ && type(a:arg.do) != s:TYPE.funcref
- \ && (type(a:arg.do) != s:TYPE.string || empty(a:arg.do))
- throw printf(opt_errfmt, 'do', 'string or funcref')
- endif
- call extend(opts, a:arg)
- if has_key(opts, 'dir')
- let opts.dir = s:dirpath(s:plug_expand(opts.dir))
- endif
- else
- throw 'Invalid argument type (expected: string or dictionary)'
- endif
- return opts
-endfunction
-
-function! s:infer_properties(name, repo)
- let repo = a:repo
- if s:is_local_plug(repo)
- return { 'dir': s:dirpath(s:plug_expand(repo)) }
- else
- if repo =~ ':'
- let uri = repo
- else
- if 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
- return { 'dir': s:dirpath(g:plug_home.'/'.a:name), 'uri': uri }
- endif
-endfunction
-
-function! s:install(force, names)
- call s:update_impl(0, a:force, a:names)
-endfunction
-
-function! s:update(force, names)
- call s:update_impl(1, a:force, a:names)
-endfunction
-
-function! plug#helptags()
- if !exists('g:plugs')
- return s:err('plug#begin was not called')
- endif
- for spec in values(g:plugs)
- let docd = join([s:rtp(spec), 'doc'], '/')
- if isdirectory(docd)
- silent! execute 'helptags' s:esc(docd)
- endif
- endfor
- return 1
-endfunction
-
-function! s:syntax()
- syntax clear
- syntax region plug1 start=/\%1l/ end=/\%2l/ contains=plugNumber
- syntax region plug2 start=/\%2l/ end=/\%3l/ contains=plugBracket,plugX
- syn match plugNumber /[0-9]\+[0-9.]*/ contained
- syn match plugBracket /[[\]]/ contained
- syn match plugX /x/ contained
- syn match plugDash /^-\{1}\ /
- syn match plugPlus /^+/
- syn match plugStar /^*/
- syn match plugMessage /\(^- \)\@<=.*/
- syn match plugName /\(^- \)\@<=[^ ]*:/
- syn match plugSha /\%(: \)\@<=[0-9a-f]\{4,}$/
- syn match plugTag /(tag: [^)]\+)/
- syn match plugInstall /\(^+ \)\@<=[^:]*/
- syn match plugUpdate /\(^* \)\@<=[^:]*/
- 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,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 match plugH2 /^-\{2,}/
- syn keyword Function PlugInstall PlugStatus PlugUpdate PlugClean
- hi def link plug1 Title
- hi def link plug2 Repeat
- hi def link plugH2 Type
- hi def link plugX Exception
- hi def link plugBracket Structure
- hi def link plugNumber Number
-
- hi def link plugDash Special
- hi def link plugPlus Constant
- hi def link plugStar Boolean
-
- hi def link plugMessage Function
- hi def link plugName Label
- hi def link plugInstall Function
- 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
- hi def link plugTag Constant
-
- hi def link plugNotLoaded Comment
-endfunction
-
-function! s:lpad(str, len)
- return a:str . repeat(' ', a:len - len(a:str))
-endfunction
-
-function! s:lines(msg)
- return split(a:msg, "[\r\n]")
-endfunction
-
-function! s:lastline(msg)
- return get(s:lines(a:msg), -1, '')
-endfunction
-
-function! s:new_window()
- execute get(g:, 'plug_window', 'vertical topleft new')
-endfunction
-
-function! s:plug_window_exists()
- let buflist = tabpagebuflist(s:plug_tab)
- return !empty(buflist) && index(buflist, s:plug_buf) >= 0
-endfunction
-
-function! s:switch_in()
- if !s:plug_window_exists()
- return 0
- endif
-
- if winbufnr(0) != s:plug_buf
- let s:pos = [tabpagenr(), winnr(), winsaveview()]
- execute 'normal!' s:plug_tab.'gt'
- let winnr = bufwinnr(s:plug_buf)
- execute winnr.'wincmd w'
- call add(s:pos, winsaveview())
- else
- let s:pos = [winsaveview()]
- endif
-
- setlocal modifiable
- return 1
-endfunction
-
-function! s:switch_out(...)
- call winrestview(s:pos[-1])
- setlocal nomodifiable
- if a:0 > 0
- execute a:1
- endif
-
- if len(s:pos) > 1
- execute 'normal!' s:pos[0].'gt'
- execute s:pos[1] 'wincmd w'
- call winrestview(s:pos[2])
- endif
-endfunction
-
-function! s:finish_bindings()
- nnoremap R :call retry()
- nnoremap D :PlugDiff
- nnoremap S :PlugStatus
- nnoremap U :call status_update()
- xnoremap U :call status_update()
- nnoremap ]] :silent! call section('')
- nnoremap [[ :silent! call section('b')
-endfunction
-
-function! s:prepare(...)
- if empty(s:plug_getcwd())
- 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()
- if b:plug_preview == 1
- pc
- endif
- enew
- else
- call s:new_window()
- endif
-
- nnoremap q :call close_pane()
- if a:0 == 0
- call s:finish_bindings()
- endif
- let b:plug_preview = -1
- let s:plug_tab = tabpagenr()
- let s:plug_buf = winbufnr(0)
- call s:assign_name()
-
- 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
- if exists('+colorcolumn')
- setlocal colorcolumn=
- endif
- setf vim-plug
- if exists('g:syntax_on')
- call s:syntax()
- endif
-endfunction
-
-function! s:close_pane()
- if b:plug_preview == 1
- pc
- let b:plug_preview = -1
- else
- bd
- endif
-endfunction
-
-function! s:assign_name()
- " Assign buffer name
- let prefix = '[Plugins]'
- let name = prefix
- let idx = 2
- while bufexists(name)
- let name = printf('%s (%s)', prefix, idx)
- let idx = idx + 1
- endwhile
- silent! execute 'f' fnameescape(name)
-endfunction
-
-function! s:chsh(swap)
- let prev = [&shell, &shellcmdflag, &shellredir]
- if !s:is_win
- set shell=sh
- endif
- if a:swap
- if s:is_powershell(&shell)
- let &shellredir = '2>&1 | Out-File -Encoding UTF8 %s'
- elseif &shell =~# 'sh' || &shell =~# 'cmd\(\.exe\)\?$'
- set shellredir=>%s\ 2>&1
- endif
- endif
- return prev
-endfunction
-
-function! s:bang(cmd, ...)
- let batchfile = ''
- try
- 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
- if s:is_win
- let [batchfile, cmd] = s:batchfile(cmd)
- 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, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
- if s:is_win && filereadable(batchfile)
- call delete(batchfile)
- endif
- 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)
- continue
- endif
- let installed = has_key(s:update.new, name)
- let updated = installed ? 0 :
- \ (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
- 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
- call s:load_plugin(spec)
- let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged')
- call spec.do({ 'name': name, 'status': status, 'force': a:force })
- catch
- let error = v:exception
- endtry
- 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
-endfunction
-
-function! s:hash_match(a, b)
- return stridx(a:a, a:b) == 0 || stridx(a:b, a:a) == 0
-endfunction
-
-function! s:checkout(spec)
- let sha = a:spec.commit
- let output = s:git_revision(a:spec.dir)
- if !empty(output) && !s:hash_match(sha, s:lines(output)[0])
- let credential_helper = s:git_version_requirement(2) ? '-c credential.helper= ' : ''
- let output = s:system(
- \ 'git '.credential_helper.'fetch --depth 999999 && git checkout '.plug#shellescape(sha).' --', a:spec.dir)
- endif
- return output
-endfunction
-
-function! s:finish(pull)
- let new_frozen = len(filter(keys(s:update.new), 'g:plugs[v:val].frozen'))
- if new_frozen
- let s = new_frozen > 1 ? 's' : ''
- call append(3, printf('- Installed %d frozen plugin%s', new_frozen, s))
- endif
- call append(3, '- Finishing ... ') | 4
- redraw
- call plug#helptags()
- call plug#end()
- call setline(4, getline(4) . 'Done!')
- redraw
- let msgs = []
- if !empty(s:update.errors)
- call add(msgs, "Press 'R' to retry.")
- endif
- if a:pull && len(s:update.new) < len(filter(getline(5, '$'),
- \ "v:val =~ '^- ' && v:val !~# 'Already up.to.date'"))
- call add(msgs, "Press 'D' to see the updated changes.")
- endif
- echo join(msgs, ' ')
- call s:finish_bindings()
-endfunction
-
-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
-
-function! s:is_managed(name)
- return has_key(g:plugs[a:name], 'uri')
-endfunction
-
-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 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)
-
- let managed = filter(copy(g:plugs), 's:is_managed(v:key)')
- let todo = empty(args) ? filter(managed, '!v:val.frozen || !isdirectory(v:val.dir)') :
- \ filter(managed, 'index(args, v:key) >= 0')
-
- if empty(todo)
- return s:warn('echo', 'No plugin to '. (a:pull ? 'update' : 'install'))
- endif
-
- if !s:is_win && s:git_version_requirement(2, 3)
- let s:git_terminal_prompt = exists('$GIT_TERMINAL_PROMPT') ? $GIT_TERMINAL_PROMPT : ''
- let $GIT_TERMINAL_PROMPT = 0
- for plug in values(todo)
- let plug.uri = substitute(plug.uri,
- \ '^https://git::@github\.com', 'https://github.com', '')
- endfor
- endif
-
- if !isdirectory(g:plug_home)
- try
- call mkdir(g:plug_home, 'p')
- catch
- return s:err(printf('Invalid plug directory: %s. '.
- \ 'Try to call plug#begin with a valid directory', g:plug_home))
- endtry
- endif
-
- if has('nvim') && !exists('*jobwait') && threads > 1
- call s:warn('echom', '[vim-plug] Update Neovim for parallel installer')
- endif
-
- 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(),
- \ 'all': todo,
- \ 'todo': copy(todo),
- \ 'errors': [],
- \ 'pull': a:pull,
- \ 'force': a:force,
- \ 'new': {},
- \ 'threads': (python || ruby || use_job) ? min([len(todo), threads]) : 1,
- \ 'bar': '',
- \ 'fin': 0
- \ }
-
- call s:prepare(1)
- call append(0, ['', ''])
- normal! 2G
- silent! redraw
-
- " Set remote name, overriding a possible user git config's clone.defaultRemoteName
- let s:clone_opt = ['--origin', 'origin']
- if get(g:, 'plug_shallow', 1)
- call extend(s:clone_opt, ['--depth', '1'])
- if s:git_version_requirement(1, 7, 10)
- call add(s:clone_opt, '--no-single-branch')
- endif
- endif
-
- if has('win32unix') || has('wsl')
- call extend(s:clone_opt, ['-c', 'core.eol=lf', '-c', 'core.autocrlf=input'])
- endif
-
- let s:submodule_opt = s:git_version_requirement(2, 8) ? ' --jobs='.threads : ''
-
- " Python version requirement (>= 2.7)
- if python && !has('python3') && !ruby && !use_job && s:update.threads > 1
- redir => pyv
- silent python import platform; print platform.python_version()
- redir END
- let python = s:version_requirement(
- \ map(split(split(pyv)[0], '\.'), 'str2nr(v:val)'), [2, 6])
- endif
-
- if (python || ruby) && s:update.threads > 1
- try
- let imd = &imd
- if s:mac_gui
- set noimd
- endif
- if ruby
- call s:update_ruby()
- else
- call s:update_python()
- endif
- catch
- let lines = getline(4, '$')
- let printed = {}
- silent! 4,$d _
- for line in lines
- let name = s:extract_name(line, '.', '')
- if empty(name) || !has_key(printed, name)
- call append('$', line)
- if !empty(name)
- let printed[name] = 1
- if line[0] == 'x' && index(s:update.errors, name) < 0
- call add(s:update.errors, name)
- end
- endif
- endif
- endfor
- finally
- let &imd = imd
- call s:update_finish()
- 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 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 '.plug#shellescape(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 '.plug#shellescape(tag).' -- 2>&1', spec.dir)
- else
- let branch = s:git_origin_branch(spec)
- call s:log4(name, 'Merging origin/'.s:esc(branch))
- let out = s:system('git checkout -q '.plug#shellescape(branch).' -- 2>&1'
- \. (has_key(s:update.new, name) ? '' : ('&& git merge --ff-only '.plug#shellescape('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'.s:submodule_opt.' 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')
- endif
-endfunction
-
-function! s:job_abort()
- if (!s:nvim && !s:vim8) || !exists('s:jobs')
- return
- endif
-
- for [name, j] in items(s:jobs)
- if s:nvim
- silent! call jobstop(j.jobid)
- elseif s:vim8
- silent! call job_stop(j.jobid)
- endif
- if j.new
- call s:rm_rf(g:plugs[name].dir)
- endif
- endfor
- let s:jobs = {}
-endfunction
-
-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
-
-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' || a:event == 'stderr') ?
- \ 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': [''],
- \ 'new': get(a:opts, 'new', 0) }
- let s:jobs[a:name] = job
-
- if s:nvim
- if has_key(a:opts, 'dir')
- let job.cwd = a:opts.dir
- endif
- let argv = a:cmd
- call extend(job, {
- \ 'on_stdout': function('s:nvim_cb'),
- \ 'on_stderr': function('s:nvim_cb'),
- \ 'on_exit': function('s:nvim_cb'),
- \ })
- let jid = s:plug_call('jobstart', argv, job)
- if jid > 0
- let job.jobid = jid
- else
- let job.running = 0
- let job.error = 1
- let job.lines = [jid < 0 ? argv[0].' is not executable' :
- \ 'Invalid arguments (or job table is full)']
- endif
- elseif s:vim8
- let cmd = join(map(copy(a:cmd), 'plug#shellescape(v:val, {"script": 0})'))
- if has_key(a:opts, 'dir')
- let cmd = s:with_cd(cmd, a:opts.dir, 0)
- endif
- let argv = s:is_win ? ['cmd', '/s', '/c', '"'.cmd.'"'] : ['sh', '-c', cmd]
- let jid = job_start(s:is_win ? join(argv, ' ') : argv, {
- \ 'out_cb': function('s:job_cb', ['s:job_out_cb', job]),
- \ 'err_cb': function('s:job_cb', ['s:job_out_cb', job]),
- \ 'exit_cb': function('s:job_cb', ['s:job_exit_cb', job]),
- \ 'err_mode': 'raw',
- \ '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 job.lines = s:lines(call('s:system', has_key(a:opts, 'dir') ? [a:cmd, a:opts.dir] : [a:cmd]))
- let job.error = v:shell_error != 0
- let job.running = 0
- endif
-endfunction
-
-function! s:reap(name)
- let job = s:jobs[a:name]
- if job.error
- call add(s:update.errors, a:name)
- elseif get(job, 'new', 0)
- let s:update.new[a:name] = 1
- endif
- let s:update.bar .= job.error ? 'x' : '='
-
- 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)
-endfunction
-
-function! s:bar()
- if s:switch_in()
- let total = len(s:update.all)
- call setline(1, (s:update.pull ? 'Updating' : 'Installing').
- \ ' plugins ('.len(s:update.bar).'/'.total.')')
- call s:progress_bar(2, s:update.bar, total)
- call s:switch_out()
- endif
-endfunction
-
-function! s:logpos(name)
- let max = line('$')
- for i in range(4, max > 4 ? max : 4)
- if getline(i) =~# '^[-+x*] '.a:name.':'
- for j in range(i + 1, max > 5 ? max : 5)
- 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 [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 b = 4
- endif
- " 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
-
-function! s:update_vim()
- let s:jobs = {}
-
- call s:bar()
- call s:tick()
-endfunction
-
-function! s:tick()
- let pull = s:update.pull
- 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
- call s:update_finish()
- let s:update.fin = 1
- endif
- return
- endif
-
- let name = keys(s:update.todo)[0]
- let spec = remove(s:update.todo, name)
- let new = empty(globpath(spec.dir, '.git', 1))
-
- call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...')
- redraw
-
- let has_tag = has_key(spec, 'tag')
- if !new
- let [error, _] = s:git_validate(spec, 0)
- if empty(error)
- if pull
- let cmd = s:git_version_requirement(2) ? ['git', '-c', 'credential.helper=', 'fetch'] : ['git', 'fetch']
- if has_tag && !empty(globpath(spec.dir, '.git/shallow'))
- call extend(cmd, ['--depth', '99999999'])
- endif
- if !empty(prog)
- call add(cmd, prog)
- endif
- call s:spawn(name, cmd, { 'dir': spec.dir })
- else
- let s:jobs[name] = { 'running': 0, 'lines': ['Already installed'], 'error': 0 }
- endif
- else
- let s:jobs[name] = { 'running': 0, 'lines': s:lines(error), 'error': 1 }
- endif
- else
- let cmd = ['git', 'clone']
- if !has_tag
- call extend(cmd, s:clone_opt)
- endif
- if !empty(prog)
- call add(cmd, prog)
- endif
- call s:spawn(name, extend(cmd, [spec.uri, s:trim(spec.dir)]), { 'new': 1 })
- endif
-
- if !s:jobs[name].running
- call s:reap(name)
- endif
- if len(s:jobs) >= s:update.threads
- break
- endif
-endwhile
-endfunction
-
-function! s:update_python()
-let py_exe = has('python') ? 'python' : 'python3'
-execute py_exe "<< EOF"
-import datetime
-import functools
-import os
-try:
- import queue
-except ImportError:
- import Queue as queue
-import random
-import re
-import shutil
-import signal
-import subprocess
-import tempfile
-import threading as thr
-import time
-import traceback
-import vim
-
-G_NVIM = vim.eval("has('nvim')") == '1'
-G_PULL = vim.eval('s:update.pull') == '1'
-G_RETRIES = int(vim.eval('get(g:, "plug_retries", 2)')) + 1
-G_TIMEOUT = int(vim.eval('get(g:, "plug_timeout", 60)'))
-G_CLONE_OPT = ' '.join(vim.eval('s:clone_opt'))
-G_PROGRESS = vim.eval('s:progress_opt(1)')
-G_LOG_PROB = 1.0 / int(vim.eval('s:update.threads'))
-G_STOP = thr.Event()
-G_IS_WIN = vim.eval('s:is_win') == '1'
-
-class PlugError(Exception):
- def __init__(self, msg):
- self.msg = msg
-class CmdTimedOut(PlugError):
- pass
-class CmdFailed(PlugError):
- pass
-class InvalidURI(PlugError):
- pass
-class Action(object):
- INSTALL, UPDATE, ERROR, DONE = ['+', '*', 'x', '-']
-
-class Buffer(object):
- def __init__(self, lock, num_plugs, is_pull):
- self.bar = ''
- self.event = 'Updating' if is_pull else 'Installing'
- self.lock = lock
- self.maxy = int(vim.eval('winheight(".")'))
- self.num_plugs = num_plugs
-
- def __where(self, name):
- """ Find first line with name in current buffer. Return line num. """
- found, lnum = False, 0
- matcher = re.compile('^[-+x*] {0}:'.format(name))
- for line in vim.current.buffer:
- if matcher.search(line) is not None:
- found = True
- break
- lnum += 1
-
- if not found:
- lnum = -1
- return lnum
-
- def header(self):
- curbuf = vim.current.buffer
- curbuf[0] = self.event + ' plugins ({0}/{1})'.format(len(self.bar), self.num_plugs)
-
- num_spaces = self.num_plugs - len(self.bar)
- curbuf[1] = '[{0}{1}]'.format(self.bar, num_spaces * ' ')
-
- with self.lock:
- vim.command('normal! 2G')
- vim.command('redraw')
-
- def write(self, action, name, lines):
- first, rest = lines[0], lines[1:]
- msg = ['{0} {1}{2}{3}'.format(action, name, ': ' if first else '', first)]
- msg.extend([' ' + line for line in rest])
-
- try:
- if action == Action.ERROR:
- self.bar += 'x'
- vim.command("call add(s:update.errors, '{0}')".format(name))
- elif action == Action.DONE:
- self.bar += '='
-
- curbuf = vim.current.buffer
- lnum = self.__where(name)
- if lnum != -1: # Found matching line num
- del curbuf[lnum]
- if lnum > self.maxy and action in set([Action.INSTALL, Action.UPDATE]):
- lnum = 3
- else:
- lnum = 3
- curbuf.append(msg, lnum)
-
- self.header()
- except vim.error:
- pass
-
-class Command(object):
- CD = 'cd /d' if G_IS_WIN else 'cd'
-
- def __init__(self, cmd, cmd_dir=None, timeout=60, cb=None, clean=None):
- self.cmd = cmd
- if cmd_dir:
- self.cmd = '{0} {1} && {2}'.format(Command.CD, cmd_dir, self.cmd)
- self.timeout = timeout
- self.callback = cb if cb else (lambda msg: None)
- self.clean = clean if clean else (lambda: None)
- self.proc = None
-
- @property
- def alive(self):
- """ Returns true only if command still running. """
- return self.proc and self.proc.poll() is None
-
- def execute(self, ntries=3):
- """ Execute the command with ntries if CmdTimedOut.
- Returns the output of the command if no Exception.
- """
- attempt, finished, limit = 0, False, self.timeout
-
- while not finished:
- try:
- attempt += 1
- result = self.try_command()
- finished = True
- return result
- except CmdTimedOut:
- if attempt != ntries:
- self.notify_retry()
- self.timeout += limit
- else:
- raise
-
- def notify_retry(self):
- """ Retry required for command, notify user. """
- for count in range(3, 0, -1):
- if G_STOP.is_set():
- raise KeyboardInterrupt
- msg = 'Timeout. Will retry in {0} second{1} ...'.format(
- count, 's' if count != 1 else '')
- self.callback([msg])
- time.sleep(1)
- self.callback(['Retrying ...'])
-
- def try_command(self):
- """ Execute a cmd & poll for callback. Returns list of output.
- Raises CmdFailed -> return code for Popen isn't 0
- Raises CmdTimedOut -> command exceeded timeout without new output
- """
- first_line = True
-
- try:
- tfile = tempfile.NamedTemporaryFile(mode='w+b')
- preexec_fn = not G_IS_WIN and os.setsid or None
- self.proc = subprocess.Popen(self.cmd, stdout=tfile,
- stderr=subprocess.STDOUT,
- stdin=subprocess.PIPE, shell=True,
- preexec_fn=preexec_fn)
- thrd = thr.Thread(target=(lambda proc: proc.wait()), args=(self.proc,))
- thrd.start()
-
- thread_not_started = True
- while thread_not_started:
- try:
- thrd.join(0.1)
- thread_not_started = False
- except RuntimeError:
- pass
-
- while self.alive:
- if G_STOP.is_set():
- raise KeyboardInterrupt
-
- if first_line or random.random() < G_LOG_PROB:
- first_line = False
- line = '' if G_IS_WIN else nonblock_read(tfile.name)
- if line:
- self.callback([line])
-
- time_diff = time.time() - os.path.getmtime(tfile.name)
- if time_diff > self.timeout:
- raise CmdTimedOut(['Timeout!'])
-
- thrd.join(0.5)
-
- tfile.seek(0)
- result = [line.decode('utf-8', 'replace').rstrip() for line in tfile]
-
- if self.proc.returncode != 0:
- raise CmdFailed([''] + result)
-
- return result
- except:
- self.terminate()
- raise
-
- def terminate(self):
- """ Terminate process and cleanup. """
- if self.alive:
- if G_IS_WIN:
- os.kill(self.proc.pid, signal.SIGINT)
- else:
- os.killpg(self.proc.pid, signal.SIGTERM)
- self.clean()
-
-class Plugin(object):
- def __init__(self, name, args, buf_q, lock):
- self.name = name
- self.args = args
- self.buf_q = buf_q
- self.lock = lock
- self.tag = args.get('tag', 0)
-
- def manage(self):
- try:
- if os.path.exists(self.args['dir']):
- self.update()
- else:
- self.install()
- with self.lock:
- thread_vim_command("let s:update.new['{0}'] = 1".format(self.name))
- except PlugError as exc:
- self.write(Action.ERROR, self.name, exc.msg)
- except KeyboardInterrupt:
- G_STOP.set()
- self.write(Action.ERROR, self.name, ['Interrupted!'])
- except:
- # Any exception except those above print stack trace
- msg = 'Trace:\n{0}'.format(traceback.format_exc().rstrip())
- self.write(Action.ERROR, self.name, msg.split('\n'))
- raise
-
- def install(self):
- target = self.args['dir']
- if target[-1] == '\\':
- target = target[0:-1]
-
- def clean(target):
- def _clean():
- try:
- shutil.rmtree(target)
- except OSError:
- pass
- return _clean
-
- self.write(Action.INSTALL, self.name, ['Installing ...'])
- callback = functools.partial(self.write, Action.INSTALL, self.name)
- cmd = 'git clone {0} {1} {2} {3} 2>&1'.format(
- '' if self.tag else G_CLONE_OPT, G_PROGRESS, self.args['uri'],
- 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 -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):
- 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),
- 'PlugClean required.']
- raise InvalidURI(msg)
-
- if G_PULL:
- 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 ''
- 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:])
- else:
- self.write(Action.DONE, self.name, ['Already installed'])
-
- def write(self, action, name, msg):
- self.buf_q.put((action, name, msg))
-
-class PlugThread(thr.Thread):
- def __init__(self, tname, args):
- super(PlugThread, self).__init__()
- self.tname = tname
- self.args = args
-
- def run(self):
- thr.current_thread().name = self.tname
- buf_q, work_q, lock = self.args
-
- try:
- while not G_STOP.is_set():
- name, args = work_q.get_nowait()
- plug = Plugin(name, args, buf_q, lock)
- plug.manage()
- work_q.task_done()
- except queue.Empty:
- pass
-
-class RefreshThread(thr.Thread):
- def __init__(self, lock):
- super(RefreshThread, self).__init__()
- self.lock = lock
- self.running = True
-
- def run(self):
- while self.running:
- with self.lock:
- thread_vim_command('noautocmd normal! a')
- time.sleep(0.33)
-
- def stop(self):
- self.running = False
-
-if G_NVIM:
- def thread_vim_command(cmd):
- vim.session.threadsafe_call(lambda: vim.command(cmd))
-else:
- def thread_vim_command(cmd):
- vim.command(cmd)
-
-def esc(name):
- return '"' + name.replace('"', '\"') + '"'
-
-def nonblock_read(fname):
- """ Read a file with nonblock flag. Return the last line. """
- fread = os.open(fname, os.O_RDONLY | os.O_NONBLOCK)
- buf = os.read(fread, 100000).decode('utf-8', 'replace')
- os.close(fread)
-
- line = buf.rstrip('\r\n')
- left = max(line.rfind('\r'), line.rfind('\n'))
- if left != -1:
- left += 1
- line = line[left:]
-
- return line
-
-def main():
- thr.current_thread().name = 'main'
- nthreads = int(vim.eval('s:update.threads'))
- plugs = vim.eval('s:update.todo')
- mac_gui = vim.eval('s:mac_gui') == '1'
-
- lock = thr.Lock()
- buf = Buffer(lock, len(plugs), G_PULL)
- buf_q, work_q = queue.Queue(), queue.Queue()
- for work in plugs.items():
- work_q.put(work)
-
- start_cnt = thr.active_count()
- for num in range(nthreads):
- tname = 'PlugT-{0:02}'.format(num)
- thread = PlugThread(tname, (buf_q, work_q, lock))
- thread.start()
- if mac_gui:
- rthread = RefreshThread(lock)
- rthread.start()
-
- 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, ['OK'] if not msg else msg)
- buf_q.task_done()
- except queue.Empty:
- pass
- except KeyboardInterrupt:
- G_STOP.set()
-
- if mac_gui:
- rthread.stop()
- rthread.join()
-
-main()
-EOF
-endfunction
-
-function! s:update_ruby()
- ruby << EOF
- module PlugStream
- SEP = ["\r", "\n", nil]
- def get_line
- buffer = ''
- loop do
- char = readchar rescue return
- if SEP.include? char.chr
- buffer << $/
- break
- else
- buffer << char
- end
- end
- buffer
- end
- end unless defined?(PlugStream)
-
- def esc arg
- %["#{arg.gsub('"', '\"')}"]
- end
-
- def killall pid
- pids = [pid]
- if /mswin|mingw|bccwin/ =~ RUBY_PLATFORM
- pids.each { |pid| Process.kill 'INT', pid.to_i rescue nil }
- else
- unless `which pgrep 2> /dev/null`.empty?
- children = pids
- until children.empty?
- children = children.map { |pid|
- `pgrep -P #{pid}`.lines.map { |l| l.chomp }
- }.flatten
- pids += children
- end
- end
- pids.each { |pid| Process.kill 'TERM', pid.to_i rescue nil }
- 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'
- running = true
- iswin = VIM::evaluate('s:is_win').to_i == 1
- pull = VIM::evaluate('s:update.pull').to_i == 1
- base = VIM::evaluate('g:plug_home')
- all = VIM::evaluate('s:update.todo')
- limit = VIM::evaluate('get(g:, "plug_timeout", 60)')
- 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 = ''
- skip = 'Already installed'
- mtx = Mutex.new
- take1 = proc { mtx.synchronize { running && all.shift } }
- logh = proc {
- cnt = bar.length
- $curbuf[1] = "#{pull ? 'Updating' : 'Installing'} plugins (#{cnt}/#{tot})"
- $curbuf[2] = '[' + bar.ljust(tot) + ']'
- VIM::command('normal! 2G')
- VIM::command('redraw')
- }
- where = proc { |name| (1..($curbuf.length)).find { |l| $curbuf[l] =~ /^[-+x*] #{name}:/ } }
- log = proc { |name, result, type|
- mtx.synchronize do
- ing = ![true, false].include?(type)
- bar += type ? '=' : 'x' unless ing
- b = case type
- when :install then '+' when :update then '*'
- when true, nil then '-' else
- VIM::command("call add(s:update.errors, '#{name}')")
- 'x'
- end
- result =
- if type || type.nil?
- ["#{b} #{name}: #{result.lines.to_a.last || 'OK'}"]
- elsif result =~ /^Interrupted|^Timeout/
- ["#{b} #{name}: #{result}"]
- else
- ["#{b} #{name}"] + result.lines.map { |l| " " << l }
- end
- if lnum = where.call(name)
- $curbuf.delete lnum
- lnum = 4 if ing && lnum > maxy
- end
- result.each_with_index do |line, offset|
- $curbuf.append((lnum || 4) - 1 + offset, line.gsub(/\e\[./, '').chomp)
- end
- logh.call
- end
- }
- bt = proc { |cmd, name, type, cleanup|
- tried = timeout = 0
- begin
- tried += 1
- timeout += limit
- fd = nil
- data = ''
- if iswin
- Timeout::timeout(timeout) do
- tmp = VIM::evaluate('tempname()')
- system("(#{cmd}) > #{tmp}")
- data = File.read(tmp).chomp
- File.unlink tmp rescue nil
- end
- else
- fd = IO.popen(cmd).extend(PlugStream)
- first_line = true
- log_prob = 1.0 / nthr
- while line = Timeout::timeout(timeout) { fd.get_line }
- data << line
- log.call name, line.chomp, type if name && (first_line || rand < log_prob)
- first_line = false
- end
- fd.close
- end
- [$? == 0, data.chomp]
- rescue Timeout::Error, Interrupt => e
- if fd && !fd.closed?
- killall fd.pid
- fd.close
- end
- cleanup.call if cleanup
- if e.is_a?(Timeout::Error) && tried < tries
- 3.downto(1) do |countdown|
- s = countdown > 1 ? 's' : ''
- log.call name, "Timeout. Will retry in #{countdown} second#{s} ...", type
- sleep 1
- end
- log.call name, 'Retrying ...', type
- retry
- end
- [false, e.is_a?(Interrupt) ? "Interrupted!" : "Timeout!"]
- end
- }
- main = Thread.current
- threads = []
- watcher = Thread.new {
- 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 } unless vim7
- end
- threads.each { |t| t.join rescue nil }
- main.kill
- }
- refresh = Thread.new {
- while true
- mtx.synchronize do
- break unless running
- VIM::command('noautocmd normal! a')
- end
- sleep 0.2
- end
- } if VIM::evaluate('s:mac_gui') == 1
-
- clone_opt = VIM::evaluate('s:clone_opt').join(' ')
- progress = VIM::evaluate('s:progress_opt(1)')
- nthr.times do
- mtx.synchronize do
- threads << Thread.new {
- while pair = take1.call
- name = pair.first
- 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 -f .git/config remote.origin.url", nil, nil, nil
- current_uri = data.lines.to_a.last
- if !ret
- if data =~ /^Interrupted|^Timeout/
- [false, data]
- else
- [false, [data.chomp, "PlugClean required."].join($/)]
- end
- elsif !compare_git_uri(current_uri, uri)
- [false, ["Invalid URI: #{current_uri}",
- "Expected: #{uri}",
- "PlugClean required."].join($/)]
- else
- 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", name, :update, nil
- else
- [true, skip]
- end
- end
- else
- d = esc dir.sub(%r{[\\/]+$}, '')
- log.call name, 'Installing ...', :install
- bt.call "git clone #{clone_opt unless tag} #{progress} #{uri} #{d} 2>&1", name, :install, proc {
- FileUtils.rm_rf dir
- }
- end
- mtx.synchronize { VIM::command("let s:update.new['#{name}'] = 1") } if !exists && ok
- log.call name, result, ok
- end
- } if running
- end
- end
- threads.each { |t| t.join rescue nil }
- logh.call
- refresh.kill if refresh
- watcher.kill
-EOF
-endfunction
-
-function! s:shellesc_cmd(arg, script)
- let escaped = substitute('"'.a:arg.'"', '[&|<>()@^!"]', '^&', 'g')
- return substitute(escaped, '%', (a:script ? '%' : '^') . '&', 'g')
-endfunction
-
-function! s:shellesc_ps1(arg)
- return "'".substitute(escape(a:arg, '\"'), "'", "''", 'g')."'"
-endfunction
-
-function! s:shellesc_sh(arg)
- return "'".substitute(a:arg, "'", "'\\\\''", 'g')."'"
-endfunction
-
-" Escape the shell argument based on the shell.
-" Vim and Neovim's shellescape() are insufficient.
-" 1. shellslash determines whether to use single/double quotes.
-" Double-quote escaping is fragile for cmd.exe.
-" 2. It does not work for powershell.
-" 3. It does not work for *sh shells if the command is executed
-" via cmd.exe (ie. cmd.exe /c sh -c command command_args)
-" 4. It does not support batchfile syntax.
-"
-" Accepts an optional dictionary with the following keys:
-" - shell: same as Vim/Neovim 'shell' option.
-" If unset, fallback to 'cmd.exe' on Windows or 'sh'.
-" - script: If truthy and shell is cmd.exe, escape for batchfile syntax.
-function! plug#shellescape(arg, ...)
- if a:arg =~# '^[A-Za-z0-9_/:.-]\+$'
- return a:arg
- endif
- let opts = a:0 > 0 && type(a:1) == s:TYPE.dict ? a:1 : {}
- let shell = get(opts, 'shell', s:is_win ? 'cmd.exe' : 'sh')
- let script = get(opts, 'script', 1)
- if shell =~# 'cmd\(\.exe\)\?$'
- return s:shellesc_cmd(a:arg, script)
- elseif s:is_powershell(shell)
- return s:shellesc_ps1(a:arg)
- endif
- return s:shellesc_sh(a:arg)
-endfunction
-
-function! s:glob_dir(path)
- return map(filter(s:glob(a:path, '**'), 'isdirectory(v:val)'), 's:dirpath(v:val)')
-endfunction
-
-function! s:progress_bar(line, bar, total)
- call setline(a:line, '[' . s:lpad(a:bar, a:total) . ']')
-endfunction
-
-function! s:compare_git_uri(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)
- if a:bullet != 'x'
- return [printf('%s %s: %s', a:bullet, a:name, s:lastline(a:message))]
- else
- let lines = map(s:lines(a:message), '" ".v:val')
- return extend([printf('x %s:', a:name)], lines)
- endif
-endfunction
-
-function! s:with_cd(cmd, dir, ...)
- let script = a:0 > 0 ? a:1 : 1
- return printf('cd%s %s && %s', s:is_win ? ' /d' : '', plug#shellescape(a:dir, {'script': script}), a:cmd)
-endfunction
-
-function! s:system(cmd, ...)
- let batchfile = ''
- try
- let [sh, shellcmdflag, shrd] = s:chsh(1)
- if type(a:cmd) == s:TYPE.list
- " Neovim's system() supports list argument to bypass the shell
- " but it cannot set the working directory for the command.
- " Assume that the command does not rely on the shell.
- if has('nvim') && a:0 == 0
- return system(a:cmd)
- endif
- let cmd = join(map(copy(a:cmd), 'plug#shellescape(v:val, {"shell": &shell, "script": 0})'))
- if s:is_powershell(&shell)
- let cmd = '& ' . cmd
- endif
- else
- let cmd = a:cmd
- endif
- if a:0 > 0
- let cmd = s:with_cd(cmd, a:1, type(a:cmd) != s:TYPE.list)
- endif
- if s:is_win && type(a:cmd) != s:TYPE.list
- let [batchfile, cmd] = s:batchfile(cmd)
- endif
- return system(cmd)
- finally
- let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
- if s:is_win && filereadable(batchfile)
- call delete(batchfile)
- endif
- endtry
-endfunction
-
-function! s:system_chomp(...)
- let ret = call('s:system', a:000)
- return v:shell_error ? '' : substitute(ret, '\n$', '', '')
-endfunction
-
-function! s:git_validate(spec, check_branch)
- let err = ''
- if isdirectory(a:spec.dir)
- let result = [s:git_local_branch(a:spec.dir), s:git_origin_url(a:spec.dir)]
- let remote = result[-1]
- if empty(remote)
- let err = join([remote, 'PlugClean required.'], "\n")
- elseif !s:compare_git_uri(remote, a:spec.uri)
- let err = join(['Invalid URI: '.remote,
- \ 'Expected: '.a:spec.uri,
- \ 'PlugClean required.'], "\n")
- elseif a:check_branch && has_key(a:spec, 'commit')
- let sha = s:git_revision(a:spec.dir)
- if empty(sha)
- let err = join(add(result, 'PlugClean required.'), "\n")
- elseif !s:hash_match(sha, a:spec.commit)
- let err = join([printf('Invalid HEAD (expected: %s, actual: %s)',
- \ a:spec.commit[:6], sha[:6]),
- \ 'PlugUpdate required.'], "\n")
- endif
- elseif a:check_branch
- let current_branch = result[0]
- " Check tag
- let origin_branch = s:git_origin_branch(a:spec)
- 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 && a:spec.tag !~ '\*'
- let err = printf('Invalid tag: %s (expected: %s). Try PlugUpdate.',
- \ (empty(tag) ? 'N/A' : tag), a:spec.tag)
- endif
- " Check branch
- elseif origin_branch !=# current_branch
- let err = printf('Invalid branch: %s (expected: %s). Try PlugUpdate.',
- \ current_branch, origin_branch)
- endif
- if empty(err)
- let [ahead, behind] = split(s:lastline(s:system([
- \ 'git', 'rev-list', '--count', '--left-right',
- \ printf('HEAD...origin/%s', origin_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.', origin_branch, ahead, behind)
- else
- let err = printf("Ahead of origin/%s by %d commit(s).\n"
- \ .'Cannot update until local changes are pushed.',
- \ origin_branch, ahead)
- endif
- endif
- endif
- endif
- else
- let err = 'Not found'
- endif
- return [err, err =~# 'PlugClean']
-endfunction
-
-function! s:rm_rf(dir)
- if isdirectory(a:dir)
- return s:system(s:is_win
- \ ? 'rmdir /S /Q '.plug#shellescape(a:dir)
- \ : ['rm', '-rf', a:dir])
- endif
-endfunction
-
-function! s:clean(force)
- call s:prepare()
- 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)
- 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)
- normal! 2G
- redraw
- endfor
-
- let allowed = {}
- for dir in dirs
- let allowed[s:dirpath(s:plug_fnamemodify(dir, ':h:h'))] = 1
- let allowed[dir] = 1
- for child in s:glob_dir(dir)
- let allowed[child] = 1
- endfor
- endfor
-
- let todo = []
- let found = sort(s:glob_dir(g:plug_home))
- while !empty(found)
- let f = remove(found, 0)
- 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
-
- 4
- redraw
- if empty(todo)
- call append(line('$'), 'Already clean.')
- else
- 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 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
- let err_count = 0
- 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
- let err = s:rm_rf(line[2:])
- setlocal modifiable
- if empty(err)
- call setline(l1, '~'.line[1:])
- let s:clean_count += 1
- else
- delete _
- call append(l1 - 1, s:format_message('x', line[1:], err))
- let l2 += len(s:lines(err))
- let err_count += 1
- endif
- let msg = printf('Removed %d directories.', s:clean_count)
- if err_count > 0
- let msg .= printf(' Failed to remove %d directories.', err_count)
- endif
- call setline(4, msg)
- setlocal nomodifiable
- endif
- endif
- let l1 += 1
- endwhile
-endfunction
-
-function! s:upgrade()
- echo 'Downloading the latest version of vim-plug'
- redraw
- let tmp = s:plug_tempname()
- let new = tmp . '/plug.vim'
-
- try
- let out = s:system(['git', 'clone', '--depth', '1', s:plug_src, tmp])
- if v:shell_error
- return s:err('Error upgrading vim-plug: '. out)
- endif
-
- if readfile(s:me) ==# readfile(new)
- echo 'vim-plug is already up-to-date'
- return 0
- else
- call rename(s:me, s:me . '.old')
- call rename(new, s:me)
- unlet g:loaded_plug
- echo 'vim-plug has been upgraded'
- return 1
- endif
- finally
- silent! call s:rm_rf(tmp)
- endtry
-endfunction
-
-function! s:upgrade_specs()
- for spec in values(g:plugs)
- let spec.frozen = get(spec, 'frozen', 0)
- endfor
-endfunction
-
-function! s:status()
- call s:prepare()
- call append(0, 'Checking plugins')
- call append(1, '')
-
- let ecnt = 0
- 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 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 is_dir
- let [valid, msg] = [1, 'OK']
- else
- let [valid, msg] = [0, 'Not found.']
- endif
- endif
- let cnt += 1
- let ecnt += !valid
- " `s:loaded` entry can be missing if PlugUpgraded
- if is_dir && get(s:loaded, name, -1) == 0
- let unloaded = 1
- let msg .= ' (not loaded)'
- endif
- call s:progress_bar(2, repeat('=', cnt), total)
- call append(3, s:format_message(valid ? '-' : 'x', name, msg))
- normal! 2G
- redraw
- endfor
- call setline(1, 'Finished. '.ecnt.' error(s).')
- normal! gg
- setlocal nomodifiable
- if unloaded
- echo "Press 'L' on each line to load plugin, or 'U' to update"
- nnoremap L :call status_load(line('.'))
- xnoremap L :call status_load(line('.'))
- end
-endfunction
-
-function! s:extract_name(str, prefix, suffix)
- return matchstr(a:str, '^'.a:prefix.' \zs[^:]\+\ze:.*'.a:suffix.'$')
-endfunction
-
-function! s:status_load(lnum)
- let line = getline(a:lnum)
- let name = s:extract_name(line, '-', '(not loaded)')
- if !empty(name)
- call plug#load(name)
- setlocal modifiable
- call setline(a:lnum, substitute(line, ' (not loaded)$', '', ''))
- setlocal nomodifiable
- endif
-endfunction
-
-function! s:status_update() range
- let lines = getline(a:firstline, a:lastline)
- let names = filter(map(lines, 's:extract_name(v:val, "[x-]", "")'), '!empty(v:val)')
- if !empty(names)
- echo
- execute 'PlugUpdate' join(names)
- endif
-endfunction
-
-function! s:is_preview_window_open()
- silent! wincmd P
- if &previewwindow
- wincmd p
- return 1
- endif
-endfunction
-
-function! s:find_name(lnum)
- for lnum in reverse(range(1, a:lnum))
- let line = getline(lnum)
- if empty(line)
- return ''
- endif
- let name = s:extract_name(line, '-', '')
- if !empty(name)
- return name
- endif
- endfor
- return ''
-endfunction
-
-function! s:preview_commit()
- if b:plug_preview < 0
- let b:plug_preview = !s:is_preview_window_open()
- endif
-
- let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-f]\{7,9}')
- if empty(sha)
- return
- endif
-
- let name = s:find_name(line('.'))
- if empty(name) || !has_key(g:plugs, name) || !isdirectory(g:plugs[name].dir)
- return
- endif
-
- 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
- let batchfile = ''
- try
- let [sh, shellcmdflag, shrd] = s:chsh(1)
- let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha
- if s:is_win
- let [batchfile, cmd] = s:batchfile(cmd)
- endif
- execute 'silent %!' cmd
- finally
- let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
- if s:is_win && filereadable(batchfile)
- call delete(batchfile)
- endif
- endtry
- setlocal nomodifiable
- nnoremap q :q
- wincmd p
-endfunction
-
-function! s:section(flags)
- call search('\(^[x-] \)\@<=[^:]\+:', a:flags)
-endfunction
-
-function! s:format_git_log(line)
- let indent = ' '
- let tokens = split(a:line, nr2char(1))
- if len(tokens) != 5
- return indent.substitute(a:line, '\s*$', '', '')
- endif
- let [graph, sha, refs, subject, date] = tokens
- let tag = matchstr(refs, 'tag: [^,)]\+')
- let tag = empty(tag) ? ' ' : ' ('.tag.') '
- return printf('%s%s%s%s%s (%s)', indent, graph, sha, tag, subject, date)
-endfunction
-
-function! s:append_ul(lnum, text)
- call append(a:lnum, ['', a:text, repeat('-', len(a:text))])
-endfunction
-
-function! s:diff()
- call s:prepare()
- call append(0, ['Collecting changes ...', ''])
- let cnts = [0, 0]
- let bar = ''
- let total = filter(copy(g:plugs), 's:is_managed(v:key) && isdirectory(v:val.dir)')
- call s:progress_bar(2, bar, len(total))
- for origin in [1, 0]
- let plugs = reverse(sort(items(filter(copy(total), (origin ? '' : '!').'(has_key(v:val, "commit") || has_key(v:val, "tag"))'))))
- if empty(plugs)
- continue
- endif
- call s:append_ul(2, origin ? 'Pending updates:' : 'Last update:')
- for [k, v] in plugs
- let branch = s:git_origin_branch(v)
- if len(branch)
- let range = origin ? '..origin/'.branch : 'HEAD@{1}..'
- let cmd = ['git', 'log', '--graph', '--color=never']
- if s:git_version_requirement(2, 10, 0)
- call add(cmd, '--no-show-signature')
- endif
- call extend(cmd, ['--pretty=format:%x01%h%x01%d%x01%s%x01%cr', range])
- if has_key(v, 'rtp')
- call extend(cmd, ['--', v.rtp])
- endif
- let diff = s:system_chomp(cmd, 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)')))
- let cnts[origin] += 1
- endif
- endif
- let bar .= '='
- call s:progress_bar(2, bar, len(total))
- normal! 2G
- redraw
- endfor
- if !cnts[origin]
- call append(5, ['', 'N/A'])
- endif
- endfor
- call setline(1, printf('%d plugin(s) updated.', cnts[0])
- \ . (cnts[1] ? printf(' %d plugin(s) have pending updates.', cnts[1]) : ''))
-
- if cnts[0] || cnts[1]
- nnoremap (plug-preview) :silent! call preview_commit()
- if empty(maparg("\", 'n'))
- nmap (plug-preview)
- endif
- if empty(maparg('o', 'n'))
- nmap o (plug-preview)
- endif
- endif
- if cnts[0]
- nnoremap X :call revert()
- echo "Press 'X' on each block to revert the update"
- endif
- normal! gg
- setlocal nomodifiable
-endfunction
-
-function! s:revert()
- if search('^Pending updates', 'bnW')
- return
- endif
-
- let name = s:find_name(line('.'))
- if empty(name) || !has_key(g:plugs, name) ||
- \ input(printf('Revert the update of %s? (y/N) ', name)) !~? '^y'
- return
- endif
-
- call s:system('git reset --hard HEAD@{1} && git checkout '.plug#shellescape(g:plugs[name].branch).' --', g:plugs[name].dir)
- setlocal modifiable
- normal! "_dap
- setlocal nomodifiable
- echo 'Reverted'
-endfunction
-
-function! s:snapshot(force, ...) abort
- call s:prepare()
- setf vim
- call append(0, ['" Generated by vim-plug',
- \ '" '.strftime("%c"),
- \ '" :source this file in vim to restore the snapshot',
- \ '" or execute: vim -S snapshot.vim',
- \ '', '', 'PlugUpdate!'])
- 1
- let anchor = line('$') - 3
- let names = sort(keys(filter(copy(g:plugs),
- \'has_key(v:val, "uri") && !has_key(v:val, "commit") && isdirectory(v:val.dir)')))
- for name in reverse(names)
- let sha = s:git_revision(g:plugs[name].dir)
- if !empty(sha)
- call append(anchor, printf("silent! let g:plugs['%s'].commit = '%s'", name, sha))
- redraw
- endif
- endfor
-
- if a:0 > 0
- let fn = s:plug_expand(a:1)
- if filereadable(fn) && !(a:force || s:ask(a:1.' already exists. Overwrite?'))
- return
- endif
- call writefile(getline(1, '$'), fn)
- echo 'Saved as '.a:1
- silent execute 'e' s:esc(fn)
- setf vim
- endif
-endfunction
-
-function! s:split_rtp()
- return split(&rtp, '\\\@
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ {one line to give the program's name and a brief idea of what it does.}
+ Copyright (C) {year} {name of author}
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ {project} Copyright (C) {year} {fullname}
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
+
diff --git a/vim/.config/vim/plugged/YCM-Generator/README.md b/vim/.config/vim/plugged/YCM-Generator/README.md
new file mode 100644
index 0000000..df93026
--- /dev/null
+++ b/vim/.config/vim/plugged/YCM-Generator/README.md
@@ -0,0 +1,72 @@
+# YCM-Generator
+This is a script which generates a list of compiler flags from a project with an arbitrary build system. It can be used to:
+
+* generate a ```.ycm_extra_conf.py``` file for use with [YouCompleteMe](https://github.com/Valloric/YouCompleteMe)
+* generate a ```.color_coded``` file for use with [color_coded](https://github.com/jeaye/color_coded)
+
+It works by building the project with a fake toolchain, which simply and filters compiler flags to be stored in the resulting file.
+
+It is reasonably fast, taking ~10 seconds to generate a configuration file for the Linux kernel.
+
+## Status
+This plugin is in maintenance mode. I am happy to merge PRs and triage bug reports, but am not actively working on it.
+
+## Installation
+Add ```NeoBundle 'rdnetto/YCM-Generator'``` to your vimrc (or the equivalent for your plugin manager).
+
+For [vim-plug](https://github.com/junegunn/vim-plug) users, add ```Plug 'rdnetto/YCM-Generator', { 'branch': 'stable'}``` to your vimrc.
+
+Alternatively, Arch Linux users can install YCM-Generator using the (unofficial) [AUR package](https://aur4.archlinux.org/packages/ycm-generator-git/).
+
+## Usage
+Run ```./config_gen.py PROJECT_DIRECTORY```, where ```PROJECT_DIRECTORY``` is the root directory of your project's build system (i.e. the one containing the root Makefile, etc.)
+
+You can also invoke it from within Vim using the ```:YcmGenerateConfig``` or ```:CCGenerateConfig``` commands to generate a config file for the current directory. These commands accept the same arguments as ```./config_gen.py```, but do not require the project directory to be specified (it defaults to the current working directory).
+
+## Requirements and Limitations
+* Requirements:
+ + Python 2
+ + Clang
+
+* Supported build systems:
+ + make
+ + cmake
+ + qmake
+ + autotools
+
+Your build system should support specifying the compiler through the ```CC```/```CXX``` environment variables, or not use an absolute path to the compiler.
+
+Some flags present in the resulting configuration file may be mutually exclusive with each other - reading the generated file prior to use is recommended.
+
+The script assumes that executables with the names `clang` and `clang++` exist in your `PATH`. This has been known to cause issues under Ubuntu, where the C++ compiler may be called `clang++-3.6` (see #50).
+
+## Documentation & Support
+* run ```./config_gen.py --help``` to see the complete list of supported options.
+* if you receive the error message ```ERROR: No commands were logged to the build logs```, try using the ```--verbose``` flag to see any error messages
+ + some build systems require certain environment variables to be set. Note that these will *not* be used by YCM-Generator by default, unless `--preserve-environment` is used
+ + if you open an issue regarding this error message, please include the output when running with ```--verbose``` and a link to the project repo (if possible)
+
+## Development
+Patches are welcome. Please submit pull requests against the ```develop``` branch.
+
+### Windows support
+The script is currently supported under Unices (Linux, NixOS[1], BSD, OS X) only.
+Implementing Windows support consists of porting the contents of ```fake-toolchain/Unix```.
+If you are interested in implementing/testing this, please open a pull request.
+
+[1] May require `--preserve-environment` - see [#19](https://github.com/rdnetto/YCM-Generator/issues/19)
+
+### Test Cases
+The following projects are used for testing:
+
+| Project | Build system | Notes |
+| ------------------------------------------------------------------------- | ----------------- | ------ |
+| [Linux kernel](https://git.kernel.org) | Kbuild (Make) | |
+| [Vim-qt](https://bitbucket.org/equalsraf/vim-qt.git) | Autotools | |
+| [Clementine](https://github.com/clementine-player/Clementine.git) | Cmake | |
+| [ExtPlane](https://github.com/vranki/ExtPlane.git) | Qmake | Should be tested with both versions of Qt. |
+| [OpenFOAM](https://github.com/OpenFOAM/OpenFOAM-3.0.x.git) | wmake | |
+
+## License
+YCM-Generator is published under the GNU GPLv3.
+
diff --git a/vim/.config/vim/plugged/YCM-Generator/config_gen.py b/vim/.config/vim/plugged/YCM-Generator/config_gen.py
new file mode 100755
index 0000000..6a4a108
--- /dev/null
+++ b/vim/.config/vim/plugged/YCM-Generator/config_gen.py
@@ -0,0 +1,502 @@
+#!/usr/bin/env python2
+
+import sys
+import os
+import os.path
+import re
+import argparse
+import datetime
+import multiprocessing
+import shlex
+import shutil
+import tempfile
+import time
+import subprocess
+import glob
+
+
+# Default flags for make
+default_make_flags = ["-i", "-j" + str(multiprocessing.cpu_count())]
+
+# Set YCM-Generator directory
+# Always obtain the real path to the directory where 'config_gen.py' lives as,
+# in some cases, it will be a symlink placed in '/usr/bin' (as is the case
+# with the Arch Linux AUR package) and it won't
+# be able to find the plugin directory.
+ycm_generator_dir = os.path.dirname(os.path.realpath(__file__))
+
+
+def main():
+ # parse command-line args
+ parser = argparse.ArgumentParser(description="Automatically generates config files for YouCompleteMe")
+ parser.add_argument("-v", "--verbose", action="store_true", help="Show output from build process")
+ parser.add_argument("-f", "--force", action="store_true", help="Overwrite the file if it exists.")
+ parser.add_argument("-m", "--make", default="make", help="Use the specified executable for make.")
+ parser.add_argument("-b", "--build-system", choices=["cmake", "autotools", "qmake", "make"], help="Force use of the specified build system rather than trying to autodetect.")
+ parser.add_argument("-c", "--compiler", help="Use the specified executable for clang. It should be the same version as the libclang used by YCM. The executable for clang++ will be inferred from this.")
+ parser.add_argument("-C", "--configure_opts", default="", help="Additional flags to pass to configure/cmake/etc. e.g. --configure_opts=\"--enable-FEATURE\"")
+ parser.add_argument("-F", "--format", choices=["ycm", "cc"], default="ycm", help="Format of output file (YouCompleteMe or color_coded). Default: ycm")
+ parser.add_argument("-M", "--make-flags", help="Flags to pass to make when fake-building. Default: -M=\"{}\"".format(" ".join(default_make_flags)))
+ parser.add_argument("-o", "--output", help="Save the config file as OUTPUT. Default: .ycm_extra_conf.py, or .color_coded if --format=cc.")
+ parser.add_argument("-x", "--language", choices=["c", "c++"], help="Only output flags for the given language. This defaults to whichever language has its compiler invoked the most.")
+ parser.add_argument("--out-of-tree", action="store_true", help="Build autotools projects out-of-tree. This is a no-op for other project types.")
+ parser.add_argument("--qt-version", choices=["4", "5"], default="5", help="Use the given Qt version for qmake. (Default: 5)")
+ parser.add_argument("-e", "--preserve-environment", action="store_true", help="Pass environment variables to build processes.")
+ parser.add_argument("PROJECT_DIR", help="The root directory of the project.")
+ args = vars(parser.parse_args())
+ project_dir = os.path.abspath(args["PROJECT_DIR"])
+
+ # verify that project_dir exists
+ if(not os.path.exists(project_dir)):
+ print("ERROR: '{}' does not exist".format(project_dir))
+ return 1
+
+ # verify the clang is installed, and infer the correct name for both the C and C++ compilers
+ try:
+ cc = args["compiler"] or "clang"
+ args["cc"] = subprocess.check_output(["which", cc]).strip()
+ except subprocess.CalledProcessError:
+ print("ERROR: Could not find clang at '{}'. Please make sure it is installed and is either in your path, or specified with --compiler.".format(cc))
+ return 1
+
+ try:
+ h, t = os.path.split(args["compiler"] or "clang")
+ cxx = os.path.join(h, t.replace("clang", "clang++"))
+ args["cxx"] = subprocess.check_output(["which", cxx]).strip()
+ except subprocess.CalledProcessError:
+ print("ERROR: Could not find clang++ at '{}'. Please make sure it is installed and specified appropriately.".format(cxx))
+ return 1
+
+ # sanity check - remove this after we add Windows support
+ if(sys.platform.startswith("win32")):
+ print("ERROR: Windows is not supported")
+
+ # prompt user to overwrite existing file (if necessary)
+ config_file = {
+ None: args["output"],
+ "cc": os.path.join(project_dir, ".color_coded"),
+ "ycm": os.path.join(project_dir, ".ycm_extra_conf.py"),
+ }[args["format"] if args["output"] is None else None]
+
+ if(os.path.exists(config_file) and not args["force"]):
+ print("'{}' already exists. Overwrite? [y/N] ".format(config_file)),
+ response = sys.stdin.readline().strip().lower()
+
+ if(response != "y" and response != "yes"):
+ return 1
+
+ # command-line args to pass to fake_build() using kwargs
+ args["make_cmd"] = args.pop("make")
+ args["configure_opts"] = shlex.split(args["configure_opts"])
+ args["make_flags"] = default_make_flags if args["make_flags"] is None else shlex.split(args["make_flags"])
+ force_lang = args.pop("language")
+ output_format = args.pop("format")
+ del args["compiler"]
+ del args["force"]
+ del args["output"]
+ del args["PROJECT_DIR"]
+
+ generate_conf = {
+ "ycm": generate_ycm_conf,
+ "cc": generate_cc_conf,
+ }[output_format]
+
+ # temporary files to hold build logs
+ with tempfile.NamedTemporaryFile(mode="rw") as c_build_log:
+ with tempfile.NamedTemporaryFile(mode="rw") as cxx_build_log:
+ # perform the actual compilation of flags
+ fake_build(project_dir, c_build_log.name, cxx_build_log.name, **args)
+ (c_count, c_skip, c_flags) = parse_flags(c_build_log)
+ (cxx_count, cxx_skip, cxx_flags) = parse_flags(cxx_build_log)
+
+ print("Collected {} relevant entries for C compilation ({} discarded).".format(c_count, c_skip))
+ print("Collected {} relevant entries for C++ compilation ({} discarded).".format(cxx_count, cxx_skip))
+
+ # select the language to compile for. If -x was used, zero all other options (so we don't need to repeat the error code)
+ if(force_lang == "c"):
+ cxx_count = 0
+ elif(force_lang == "c++"):
+ c_count = 0
+
+ if(c_count == 0 and cxx_count == 0):
+ print("")
+ print("ERROR: No commands were logged to the build logs (C: {}, C++: {}).".format(c_build_log.name, cxx_build_log.name))
+ print("Your build system may not be compatible.")
+
+ if(not args["verbose"]):
+ print("")
+ print("Try running with the --verbose flag to see build system output - the most common cause of this is a hardcoded compiler path.")
+
+ c_build_log.delete = False
+ cxx_build_log.delete = False
+ return 3
+
+ elif(c_count > cxx_count):
+ lang, flags = ("c", c_flags)
+ else:
+ lang, flags = ("c++", cxx_flags)
+
+ generate_conf(["-x", lang] + flags, config_file)
+ print("Created {} config file with {} {} flags".format(output_format.upper(), len(flags), lang.upper()))
+
+
+def fake_build(project_dir, c_build_log_path, cxx_build_log_path, verbose, make_cmd, build_system, cc, cxx, out_of_tree, configure_opts, make_flags, preserve_environment, qt_version):
+ '''Builds the project using the fake toolchain, to collect the compiler flags.
+
+ project_dir: the directory containing the source files
+ build_log_path: the file to log commands to
+ verbose: show the build process output
+ make_cmd: the path of the make executable
+ cc: the path of the clang executable
+ cxx: the path of the clang++ executable
+ out_of_tree: perform an out-of-tree build (autotools only)
+ configure_opts: additional flags for configure stage
+ make_flags: additional flags for make
+ preserve_environment: pass environment variables to build processes
+ qt_version: The Qt version to use when building with qmake.
+ '''
+
+ # TODO: add Windows support
+ assert(not sys.platform.startswith("win32"))
+ fake_path = os.path.join(ycm_generator_dir, "fake-toolchain", "Unix")
+
+ # environment variables and arguments for build process
+ started = time.time()
+ FNULL = open(os.devnull, "w")
+ proc_opts = {} if verbose else {
+ "stdin": FNULL,
+ "stdout": FNULL,
+ "stderr": FNULL
+ }
+ proc_opts["cwd"] = project_dir
+
+ if(preserve_environment):
+ env = os.environ
+ else:
+ # Preserve HOME, since Cmake needs it to find some packages and it's
+ # normally there anyway. See #26.
+ env = dict(map(lambda x: (x, os.environ[x]), ["HOME"]))
+
+ env["PATH"] = "{}:{}".format(fake_path, os.environ["PATH"])
+ env["CC"] = "clang"
+ env["CXX"] = "clang++"
+ env["YCM_CONFIG_GEN_CC_LOG"] = c_build_log_path
+ env["YCM_CONFIG_GEN_CXX_LOG"] = cxx_build_log_path
+
+ # used during configuration stage, so that cmake, etc. can verify what the compiler supports
+ env_config = env.copy()
+ env_config["YCM_CONFIG_GEN_CC_PASSTHROUGH"] = cc
+ env_config["YCM_CONFIG_GEN_CXX_PASSTHROUGH"] = cxx
+
+ # use -i (ignore errors), since the makefile may include scripts which
+ # depend upon the existence of various output files
+ make_args = [make_cmd] + make_flags
+
+ # Used for the qmake build system below
+ pro_files = glob.glob(os.path.join(project_dir, "*.pro"))
+
+ # sanity check - make sure the toolchain is available
+ assert os.path.exists(fake_path), "Could not find toolchain at '{}'".format(fake_path)
+
+ # helper function to display exact commands used
+ def run(cmd, *args, **kwargs):
+ print("$ " + " ".join(cmd))
+ subprocess.call(cmd, *args, **kwargs)
+
+ if build_system is None:
+ if os.path.exists(os.path.join(project_dir, "CMakeLists.txt")):
+ build_system = "cmake"
+ elif os.path.exists(os.path.join(project_dir, "configure")):
+ build_system = "autotools"
+ elif pro_files:
+ build_system = "qmake"
+ elif any([os.path.exists(os.path.join(project_dir, x)) for x in ["GNUmakefile", "makefile", "Makefile"]]):
+ build_system = "make"
+
+ # execute the build system
+ if build_system == "cmake":
+ # cmake
+ # run cmake in a temporary directory, then compile the project as usual
+ build_dir = tempfile.mkdtemp()
+ proc_opts["cwd"] = build_dir
+
+ # if the project was built in-tree, we need to hide the cache file so that cmake
+ # populates the build dir instead of just re-generating the existing files
+ cache_path = os.path.join(project_dir, "CMakeCache.txt")
+
+ if(os.path.exists(cache_path)):
+ fd, cache_tmp = tempfile.mkstemp()
+ os.close(fd)
+ shutil.move(cache_path, cache_tmp)
+ else:
+ cache_tmp = None
+
+ print("Running cmake in '{}'...".format(build_dir))
+ sys.stdout.flush()
+ run(["cmake", project_dir] + configure_opts, env=env_config, **proc_opts)
+
+ print("\nRunning make...")
+ sys.stdout.flush()
+ run(make_args, env=env, **proc_opts)
+
+ print("\nCleaning up...")
+ print("")
+ sys.stdout.flush()
+ shutil.rmtree(build_dir)
+
+ if(cache_tmp):
+ shutil.move(cache_tmp, cache_path)
+
+ elif build_system == "autotools":
+ # autotools
+ # perform build in-tree, since not all projects handle out-of-tree builds correctly
+
+ if(out_of_tree):
+ build_dir = tempfile.mkdtemp()
+ proc_opts["cwd"] = build_dir
+ print("Configuring autotools in '{}'...".format(build_dir))
+ else:
+ print("Configuring autotools...")
+
+ run([os.path.join(project_dir, "configure")] + configure_opts, env=env_config, **proc_opts)
+
+ print("\nRunning make...")
+ run(make_args, env=env, **proc_opts)
+
+ print("\nCleaning up...")
+
+ if(out_of_tree):
+ print("")
+ shutil.rmtree(build_dir)
+ else:
+ run([make_cmd, "maintainer-clean"], env=env, **proc_opts)
+
+ elif build_system == "qmake":
+ # qmake
+ # make sure there is only one .pro file
+ if len(pro_files) != 1:
+ print("ERROR: Found {} .pro files (expected one): {}.".format(
+ len(pro_files), ', '.join(pro_files)))
+ sys.exit(1)
+
+ # run qmake in a temporary directory, then compile the project as usual
+ build_dir = tempfile.mkdtemp()
+ proc_opts["cwd"] = build_dir
+ env_config["QT_SELECT"] = qt_version
+
+ # QMAKESPEC is platform dependent - valid mkspecs are in
+ # /usr/share/qt4/mkspecs, /usr/lib64/qt5/mkspecs
+ env_config["QMAKESPEC"] = {
+ ("Linux", True): "unsupported/linux-clang",
+ ("Linux", False): "linux-clang",
+ ("Darwin", True): "unsupported/macx-clang",
+ ("Darwin", False): "macx-clang",
+ ("FreeBSD", False): "unsupported/freebsd-clang",
+ }[(os.uname()[0], qt_version == "4")]
+
+ print("Running qmake in '{}' with Qt {}...".format(build_dir, qt_version))
+ run(["qmake"] + configure_opts + [pro_files[0]], env=env_config,
+ **proc_opts)
+
+ print("\nRunning make...")
+ run(make_args, env=env, **proc_opts)
+
+ print("\nCleaning up...")
+ print("")
+ shutil.rmtree(build_dir)
+
+ elif build_system == "make":
+ # make
+ # needs to be handled last, since other build systems can generate Makefiles
+ print("Preparing build directory...")
+ run([make_cmd, "clean"], env=env, **proc_opts)
+
+ print("\nRunning make...")
+ run(make_args, env=env, **proc_opts)
+
+ elif(os.path.exists(os.path.join(project_dir, "Make/options"))):
+ print("Found OpenFOAM Make/options")
+
+ # OpenFOAM build system
+ make_args = ["wmake"]
+
+ # Since icpc could not find directory in which g++ resides,
+ # set environmental variables to gcc to make fake_build operate normally.
+
+ env['WM_COMPILER']='Gcc'
+ env['WM_CC']='gcc'
+ env['WM_CXX']='g++'
+
+ print("\nRunning wmake...")
+ run(make_args, env=env, **proc_opts)
+
+ else:
+ print("ERROR: Unknown build system")
+ sys.exit(2)
+
+ print("Build completed in {} sec".format(round(time.time() - started, 2)))
+ print("")
+
+
+def parse_flags(build_log):
+ '''Creates a list of compiler flags from the build log.
+
+ build_log: an iterator of lines
+ Returns: (line_count, skip_count, flags)
+ flags is a list, and the counts are integers
+ '''
+
+ # Used to ignore entries which result in temporary files, or don't fully
+ # compile the file
+ temp_output = re.compile("(-x assembler)|(-o ([a-zA-Z0-9._].tmp))|(/dev/null)")
+ skip_count = 0
+
+ # Flags we want:
+ # -includes (-i, -I)
+ # -defines (-D)
+ # -warnings (-Werror), but no assembler, etc. flags (-Wa,-option)
+ # -language (-std=gnu99) and standard library (-nostdlib)
+ # -word size (-m64)
+ flags_whitelist = ["-[iIDF].*", "-W[^,]*", "-std=[a-z0-9+]+", "-(no)?std(lib|inc)", "-m[0-9]+"]
+ flags_whitelist = re.compile("|".join(map("^{}$".format, flags_whitelist)))
+ flags = set()
+ line_count = 0
+
+ # macro definitions should be handled separately, so we can resolve duplicates
+ define_flags = dict()
+ define_regex = re.compile("-D([a-zA-Z0-9_]+)=(.*)")
+
+ # Used to only bundle filenames with applicable arguments
+ filename_flags = ["-o", "-I", "-isystem", "-iquote", "-include", "-imacros", "-isysroot"]
+
+ # Process build log
+ for line in build_log:
+ if(temp_output.search(line)):
+ skip_count += 1
+ continue
+
+ line_count += 1
+ words = split_flags(line)
+
+ for (i, word) in enumerate(words):
+ if(word[0] != '-' or not flags_whitelist.match(word)):
+ continue
+
+ # handle macro definitions
+ m = define_regex.match(word)
+ if(m):
+ if(m.group(1) not in define_flags):
+ define_flags[m.group(1)] = [m.group(2)]
+ elif(m.group(2) not in define_flags[m.group(1)]):
+ define_flags[m.group(1)].append(m.group(2))
+
+ continue
+
+ # include arguments for this option, if there are any, as a tuple
+ if(i != len(words) - 1 and word in filename_flags and words[i + 1][0] != '-'):
+ flags.add((word, words[i + 1]))
+ else:
+ flags.add(word)
+
+ # Only specify one word size (the largest)
+ # (Different sizes are used for different files in the linux kernel.)
+ mRegex = re.compile("^-m[0-9]+$")
+ word_flags = list([f for f in flags if isinstance(f, basestring) and mRegex.match(f)])
+
+ if(len(word_flags) > 1):
+ for flag in word_flags:
+ flags.remove(flag)
+
+ flags.add(max(word_flags))
+
+ # Resolve duplicate macro definitions (always choose the last value for consistency)
+ for name, values in define_flags.iteritems():
+ if(len(values) > 1):
+ print("WARNING: {} distinct definitions of macro {} found".format(len(values), name))
+ values.sort()
+
+ flags.add("-D{}={}".format(name, values[0]))
+
+ return (line_count, skip_count, sorted(flags))
+
+
+def generate_cc_conf(flags, config_file):
+ '''Generates the .color_coded file
+
+ flags: the list of flags
+ config_file: the path to save the configuration file at'''
+
+ with open(config_file, "w") as output:
+ for flag in flags:
+ if(isinstance(flag, basestring)):
+ output.write(flag + "\n")
+ else: # is tuple
+ for f in flag:
+ output.write(f + "\n")
+
+
+def generate_ycm_conf(flags, config_file):
+ '''Generates the .ycm_extra_conf.py.
+
+ flags: the list of flags
+ config_file: the path to save the configuration file at'''
+
+ template_file = os.path.join(ycm_generator_dir, "template.py")
+
+ with open(template_file, "r") as template:
+ with open(config_file, "w") as output:
+ output.write("# Generated by YCM Generator at {}\n\n".format(str(datetime.datetime.today())))
+
+ for line in template:
+ if(line == " # INSERT FLAGS HERE\n"):
+ # insert generated code
+ for flag in flags:
+ if(isinstance(flag, basestring)):
+ output.write(" '{}',\n".format(flag))
+ else: # is tuple
+ output.write(" '{}', '{}',\n".format(*flag))
+
+ else:
+ # copy template
+ output.write(line)
+
+
+def split_flags(line):
+ '''Helper method that splits a string into flags.
+ Flags are space-seperated, except for spaces enclosed in quotes.
+ Returns a list of flags'''
+
+ # Pass 1: split line using whitespace
+ words = line.strip().split()
+
+ # Pass 2: merge words so that the no. of quotes is balanced
+ res = []
+
+ for w in words:
+ if(len(res) > 0 and unbalanced_quotes(res[-1])):
+ res[-1] += " " + w
+ else:
+ res.append(w)
+
+ return res
+
+
+def unbalanced_quotes(s):
+ '''Helper method that returns True if the no. of single or double quotes in s is odd.'''
+
+ single = 0
+ double = 0
+
+ for c in s:
+ if(c == "'"):
+ single += 1
+ elif(c == '"'):
+ double += 1
+
+ return (single % 2 == 1 or double % 2 == 1)
+
+
+if(__name__ == "__main__"):
+ # Note that sys.exit() lets us use None and 0 interchangably
+ sys.exit(main())
+
diff --git a/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/ar b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/ar
new file mode 100755
index 0000000..8a395e6
--- /dev/null
+++ b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/ar
@@ -0,0 +1,4 @@
+#!/bin/sh
+# This script is needed because /bin/true does not exist on non-FHS-compliant distros. e.g. NixOS
+exit 0
+
diff --git a/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/as b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/as
new file mode 100755
index 0000000..8a395e6
--- /dev/null
+++ b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/as
@@ -0,0 +1,4 @@
+#!/bin/sh
+# This script is needed because /bin/true does not exist on non-FHS-compliant distros. e.g. NixOS
+exit 0
+
diff --git a/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/cc b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/cc
new file mode 100755
index 0000000..8ecd890
--- /dev/null
+++ b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/cc
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+if [ ! -z "$YCM_CONFIG_GEN_CC_PASSTHROUGH" ]; then
+ # Cmake determines compiler properties by compiling a test file, so call clang for this case
+ $YCM_CONFIG_GEN_CC_PASSTHROUGH $@
+
+elif [ "$1" = "-v" ] || [ "$1" = "--version" ]; then
+ # Needed to enable clang-specific options for certain build systems (e.g. linux)
+ $YCM_CONFIG_GEN_CC_PASSTHROUGH $@
+
+else
+ echo "$@" >> $YCM_CONFIG_GEN_CC_LOG
+fi
+
diff --git a/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/clang b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/clang
new file mode 100755
index 0000000..8ecd890
--- /dev/null
+++ b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/clang
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+if [ ! -z "$YCM_CONFIG_GEN_CC_PASSTHROUGH" ]; then
+ # Cmake determines compiler properties by compiling a test file, so call clang for this case
+ $YCM_CONFIG_GEN_CC_PASSTHROUGH $@
+
+elif [ "$1" = "-v" ] || [ "$1" = "--version" ]; then
+ # Needed to enable clang-specific options for certain build systems (e.g. linux)
+ $YCM_CONFIG_GEN_CC_PASSTHROUGH $@
+
+else
+ echo "$@" >> $YCM_CONFIG_GEN_CC_LOG
+fi
+
diff --git a/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/clang++ b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/clang++
new file mode 100755
index 0000000..4e3733e
--- /dev/null
+++ b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/clang++
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+if [ ! -z "$YCM_CONFIG_GEN_CC_PASSTHROUGH" ]; then
+ # Cmake determines compiler properties by compiling a test file, so call clang for this case
+ $YCM_CONFIG_GEN_CXX_PASSTHROUGH $@
+
+elif [ "$1" = "-v" ] || [ "$1" = "--version" ]; then
+ # Needed to enable clang-specific options for certain build systems (e.g. linux)
+ $YCM_CONFIG_GEN_CXX_PASSTHROUGH $@
+
+else
+ echo "$@" >> $YCM_CONFIG_GEN_CXX_LOG
+fi
+
diff --git a/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/cxx b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/cxx
new file mode 100755
index 0000000..4e3733e
--- /dev/null
+++ b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/cxx
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+if [ ! -z "$YCM_CONFIG_GEN_CC_PASSTHROUGH" ]; then
+ # Cmake determines compiler properties by compiling a test file, so call clang for this case
+ $YCM_CONFIG_GEN_CXX_PASSTHROUGH $@
+
+elif [ "$1" = "-v" ] || [ "$1" = "--version" ]; then
+ # Needed to enable clang-specific options for certain build systems (e.g. linux)
+ $YCM_CONFIG_GEN_CXX_PASSTHROUGH $@
+
+else
+ echo "$@" >> $YCM_CONFIG_GEN_CXX_LOG
+fi
+
diff --git a/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/g++ b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/g++
new file mode 100755
index 0000000..4e3733e
--- /dev/null
+++ b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/g++
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+if [ ! -z "$YCM_CONFIG_GEN_CC_PASSTHROUGH" ]; then
+ # Cmake determines compiler properties by compiling a test file, so call clang for this case
+ $YCM_CONFIG_GEN_CXX_PASSTHROUGH $@
+
+elif [ "$1" = "-v" ] || [ "$1" = "--version" ]; then
+ # Needed to enable clang-specific options for certain build systems (e.g. linux)
+ $YCM_CONFIG_GEN_CXX_PASSTHROUGH $@
+
+else
+ echo "$@" >> $YCM_CONFIG_GEN_CXX_LOG
+fi
+
diff --git a/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/gcc b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/gcc
new file mode 100755
index 0000000..8ecd890
--- /dev/null
+++ b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/gcc
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+if [ ! -z "$YCM_CONFIG_GEN_CC_PASSTHROUGH" ]; then
+ # Cmake determines compiler properties by compiling a test file, so call clang for this case
+ $YCM_CONFIG_GEN_CC_PASSTHROUGH $@
+
+elif [ "$1" = "-v" ] || [ "$1" = "--version" ]; then
+ # Needed to enable clang-specific options for certain build systems (e.g. linux)
+ $YCM_CONFIG_GEN_CC_PASSTHROUGH $@
+
+else
+ echo "$@" >> $YCM_CONFIG_GEN_CC_LOG
+fi
+
diff --git a/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/gcc++ b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/gcc++
new file mode 100755
index 0000000..4e3733e
--- /dev/null
+++ b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/gcc++
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+if [ ! -z "$YCM_CONFIG_GEN_CC_PASSTHROUGH" ]; then
+ # Cmake determines compiler properties by compiling a test file, so call clang for this case
+ $YCM_CONFIG_GEN_CXX_PASSTHROUGH $@
+
+elif [ "$1" = "-v" ] || [ "$1" = "--version" ]; then
+ # Needed to enable clang-specific options for certain build systems (e.g. linux)
+ $YCM_CONFIG_GEN_CXX_PASSTHROUGH $@
+
+else
+ echo "$@" >> $YCM_CONFIG_GEN_CXX_LOG
+fi
+
diff --git a/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/ld b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/ld
new file mode 100755
index 0000000..8a395e6
--- /dev/null
+++ b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/ld
@@ -0,0 +1,4 @@
+#!/bin/sh
+# This script is needed because /bin/true does not exist on non-FHS-compliant distros. e.g. NixOS
+exit 0
+
diff --git a/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/nm b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/nm
new file mode 100755
index 0000000..8a395e6
--- /dev/null
+++ b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/nm
@@ -0,0 +1,4 @@
+#!/bin/sh
+# This script is needed because /bin/true does not exist on non-FHS-compliant distros. e.g. NixOS
+exit 0
+
diff --git a/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/true b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/true
new file mode 100755
index 0000000..8a395e6
--- /dev/null
+++ b/vim/.config/vim/plugged/YCM-Generator/fake-toolchain/Unix/true
@@ -0,0 +1,4 @@
+#!/bin/sh
+# This script is needed because /bin/true does not exist on non-FHS-compliant distros. e.g. NixOS
+exit 0
+
diff --git a/vim/.config/vim/plugged/YCM-Generator/plugin/ycm-generator.vim b/vim/.config/vim/plugged/YCM-Generator/plugin/ycm-generator.vim
new file mode 100644
index 0000000..f296774
--- /dev/null
+++ b/vim/.config/vim/plugged/YCM-Generator/plugin/ycm-generator.vim
@@ -0,0 +1,23 @@
+
+let s:config_gen = expand(":p:h:h") . "/config_gen.py"
+
+command! -nargs=? -complete=file_in_path -bang CCGenerateConfig call s:GenerateConfig("cc", 0, "")
+command! -nargs=? -complete=file_in_path -bang YcmGenerateConfig call s:GenerateConfig("ycm", 0, "")
+
+function! s:GenerateConfig(fmt, overwrite, flags)
+ let l:cmd = "! " . s:config_gen . " -F " . a:fmt . " " . a:flags
+
+ if a:overwrite
+ let l:cmd = l:cmd . " -f"
+ endif
+
+ " Only append the working directory if the last option is a flag
+ let l:split_flags = split(a:flags)
+ if len(l:split_flags) == 0 || l:split_flags[-1] =~ "^-"
+ let l:cmd = l:cmd . " " . shellescape(getcwd())
+ endif
+
+ " Disable interactive prompts for consistency with Neovim
+ execute l:cmd . "
+
+import os
+import ycm_core
+
+flags = [
+ # INSERT FLAGS HERE
+]
+
+
+# Set this to the absolute path to the folder (NOT the file!) containing the
+# compile_commands.json file to use that instead of 'flags'. See here for
+# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
+#
+# You can get CMake to generate this file for you by adding:
+# set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
+# to your CMakeLists.txt file.
+#
+# Most projects will NOT need to set this to anything; you can just change the
+# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
+compilation_database_folder = ''
+
+if os.path.exists( compilation_database_folder ):
+ database = ycm_core.CompilationDatabase( compilation_database_folder )
+else:
+ database = None
+
+SOURCE_EXTENSIONS = [ '.C', '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
+
+def DirectoryOfThisScript():
+ return os.path.dirname( os.path.abspath( __file__ ) )
+
+
+def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
+ if not working_directory:
+ return list( flags )
+ new_flags = []
+ make_next_absolute = False
+ path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
+ for flag in flags:
+ new_flag = flag
+
+ if make_next_absolute:
+ make_next_absolute = False
+ if not flag.startswith( '/' ):
+ new_flag = os.path.join( working_directory, flag )
+
+ for path_flag in path_flags:
+ if flag == path_flag:
+ make_next_absolute = True
+ break
+
+ if flag.startswith( path_flag ):
+ path = flag[ len( path_flag ): ]
+ new_flag = path_flag + os.path.join( working_directory, path )
+ break
+
+ if new_flag:
+ new_flags.append( new_flag )
+ return new_flags
+
+
+def IsHeaderFile( filename ):
+ extension = os.path.splitext( filename )[ 1 ]
+ return extension in [ '.H', '.h', '.hxx', '.hpp', '.hh' ]
+
+
+def GetCompilationInfoForFile( filename ):
+ # The compilation_commands.json file generated by CMake does not have entries
+ # for header files. So we do our best by asking the db for flags for a
+ # corresponding source file, if any. If one exists, the flags for that file
+ # should be good enough.
+ if IsHeaderFile( filename ):
+ basename = os.path.splitext( filename )[ 0 ]
+ for extension in SOURCE_EXTENSIONS:
+ replacement_file = basename + extension
+ if os.path.exists( replacement_file ):
+ compilation_info = database.GetCompilationInfoForFile(
+ replacement_file )
+ if compilation_info.compiler_flags_:
+ return compilation_info
+ return None
+ return database.GetCompilationInfoForFile( filename )
+
+
+def FlagsForFile( filename, **kwargs ):
+ if database:
+ # Bear in mind that compilation_info.compiler_flags_ does NOT return a
+ # python list, but a "list-like" StringVec object
+ compilation_info = GetCompilationInfoForFile( filename )
+ if not compilation_info:
+ return None
+
+ final_flags = MakeRelativePathsInFlagsAbsolute(
+ compilation_info.compiler_flags_,
+ compilation_info.compiler_working_dir_ )
+
+ else:
+ relative_to = DirectoryOfThisScript()
+ final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
+
+ return {
+ 'flags': final_flags,
+ 'do_cache': True
+ }
+
+def Settings( **kwargs ):
+ language = kwargs[ 'language' ]
+ if language == 'cfamily':
+ return {
+ 'flags': flags
+ }
+
+ return {}
diff --git a/vim/.config/vim/plugged/nord-vim/.editorconfig b/vim/.config/vim/plugged/nord-vim/.editorconfig
new file mode 100644
index 0000000..885acd4
--- /dev/null
+++ b/vim/.config/vim/plugged/nord-vim/.editorconfig
@@ -0,0 +1,27 @@
+# Copyright (c) 2016-present Sven Greb
+# This source code is licensed under the MIT license found in the license file.
+
+# Configurations for EditorConfig.
+# See https://editorconfig.org/#file-format-details for more details.
+
+# +--------------------+
+# + Base Configuration +
+# +--------------------+
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+indent_size = 2
+indent_style = space
+insert_final_newline = true
+max_line_length = 160
+trim_trailing_whitespace = true
+
+# +-----------+
+# + Languages +
+# +-----------+
+# +--- Markdown ---+
+[*.{md}]
+max_line_length = off
+trim_trailing_whitespace = false
diff --git a/vim/.config/vim/plugged/nord-vim/.gitattributes b/vim/.config/vim/plugged/nord-vim/.gitattributes
new file mode 100644
index 0000000..ad8e9b4
--- /dev/null
+++ b/vim/.config/vim/plugged/nord-vim/.gitattributes
@@ -0,0 +1,12 @@
+# Copyright (c) 2016-present Sven Greb
+# This source code is licensed under the MIT license found in the license file.
+
+# Configuration to define attributes per path.
+#
+# References:
+# 1. https://git-scm.com/docs/gitattributes
+# 2. https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#Keyword-Expansion
+
+# Automatically perform line feed (LF) normalization for files detected as text and
+# leave all files detected as binary untouched.
+* text=auto eol=lf
diff --git a/vim/.config/vim/plugged/nord-vim/.github/codeowners b/vim/.config/vim/plugged/nord-vim/.github/codeowners
new file mode 100644
index 0000000..0f7b107
--- /dev/null
+++ b/vim/.config/vim/plugged/nord-vim/.github/codeowners
@@ -0,0 +1,14 @@
+# Copyright (c) 2016-present Sven Greb
+# This source code is licensed under the MIT license found in the license file.
+
+# Configuration for the GitHub feature to automatically request reviews from the code owners
+# when a pull request changes any owned files.
+#
+# References:
+# 1. https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-file-location
+# 2. https://github.com/blog/2392-introducing-code-owners
+
+# +----------------------+
+# + Core Team Code Owner +
+# +----------------------+
+* @svengreb
diff --git a/vim/.config/vim/plugged/nord-vim/.gitignore b/vim/.config/vim/plugged/nord-vim/.gitignore
new file mode 100644
index 0000000..78562b3
--- /dev/null
+++ b/vim/.config/vim/plugged/nord-vim/.gitignore
@@ -0,0 +1,10 @@
+# Copyright (c) 2016-present Sven Greb
+# This source code is licensed under the MIT license found in the license file.
+
+# Path match pattern to intentionally ignore untracked files and directories.
+# See https://git-scm.com/docs/gitignore for more details.
+
+# +---------+
+# + Node.js +
+# +---------+
+**/node_modules/
diff --git a/vim/.config/vim/plugged/nord-vim/.mailmap b/vim/.config/vim/plugged/nord-vim/.mailmap
new file mode 100644
index 0000000..0745dec
--- /dev/null
+++ b/vim/.config/vim/plugged/nord-vim/.mailmap
@@ -0,0 +1,8 @@
+# Copyright (c) 2016-present Sven Greb
+# This source code is licensed under the MIT license found in the license file.
+
+# Configuration for the Git mail mapping feature to coalesce together commits by the same person in the shortlog,
+# where their name and/or email address was spelled differently or has been changed.
+# See https://git-scm.com/docs/git-shortlog#_mapping_authors for more details.
+Sven Greb
+Sven Greb
diff --git a/vim/.config/vim/plugged/nord-vim/.npmrc b/vim/.config/vim/plugged/nord-vim/.npmrc
new file mode 100644
index 0000000..2ddf945
--- /dev/null
+++ b/vim/.config/vim/plugged/nord-vim/.npmrc
@@ -0,0 +1,18 @@
+# Copyright (c) 2016-present Sven Greb
+# This source code is licensed under the MIT license found in the license file.
+
+# Configurations for npm.
+# See https://docs.npmjs.com/cli/v7/configuring-npm/npmrc for more details.
+
+# Only use a lockfile for single-consumer projects, like applications, but not for multi-consumer projects like
+# libraries.
+# It helps to pin dependency versions, improves the security through integrity checksums, prevents possible errors
+# caused by updated transitive dependencies and allows to get deterministic build results, but it can hide problems in
+# multi-consumer projects when any later versions of a used dependency, or its transitive dependencies, is not
+# compatible with the own project anymore.
+package-lock=true
+
+# Do not resolve to the latest minor and patch updates.
+# Automatically pin dependencies to exact versions instead of resolving to latest minor and patch updates.
+# This prevents possible errors caused by updated transitive dependencies.
+save-exact=true
diff --git a/vim/.config/vim/plugged/nord-vim/autoload/airline/themes/nord.vim b/vim/.config/vim/plugged/nord-vim/autoload/airline/themes/nord.vim
new file mode 100755
index 0000000..ba1a9d9
--- /dev/null
+++ b/vim/.config/vim/plugged/nord-vim/autoload/airline/themes/nord.vim
@@ -0,0 +1,94 @@
+" Copyright (c) 2016-present Sven Greb
+" This source code is licensed under the MIT license found in the license file.
+
+let s:nord_vim_version="0.19.0"
+let g:airline#themes#nord#palette = {}
+
+let s:nord0_gui = "#2E3440"
+let s:nord1_gui = "#3B4252"
+let s:nord2_gui = "#434C5E"
+let s:nord3_gui = "#4C566A"
+let s:nord4_gui = "#D8DEE9"
+let s:nord5_gui = "#E5E9F0"
+let s:nord6_gui = "#ECEFF4"
+let s:nord7_gui = "#8FBCBB"
+let s:nord8_gui = "#88C0D0"
+let s:nord9_gui = "#81A1C1"
+let s:nord10_gui = "#5E81AC"
+let s:nord11_gui = "#BF616A"
+let s:nord12_gui = "#D08770"
+let s:nord13_gui = "#EBCB8B"
+let s:nord14_gui = "#A3BE8C"
+let s:nord15_gui = "#B48EAD"
+
+let s:nord0_term = "NONE"
+let s:nord1_term = "0"
+let s:nord2_term = "NONE"
+let s:nord4_term = "NONE"
+let s:nord11_term = "1"
+let s:nord14_term = "2"
+let s:nord13_term = "3"
+let s:nord9_term = "4"
+let s:nord15_term = "5"
+let s:nord8_term = "6"
+let s:nord5_term = "7"
+let s:nord3_term = "8"
+let s:nord12_term = "11"
+let s:nord10_term = "12"
+let s:nord7_term = "14"
+let s:nord6_term = "15"
+
+let s:NMain = [s:nord1_gui, s:nord8_gui, s:nord1_term, s:nord8_term]
+let s:NRight = [s:nord1_gui, s:nord9_gui, s:nord1_term, s:nord9_term]
+let s:NMiddle = [s:nord5_gui, s:nord3_gui, s:nord5_term, s:nord3_term]
+let s:NWarn = [s:nord1_gui, s:nord13_gui, s:nord3_term, s:nord13_term]
+let s:NError = [s:nord0_gui, s:nord11_gui, s:nord1_term, s:nord11_term]
+let g:airline#themes#nord#palette.normal = airline#themes#generate_color_map(s:NMain, s:NRight, s:NMiddle)
+let g:airline#themes#nord#palette.normal.airline_warning = s:NWarn
+let g:airline#themes#nord#palette.normal.airline_error = s:NError
+
+let s:IMain = [s:nord1_gui, s:nord14_gui, s:nord1_term, s:nord6_term]
+let s:IRight = [s:nord1_gui, s:nord9_gui, s:nord1_term, s:nord9_term]
+let s:IMiddle = [s:nord5_gui, s:nord3_gui, s:nord5_term, s:nord3_term]
+let s:IWarn = [s:nord1_gui, s:nord13_gui, s:nord3_term, s:nord13_term]
+let s:IError = [s:nord0_gui, s:nord11_gui, s:nord1_term, s:nord11_term]
+let g:airline#themes#nord#palette.insert = airline#themes#generate_color_map(s:IMain, s:IRight, s:IMiddle)
+let g:airline#themes#nord#palette.insert.airline_warning = s:IWarn
+let g:airline#themes#nord#palette.insert.airline_error = s:IError
+
+let s:RMain = [s:nord1_gui, s:nord14_gui, s:nord1_term, s:nord14_term]
+let s:RRight = [s:nord1_gui, s:nord9_gui, s:nord1_term, s:nord9_term]
+let s:RMiddle = [s:nord5_gui, s:nord3_gui, s:nord5_term, s:nord3_term]
+let s:RWarn = [s:nord1_gui, s:nord13_gui, s:nord3_term, s:nord13_term]
+let s:RError = [s:nord0_gui, s:nord11_gui, s:nord1_term, s:nord11_term]
+let g:airline#themes#nord#palette.replace = airline#themes#generate_color_map(s:RMain, s:RRight, s:RMiddle)
+let g:airline#themes#nord#palette.replace.airline_warning = s:RWarn
+let g:airline#themes#nord#palette.replace.airline_error = s:RError
+
+let s:VMain = [s:nord1_gui, s:nord7_gui, s:nord1_term, s:nord7_term]
+let s:VRight = [s:nord1_gui, s:nord9_gui, s:nord1_term, s:nord9_term]
+let s:VMiddle = [s:nord5_gui, s:nord3_gui, s:nord5_term, s:nord3_term]
+let s:VWarn = [s:nord1_gui, s:nord13_gui, s:nord3_term, s:nord13_term]
+let s:VError = [s:nord0_gui, s:nord11_gui, s:nord1_term, s:nord11_term]
+let g:airline#themes#nord#palette.visual = airline#themes#generate_color_map(s:VMain, s:VRight, s:VMiddle)
+let g:airline#themes#nord#palette.visual.airline_warning = s:VWarn
+let g:airline#themes#nord#palette.visual.airline_error = s:VError
+
+let s:IAMain = [s:nord5_gui, s:nord3_gui, s:nord5_term, s:nord3_term]
+let s:IARight = [s:nord5_gui, s:nord3_gui, s:nord5_term, s:nord3_term]
+if g:nord_uniform_status_lines == 0
+ let s:IAMiddle = [s:nord5_gui, s:nord1_gui, s:nord5_term, s:nord1_term]
+else
+ let s:IAMiddle = [s:nord5_gui, s:nord3_gui, s:nord5_term, s:nord3_term]
+endif
+let s:IAWarn = [s:nord1_gui, s:nord13_gui, s:nord3_term, s:nord13_term]
+let s:IAError = [s:nord0_gui, s:nord11_gui, s:nord1_term, s:nord11_term]
+let g:airline#themes#nord#palette.inactive = airline#themes#generate_color_map(s:IAMain, s:IARight, s:IAMiddle)
+let g:airline#themes#nord#palette.inactive.airline_warning = s:IAWarn
+let g:airline#themes#nord#palette.inactive.airline_error = s:IAError
+
+let g:airline#themes#nord#palette.normal.airline_term = s:NMiddle
+let g:airline#themes#nord#palette.insert.airline_term = s:IMiddle
+let g:airline#themes#nord#palette.replace.airline_term = s:RMiddle
+let g:airline#themes#nord#palette.visual.airline_term = s:VMiddle
+let g:airline#themes#nord#palette.inactive.airline_term = s:IAMiddle
diff --git a/vim/.config/vim/plugged/nord-vim/autoload/lightline/colorscheme/nord.vim b/vim/.config/vim/plugged/nord-vim/autoload/lightline/colorscheme/nord.vim
new file mode 100755
index 0000000..b51cca6
--- /dev/null
+++ b/vim/.config/vim/plugged/nord-vim/autoload/lightline/colorscheme/nord.vim
@@ -0,0 +1,43 @@
+" Copyright (c) 2016-present Sven Greb
+" This source code is licensed under the MIT license found in the license file.
+
+let s:nord_vim_version="0.19.0"
+let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
+
+let s:nord0 = ["#2E3440", "NONE"]
+let s:nord1 = ["#3B4252", 0]
+let s:nord2 = ["#434C5E", "NONE"]
+let s:nord3 = ["#4C566A", 8]
+let s:nord4 = ["#D8DEE9", "NONE"]
+let s:nord5 = ["#E5E9F0", 7]
+let s:nord6 = ["#ECEFF4", 15]
+let s:nord7 = ["#8FBCBB", 14]
+let s:nord8 = ["#88C0D0", 6]
+let s:nord9 = ["#81A1C1", 4]
+let s:nord10 = ["#5E81AC", 12]
+let s:nord11 = ["#BF616A", 1]
+let s:nord12 = ["#D08770", 11]
+let s:nord13 = ["#EBCB8B", 3]
+let s:nord14 = ["#A3BE8C", 2]
+let s:nord15 = ["#B48EAD", 5]
+
+let s:p.normal.left = [ [ s:nord1, s:nord8 ], [ s:nord5, s:nord1 ] ]
+let s:p.normal.middle = [ [ s:nord5, s:nord3 ] ]
+let s:p.normal.right = [ [ s:nord5, s:nord1 ], [ s:nord5, s:nord1 ] ]
+let s:p.normal.warning = [ [ s:nord1, s:nord13 ] ]
+let s:p.normal.error = [ [ s:nord1, s:nord11 ] ]
+
+let s:p.inactive.left = [ [ s:nord1, s:nord8 ], [ s:nord5, s:nord1 ] ]
+let s:p.inactive.middle = g:nord_uniform_status_lines == 0 ? [ [ s:nord5, s:nord1 ] ] : [ [ s:nord5, s:nord3 ] ]
+let s:p.inactive.right = [ [ s:nord5, s:nord1 ], [ s:nord5, s:nord1 ] ]
+
+let s:p.insert.left = [ [ s:nord1, s:nord6 ], [ s:nord5, s:nord1 ] ]
+let s:p.replace.left = [ [ s:nord1, s:nord13 ], [ s:nord5, s:nord1 ] ]
+let s:p.visual.left = [ [ s:nord1, s:nord7 ], [ s:nord5, s:nord1 ] ]
+
+let s:p.tabline.left = [ [ s:nord5, s:nord3 ] ]
+let s:p.tabline.middle = [ [ s:nord5, s:nord3 ] ]
+let s:p.tabline.right = [ [ s:nord5, s:nord3 ] ]
+let s:p.tabline.tabsel = [ [ s:nord1, s:nord8 ] ]
+
+let g:lightline#colorscheme#nord#palette = lightline#colorscheme#flatten(s:p)
diff --git a/vim/.config/vim/plugged/nord-vim/changelog.md b/vim/.config/vim/plugged/nord-vim/changelog.md
new file mode 100644
index 0000000..d9fae38
--- /dev/null
+++ b/vim/.config/vim/plugged/nord-vim/changelog.md
@@ -0,0 +1,1261 @@
+
+ Changelog for Nord Vim — An arctic, north-bluish clean and elegant Vim color theme.
+
+
+
+
+# 0.19.0
+
+ [](https://github.com/orgs/nordtheme/projects/1/views/10) [](https://github.com/nordtheme/vim/milestone/21)
+
+⇅ [Show all commits][111]
+
+## Features
+
+### Syntax
+
+
+Support for LSP textDocument/documentHighlight — #284 (⊶ 3e4e273d) by @cmoscofian
+
+↠ The [Neovim LSP `textDocument` / `documentHightlight` groups][114] are responsible to highlight tokens in a document that are related to each
+other, e.g. declared variables, using the `vim.buf.lsp.document_highlight()` function.
+Also see the [LSP specification about "Document Highlights Request"][115] for more details.
+
+
+
+
+
+
+
+### UI
+
+
+Support for LSP LSPSignatureActiveParameter — #286 (⊶ a8256787) by @cmoscofian
+
+↠ The [`vim.lsp.buf.signature_help` function is used to highlight the active parameter in the signature help][117] [1]. Before the active parameter was not styled differently to any other parameter which made it hard to distinguish it. This has been improved by adding support for the `LspSignatureActiveParameter` syntax highlighting group where the active parameter now uses `nord8` are foreground color and additionally a font underline with the same color.
+
+
Before
+
+
+
After
+
+
+
+
+## Improvements
+
+
+Refactored theme configuration conditions — #295, #305 (⊶ 291e05d9, e3eb2084) by @jvoisin and @svengreb
+
+↠ The conditions and default values of the theme configurations were quite verbose so this commit improves them by…
+
+- …using inline ternary operators instead of if/else blocks to reduce the code overhead and make it way more readable.
+- …using [Vim builtin `get` function][118] instead of if/else blocks.
+- …inlining the script-scoped `logWarning` function since it was only used once.
+- …grouping some blocks where it made sense.
+
+
+
+
+Only call execute function once per syntax group — #303 (⊶ 77fe4b3f) by @jvoisin and @svengreb
+
+↠ Before the custom `s:hi` function called [Vim's `execute` function][119] for each defined attribute which is quite expensive in terms of performance. To improve this the attributes are now concatenate as string and passed to `exec` at the end of the function instead.
+
+
+
+### Syntax
+
+
+Readability of C language constants — #283 (⊶ b32592eb) by @jvoisin
+
+↠ To improve the readability of C language constants, defined by [the `cConstant` syntax highlighting group][116], these are now colored with `nord9` for the foreground to make them stand out. This is important in C, since interesting things are usually happening in their proximity, like checking/returning an error, passing particular values/flags to functions and so on.
+
+
Before
+
+
+
After
+
+
+
+
+## Tasks
+
+
+Support for Neovim0.6.0 diagnostic API highlight groups — #282 (⊶ 8035ba07) by @jan-xyz
+
+↠ In [Neovim `0.6.0`][112] the [naming scheme for the highlight groups of the diagnostic API changed][113] [2]. The new groups have been added as default while the previous groups are conditionally guarded when using Neovim `0.5.0`.
+
+
+
+# 0.18.0
+
+ [](https://github.com/nordtheme/vim/projects/24) [](https://github.com/nordtheme/vim/milestone/20)
+
+⇅ [Show all commits][106]
+
+## Features
+
+### Syntax
+
+
+Support for vim-pandoc/vim-pandoc-syntax — #220 (⊶ 8d8b9bf8) by @tpoisot and @BirgerNi
+
+↠ To improve syntax highlighting for [Pandoc][9], support for the [vim-pandoc/vim-pandoc-syntax][13] plugin has been implemented.
+Most groups are linked to existing Markdown groups to ensure a consistent style across languages and different plugins.
+
+
+
+
+
+### UI
+
+
+Support for LSP code lenses — #266 (⊶ 02ddfadb) by @jan-xyz
+
+↠ Before [LSP code lenses][107] were highlighted with the default color which has been changed to make it less visually intrusive, like other UI related elements, e.g. messages of linters.
+
+
Before
+
+
+
After
+
+
+
+
+## Improvements
+
+### Syntax
+
+
+Prevent aggressive error highlighting — #269 ⇄ #270 (⊶ e3e8a75c) by @jan-xyz
+
+↠ The `TSError` group is used to [highlight syntax/parser errors][108] which caused an aggressive styling where the background color of many syntax elements was rendered with `nord11` during typing. This is a known problem and was fixed by many other themes by removing the group again. One of the [core maintainers of `nvim-treesitter` provided a solution by remapping groups][110] and also mentioned that the group is [styled by the `nvim-treesitter` plugin but the active theme][109].
+
+Syntax errors can still be highlighted through linters and parsers like [Neovim's LSP][8] can still be used instead to highlight errors with the correct style, e.g. only change the foreground color of a single word.
+
+
Before
+
+
+
After
+
+
+
+
+# 0.17.0
+
+ [](https://github.com/nordtheme/vim/projects/23) [](https://github.com/nordtheme/vim/milestone/19)
+
+⇅ [Show all commits][101]
+
+## Features
+
+### Syntax
+
+
+Support for nvim-treesitter/nvim-treesitter — #235 ⇄ #253 (⊶ b3e712a9) by @s-u-d-o-e-r and @mrswats
+
+↠ Neovim [version 0.5][102] is a long-time awaited update that introduces features like support for [tree-sitter][105] via [nvim-treesitter][104] and [LSP][7] via [nvim-lspconfig][8].
+Even though Neovim divides more and more from Vim through specific features like first-class Lua support with custom APIs, the highlighting for tree-sitter is achieved through “normal“ syntax highlighting groups. Most of the groups are already [linked by the `nvim-treesitter` plugin by default][103] so only a few groups have been adjusted for now to fit the Nord style.
+
+⚠️ Note that this is the first iteration and **it is very likely that there will be inconsistencies compared to the current highlighting when using “normal“ Vim plugins per language**. Please **report any problem** you find so that the support for tree-sitter can be improved continuously!
+
+
+
+# 0.16.0
+
+ [](https://github.com/nordtheme/vim/projects/22) [](https://github.com/nordtheme/vim/milestone/18)
+
+⇅ [Show all commits][88]
+
+## Features
+
+### API
+
+
+Public API function NordPalette to get Nord colors — #224 (⊶ 5867535c) by @jandamm
+
+↠ Implemented a new `NordPalette` pubic API function that returns all [Nord colors][87] as dictionary. This allows to use the colors in other Vim scripts without the need to copy & paste the colors from the documentations or the [Nord Vim theme sources][85].
+
+
+
+### Syntax
+
+
+Support for the php.vim plugin — #218, #262 ⇄ #263 (⊶ b3c46c87, 07452c71) by @pirey
+
+↠ In [nordtheme/vim#218][84] new highlighting groups for the bundled PHP syntax were added to improve the highlighting of classes, function and methods and the overall syntax token detection, but they are actually defined by the [php.vim][98] plugin. Therefore the added highlighting calls have been moved to a plugin section.
+Additionally, the `phpClassExtends` and `phpClassImplements` groups have been added to improve the highlighting for classes that implement or extended interfaces/classes. The `phpUseClass` has also been added to improve the highlighting for imports.
+
+To improve the highlighting with the bundled PHP syntax, the [following options][99] can be set:
+
+```vim
+let php_asp_tags = 1
+let php_baselib = 1
+let php_htmlInStrings = 1
+let php_parent_error_close = 1
+let php_parent_error_open = 1
+```
+
+
Before
+
+
+
After
+
+
+
+
+
+Conceal highlighting group support — #149, #207, #211, #256 ⇄ #261 (⊶ f3f28b93)
+
+↠ The `Conceal` group is was not supported which could resulted in rendering problems for (Unicode) characters that require special encoding like the ones from the [Greek alphabet][100] and [mathematical expressions][97] that are often used in [LaTeX][92] or [Pandoc][9] documents. These characters were highlighted with the default background color which made them kind of unreadable with the theme foreground color.
+See `:help conceal` and `:help concealcursor` for more details about concealing in Vim.
+
+To fix the problem, the `Conceal` group has been added with its background color set to `NONE` for GUI and terminal mode to either use the terminal default background color or let loaded scripts apply custom styles based on the current runtime context.
+
+The problem has been reported in #149, #207 and #211 with LaTeX and Pandoc being used by the reporters. PR #220 adds support for [vim-pandoc/vim-pandoc-syntax][13] specific highlighting groups and can be merged after adding basic support for `Conceal`.
+
+To get the correct rendering for such elements the following configurations must be set:
+
+```vim
+let g:pandoc#syntax#conceal#use = 1
+set conceallevel=2
+```
+
+
Before
+
+
+
After
+
+
+
+
+
+Updated highlights for Neovim LSP diagnostics — #229, #248 (⊶ a3af928a) by @gbrlsnchs and @thallium
+
+↠ To ensure compatibility with the latest versions of Neovim LSP the highlighting groups for diagnostics have been adapted to the changes of [neovim/neovim#12655][96].
+See [`:help lsp-highlight-diagnostics`][7] for more details.
+
+Note that LSP will be available as of [Neovim 0.5][95] which is (at the time of this commit) still in development and only available as nightly build.
+Also see great articles from Nord Vim contributors like [“Neovim (0.5) Is Overpowering“][86] for more information about Neovim 0.5 features, including LSP.
+
+Thanks to [@clason][89], [@crispgm][90] and [@ojroques][91] for the review support!
+
+
+
+### UI
+
+
+Support for the vim-indent-guides plugin — #186 ⇄ #226 (⊶ ea7ff9c3) by @mitinarseny
+
+↠ Added support for the [vim-indent-guides][93] plugin. The even and odd highlighting blocks using `nord1` and `nord2` (`nord3`in terminal mode) to provide a subtle and non-disturbing style.
+Note that the [custom theme colors][94] are only applied when the `indent_guides_auto_colors` variable has been set to `0`:
+
+```vim
+let g:indent_guides_auto_colors = 0
+```
+
+
Before
+
+
+
After
+
+
+
+
+## Improvements
+
+### UI
+
+
+coc.vim error and warning highlighting — #213 (⊶ 8a9754ce) by @butterywombat
+
+↠ Added the [coc.nvim][6] highlighting groups for errors and warnings using their respective foreground colors and the `undercurl` font style.
+
+
+
+## Bug Fixes
+
+### UI
+
+
+Typo in group Pmenu group names — #252 (⊶ e5a54c7f) by @kunzaatko
+
+↠ Fixed two typos in `Pmenu` group names:
+
+- `PMenuSel` -> `PmenuSel`
+- `PMenu` -> `Pmenu`
+
+This mismatch was never really noticed because most of the time users rely on plugins like [coc.vim][6] or [vim-clap][5] which come with custom highlighting groups and UI libraries.
+
+
+
+# 0.15.0
+
+ [](https://github.com/nordtheme/vim/projects/21) [](https://github.com/nordtheme/vim/milestone/17)
+
+## Features
+
+### Syntax
+
+**Extended support for TypeScript and TSX** — #208 (⊶ 1bd44ade) by [@iamdidev][78]
+↠ Added extended support for [TypeScript][83] and [TSX][82] through the [yats.vim][80] plugin.
+This provides, among many other good changes, better highlighting for syntax elements like [decorators][81], more granular separation of different language elements within a single code line as well as highlighting for…
+
+
…interfaces with bold font style, typing characters and types.
+
+
+
…global methods like setTimeout with italic font style.
+
+
+
…regular expressions with nord13 instead of the normal color for quoted strings.
+
+
+
…global elements like Error, JSON and console.
+
+
+
…brackets of types as structural elements.
+
+
+
…TSX/JSX and HTML with a consistent appearance.
+
+
+### UI
+
+**Support for vim-clap** — #178 (⊶ 7a52f66c) by [@meck][44] and [@ikalnytskyi][79]
+↠ Added basic support for [vim-clap][5], a modern and performant generic finder and dispatcher for Vim and NeoVim.
+
+
+
+# 0.14.0
+
+ [](https://github.com/nordtheme/vim/projects/20) [](https://github.com/nordtheme/vim/milestone/16)
+
+## Features
+
+### UI
+
+**Basic support for nvim-lsp (Language Server Protocol)** — #198 (⊶ 0ccf70b6) by [@alexanderjeurissen][74]
+↠ Added basic support for [nvim-lsp][76], a collection of common configurations for the NVim language server protocol client.
+
+## Improvements
+
+### UI
+
+**Consistent error highlighting between GUI and terminal mode** — #202 (⊶ 974a9190) by [@xulongwu4][75]
+↠ The highlighting of errors in GUI and _true color_ terminal mode now also uses `nord4` as foreground color of instead of `nord0`.
+
+
Before
+
+
After
+
+
+**Improved highlighting for “More“ separator** — #202 (⊶ 974a9190) by [@xulongwu4][75]
+↠ The highlighting of the _More_ separator is now highlighted with the `nord8` accent color.
+
+
Before
+
+
After
+
+
+**Transparent line number and cursor line background by default** — #204 (⊶ 6323f662) by [@xulongwu4][75]
+↠ Before the background color of the `LineNr` and `CursorLineNr` highlighting groups were set to `nord0` which was fine in most cases, but conflicted with plugins like [Yggdroot/LeaderF][77] that renders line numbers in a popup windows with a different background color.
+
+
Before
+
+
After
+
+
+# 0.13.0
+
+ [](https://github.com/nordtheme/vim/projects/19) [](https://github.com/nordtheme/vim/milestone/15)
+
+## Features
+
+### UI
+
+**Support uniform status line background configuration for _vim-airline_ and _lightline.vim_ themes** — #168 ⇄ #169 (⊶ 73b3d340) by [@jmurinello][66]
+↠ Added support for the [uniform status line][73] theme configuration, [introduced in version 0.7.0][63] through [nordtheme/vim#58][62], for the bundled _vim-airline_ and _lightline.vim_ themes.
+
+
lightline.vim
+
Before
+
+
After
+
+
+
vim-airline
+
Before
+
+
After
+
+
+**Basic support for coc.vim (Conquer of Completion)** — #164 (⊶ a7797269) by [@hennessey][65]
+↠ Added basic support for [coc.nvim][6], a _Intellisense_ engine for Vim 8 & NeoVim with full language server protocol support.
+
+**Basic support for _vim-startify_** — #159 ⇄ #176 (⊶ 38ab4a9c)
+↠ Added basic support for [vim-startify][69] with custom highlight groups.
+
+
+
+## Improvements
+
+### UI
+
+**No underlined style for gutter line numbers** — #174 ⇄ #185 (⊶ 0d352c4b) by [@nixtrace][67] and [@alexandremjacques][64]
+↠ [Vim version 8.1.2029][71] added the [`underline` attribute for the `CursorLineNr` group to `cterm`][70] based on [vim/vim#4933][72].
+This change resulted in gutter line numbers being underlined which has now been reverted back to Nord's style by explicitly setting the attribute for the group to `NONE`.
+
+
Before
+
+
+
After
+
+
+## Bug Fixes
+
+### Documentation
+
+**Fix missing whitespace** — #165 (⊶ 81d80e4a) by [@vasilescur][68]
+↠ Fixed a missing whitespace in the README project description.
+
+# 0.12.0
+
+ [](https://github.com/nordtheme/vim/projects/18) [](https://github.com/nordtheme/vim/milestone/14)
+
+## Features
+
+**Nord Docs Transition** — #158, #144 ⇄ #160 (⊶ 7be26147)
+↠ Transferred all documentations, assets and from „Nord Vim“ to [Nord Docs][1]
+Please see the [corresponding issue in the Nord Docs repository][60] to get an overview of what has changed for Nord Vim and what has been done to migrate to Nord Docs.
+
+###### Landing Page
+
+
+
+###### Landing Page Docs
+
+
+
+###### Installation & Activation Docs
+
+
+
+###### Configuration Docs
+
+
+
+###### Customization Docs
+
+
+
+**Theme configuration for bold font style rendering** — #143 ⇄ #161 (⊶ 18a4e350) requested by [@tobydeh][59]
+↠ Added a new [`nord_bold` theme configuration to allow to explicitly toggle bold font rendering styles][61].
+It is enabled by default when running for both in GUI and terminal mode since most terminals and shells are capable to handle bold fonts.
+
+
+
+## Improvements
+
+**Active match for increment search** — #139 ⇄ #140 (⊶ de24841a) by [@aborzunov][58]
+↠ The currently active match during increment searches (`IncSearch`) is now highlighted differently (`nord10` as background and `nord6` as foreground) than inactive matches for a better visual distinction.
+
+
+
+# 0.11.0
+
+ [](https://github.com/nordtheme/vim/projects/16) [](https://github.com/nordtheme/vim/milestone/13)
+
+## Features
+
+### Syntax
+
+**Basic support for Asciidoc syntax highlighting** — #131 ⇄ #152 (⊶ 6e6025b9) by [@tidux][46]
+↠ Added basic syntax highlighting support for [Asciidoc][39] that comes bundled with Vim 8.
+
+
+
+**Basic syntax highlighting support for Rust** — #138 ⇄ #154 (⊶ b0ffc6b5) by [@TerminalWitchcraft][45]
+↠ Added basic syntax highlighting support for [Rust][55].
+
+[Traits][54] and [enums][51] are colorized with `nord7` and with bold font to make them visually stand out more.
+Also [attributes][49] and [derives][50] are colored with `nord10`.
+
+
Before
+
+
After
+
+[Macros][53] are colorized with `nord8` and bold font to make them visually different from "normal" functions.
+
+
Before
+
+
After
+
+[Escape][52] sequences are colored with `nord13`.
+
+
Before
+
+
After
+
+Import statements and paths are correctly colored with keyword and type colors.
+
+
Before
+
+
After
+
+#### Plugin Support
+
+**Haskell Syntax Plugin Support** — #104 ⇄ #150 (⊶ b0ffc6b5) by [@vabatta][47]
+↠ Added support for Haskell syntax through the [neovimhaskell/haskell-vim][48] plugin.
+This includes better coloring for types/classes using `nord7` instead of highlighting them like keywords (`nord9`) and pre-processor and pragma elements are now colorized correctly with `nord10`.
+
+#### Pragma
+
+
Before
+
+
After
+
+#### Pre-Processor
+
+
Before
+
+
After
+
+#### Types/Classes
+
+
Before
+
+
After
+
+### UI
+
+**Theme config for bolder vertical split line** — #132 ⇄ #153 (⊶ 9059d7d8) by [@huyvohcmc][42]
+↠ Previously the [`VertSplit`][57] (`:help VertSplit`) key used `nord1` as background color by default making the line appear to be very lumpy. This has now been changed to use `nord0` as background instead to visually merge with the background so only the separator characters are a visual indicator for the split line which makes it look more lightweight and declutters the overall appearance.
+
+
With base editor background (default)
+
+
With enabled bold nord1 background
+
+To allow user who liked the previous implementation to keep the style a new `nord_bold_vertical_split_line` theme config was also added that can be assigned to `1` to achieve the legacy design.
+
+```viml
+let g:nord_bold_vertical_split_line = 1
+```
+
+The README includes information and hints how to change the separator character by customizing Vim's [`fillchars`][56] (`:help fillchars`) variable.
+
+#### Plugin Support
+
+**`:terminal` status line in airline** — #134 (⊶ be815f09) by [@meck][44]
+↠ Added support for Vim's new `:terminal` mode in [airline][4].
+
+
Before: No :terminal support (before)
+
+
After: Support for airline's new _term theme keys
+
+## Improvements
+
+### Syntax
+
+**Better generator expressions in CMake** — #137 ⇄ #151 (⊶ d2774cbb) by [@markand][43]
+↠ [CMake generator expressions][40] are now highlighted using `nord10` as foreground instead of `nord13` as background and `nord0` as foreground.
+
+
Before
+
+
After
+
+### UI
+
+#### Plugin Support
+
+**airline warnings and errors** — #130 (⊶ e85dbe75) by [@axelitus][41]
+↠ Added support for error and warning elements of [airline][4].
+
+
Before
+
+
After
+
+**ALE error and warning support** — #135 (⊶ 9d82b7a1) by [@meck][44]
+↠ Added support highlighting and underlines for [ALE][10] errors and warnings to also align the style with gutter signs.
+
+# 0.10.0
+
+ [](https://github.com/nordtheme/vim/projects/15) [](https://github.com/nordtheme/vim/milestone/12)
+
+## Features
+
+**Vim 8 terminal highlighting** — #125 ⇄ #126 (⊶ 83f8c260) by [@cg433n][38]
+↠ Added support for the Vim's built-in terminal (`:terminal`) that comes with version 8.0.0 and higher.
+
+## Improvements
+
+**Comment Color Brightness** — #145 ⇄ #146 (⊶ 9e0249ca)
+↠ Implemented the increase of the comment color (`nord3`) brightness by 10% from a lightness level of ~35% to ~45%.
+
+➜ **Please see [nordtheme/nord#94][36] for all details about this design change decision**!
+
+⚠ **NOTE**: This change also **deprecates the [comment contrast][11] configuration** that will be removed in Nord Vim version 1.0.0!
+The default comment color has been adjusted so the configuration is not required anymore for users to increase the brightness on their own.
+To notify users about this change a deprecation warning will be shown when the `g:nord_comment_brightness` configuration variable has been set and initialized through the user's configuration.
+
+**Improved compatibility of airline with tmuxline.vim plugin** — #117 ⇄ #128 (⊶ 3150628f)
+↠ The [Nord airline.vim][4] UI plugin theme now includes better support for the [tmuxline.vim][37] plugin. Previously text shown in the main segment of the _tmuxline_, generated via the `:Tmuxline airline` command, caused a `bad colour: NONE` error or has been colorized using `nord0` which resulted in unreadable text due to a `nord3` background.
+
+This has been fixed by using `nord5` as foreground color. …[#11][34] was used as implementation reference since it fixed the same incompatibility for the [lightline.vim][35] plugin.
+
+
+
+# 0.9.0
+
+ [](https://github.com/nordtheme/vim/projects/13) [](https://github.com/nordtheme/vim/milestone/11)
+
+## Features
+
+### Syntax
+
+#### Plugin Support
+
+❯ Added support for the [YAML][33] plugin [stephpy/vim-yaml][29] which improves the highlighting for keys to match the JSON syntax style. (PR #120, @mdzhang, b1478b07)
+
+
Before
+
+
After
+
+❯ Added basic syntax highlighting support for [vimwiki][30]. (PR #98 in PR #114, @smesko85, 9e7addbc)
+
+
+
+### UI
+
+❯ Added a new [configuration to allow users to enable background for the line number of the current line][31]. It can be enabled by setting the `g:nord_cursor_line_number_background` variable to `1`. (PR #100, @andrepolischuk, 035e36de)
+
+```vim
+let g:nord_cursor_line_number_background = 1
+```
+
+
No background (default)
+
+
Enabled background
+
+❯ Added a new [configuration to allow users to globally toggle underlines][32] for cases where the terminal emulator might not be capable to handle underlines in terminal mode. It can be enabled by setting the `g:nord_underline` variable to `1`. (#106 in PR #127 (supersedes #109), @dylnmc @markand , 01cfd1be)
+
+
Underlined Text
+
+❯ Added support for the status line of the `:terminal` window mode for Vim or Neovim. (PR #108 (supersedes #103), @dylnmc, 922504fb)
+
+
Before
+
+
After
+
+#### Plugin Support
+
+❯ Added highlighting support for the navigation marks in the sign column of the [kshenoy/vim-signature][28] plugin. (PR #122, @kooparse, 1df39453)
+
+
+
+### UI
+
+❯ The cursor is now correctly shown and visible when leaving a terminal window from within Vim or Neovim by adding the `TermCursorNC` group. (PR #101, @meck, 2fac9fa0)
+
+❯ The „inline marker“ in unified _diffs_ is now colorized differently than the background of the changed line to make the changes better and faster recognizable. This applies for both the [uniform _diff_ background mode][12] and normal _diff_ mode. (PR #121, @ironhouzi, 65c559ee)
+
+
Before/After comparison of default diff mode
+
+
Before/After comparison of uniform diff mode
+
+## Bug Fixes
+
+### UI
+
+❯ The current line number's color is now highlighted correctly in terminal mode. Previously it was only highlighted when running in GUI mode or when `termguicolors` has been set. (#116 in 50ec737b (PR #100), @huyvohcmc @dylnmc)
+
+
Before
+
+
After
+
+# 0.8.0
+
+ [](https://github.com/nordtheme/vim/projects/11) [](https://github.com/nordtheme/vim/milestone/10)
+
+## Features
+
+### Plugin Support
+
+#### UI
+
+❯ Added support for [vim-signify][27]. (PR #81, @dabio, edcdd0e4)
+
+
+
+## Improvements
+
+### UI
+
+❯ The color of links in `:help` was the same as normal text making it impossible to to distinguish between both. This has been improved by using `nord8` including the help bars when enabled with `:set conceallevel=2`. (#85 in PR #93, @delphinus, e9974fe6)
+
+
Before
+
+
After
+
+### Documentation
+
+❯ The lightline screenshots in the documentation have been made using the [lightline's advanced configurations][26]. This confused users when the lighline does not equal the one seen on the screenshot due to the default lightline configuration. This has now been clarified including a additional screenshot showing the appearance of the lightline when using the default configuration. (#74 in PR #94, @lokesh-krishna, 3c14c961)
+
+
+
+## Bug Fixes
+
+❯ The background color for matching parens is now assigned to the right color `nord3` instead of `nord0` in GUI mode. (#95 in PR #96, @dylnmc, 8bc1be01)
+
+
Before
+
+
After
+
+# 0.7.0
+
+ [](https://github.com/nordtheme/vim/projects/10) [](https://github.com/nordtheme/vim/milestone/9)
+
+## Features
+
+❯ Added a new [configuration to allow users to increase the comment brightness][11] by 1 - 20 percent. It can be enabled by setting the `g:nord_comment_brightness variable` to a number between `1` and `20`. (#48 in PR #56, @drzel, e18ab4e8)
+
+**This option should only be enabled if the terminal supports 24bit true color (16 million colors) and requires the `termguicolors` option to be set is in `~/.vimrc` or via `:set termguicolors`!**
+
+
Default and 15% increased
+
+
Default and 12% increased
+
+To adhere to the Nord design guidelines this option uses `nord3` by default.
+
+This is a reference table if users like to use the same increased contrast values as provided by the [Nord Atom Syntax accessibility custom comment contrast theme setting][19] which are calculated using the LESSCSS [`lighten`][18] function.
+
+| Increased by | Calculated value |
+| ------------ | ---------------- |
+| 1% | `#4e586d` |
+| 2% | `#505b70` |
+| 3% | `#525d73` |
+| 4% | `#556076` |
+| 5% | `#576279` |
+| 6% | `#59647c` |
+| 7% | `#5b677f` |
+| 8% | `#5d6982` |
+| 9% | `#5f6c85` |
+| 10% | `#616e88` |
+| 11% | `#63718b` |
+| 12% | `#66738e` |
+| 13% | `#687591` |
+| 14% | `#6a7894` |
+| 15% | `#6d7a96` |
+| 16% | `#6f7d98` |
+| 17% | `#72809a` |
+| 18% | `#75829c` |
+| 19% | `#78859e` |
+| 20% | `#7b88a1` |
+
+More information about true color and the support in various terminals can be found in [this gist][16].
+
+❯ Added a new [configuration for a uniform _diff_ background color][12]. (#60 in PR #61 #62 #65, @dylnmc @aidanharris @berkin, 958322d0)
+
+
+
+Setting `g:nord_uniform_diff_background` to `1` enables the uniform diff background using `nord1`:
+
+
+
+❯ Added a new [configuration to use uniform activate- and inactive status line backgrounds][24]. (#37 in PR #58, @dylnmc @DenniJensen, 93056802)
+
+
Default status lines
+
+
Uniform status lines
+
+❯ Added a new [configuration to explicitly enable italic text formatting][23]. (#88 in PR #89, @lokesh-krishna @dylnmc, dbfc55ff)
+
+**Please note that this option should only be enabled if the used terminal supports italics!**
+
+
With enabled option for italic comments
+
+
Markdown syntax styling
+
+❯ Added support for NeoVim UI terminal colors. (#63, @meck, af01167b)
+
+### Plugin Support
+
+#### Syntax
+
+❯ Added support for the [plasticboy/vim-markdown][21] syntax plugin to match the style of the built-in markdown syntax styles. (#45 in PR #57, @VVVFO, 09921268)
+
+
+
+
+
+#### UI
+
+❯ Added support for the `PlugClean` command of the [junegunn/vim-plug][20] plugin which used the `Ignore` group by default for deleted directory listings resulting in unreadable text when `cursorline` has been set. (#43 in PR #59, @dylnmc, e532b5d6)
+
+
Before
+
+
After
+
+❯ Added basic support for [tpope/vim-fugitive][22]. (#76 in PR #77, @anhari, fa09c3b1)
+
+Filenames are now highlighted when using the `:Gstatus` command.
+
+
+
+## Improvements
+
+### Syntax
+
+❯ Added highlight support for legacy _diff_ groups `diffAdded` and `diffRemoved` of the `git.vim` and `diff.vim` syntx definitions. (#66 in PR #67, @brandoniffert, 99e59e67)
+
+These groups are not in the [official vim documentation][25] but are still used by the syntax for example when run with `git commit --verbose`.
+
+
Before
+
+
After
+
+❯ Added highlighting support for Markdown _italic_ and **bold** delimiter. (#90 in PR #92, 97c8aa24)
+
+
Before
+
+
After
+
+❯ Added missing Markdown _italic_ and **bold** groups. (#84 in PR #91, @lokesh-krishna @dylnmc, 63b46125)
+
+❯ Improved the highlighting for matching parens. (#75 and #71 in PR #78, @vincentzhezhang @cryptomaniac512 @dylnmc, 8eb7b2a6)
+
+The background color intensity under the cursor was too bright and the cursor no more visible causing the user to be distracted to focus on the matching bracket instead of the bracket at the cursor position.
+
+To optimally improve the highlighting `nord3` will now be used as background color for the matching element which doesn't conflict with the `cursorline` color and also stands out in order to see the matching element.
+
+
Before
+
+
After with cursorline option
+
+
After without cursorline option
+
+
+
+## Bug Fixes
+
+❯ _TODO_ keywords are now highlighted correctly for Neovim and gVim (#52 in PR #53, @dylnmc, 063620f0)
+
+
+
+❯ Fixed the `WildMenu` background color for current selection (tab completion) not being visible. (#64 in PR #80, @markand, 53fce0db)
+
+
Before
+
+
After
+
+## Tasks
+
+❯ Added the included [lightline theme to the official lightline repository][17]. (#68 in [itchyny/lightline#257][17], @lokesh-krishna, itchyny/lightline@e69081c1370a57647e05df21b60a4ef092c3ce91)
+
+### Documentation
+
+❯ Migrated to the MIT license to adapt to the migration of the main [Nord][3] project. Detailed information can be found in the [main task ticket][15]. (#69 in PR #70, fa55dc35)
+
+# 0.6.0
+
+ [](https://github.com/nordtheme/vim/projects/9) [](https://github.com/nordtheme/vim/milestone/8)
+
+## Features
+
+### Plugin Support
+
+#### UI
+
+❯ Added basic support for [CtrlP][14]. (PR #33, @syedelec)
+
+- Matched characters are using the keyword color instead of the normal text color to make matched characters visible
+- Already opened buffers now take the normal text color instead of the comment color
+
+❯ Added basic support [ALE][10]. (PR #44, @meck)
+
+- Warning signs are colorized using a `nord13` foreground
+- Error signs are colorized using a `nord11` foreground instead of a red background with a white foreground
+
+## Improvements
+
+### UI
+
+❯ The fold marker foreground has been adjusted to match the comment color instead of `nord1` which has been too dark causing them to be unreadable in bright environments. The background color has also been changed to `nord1` to differ from normal comments and the font style is now bold for better legibility. (#38 in PR #40, @dylnmc)
+
+
+
+❯ The highlight text of a active substitute search result is now underlined in order to make it more recognizable. (#35 in PR #41, @KevinSjoberg)
+
+
+
+#### Neovim
+
+❯ Addded support for the Neovim specific `:CheckHealth` status highlight groups. (#31 in PR #42, @syedelec, Thanks to @dylnmc)
+
+
Before After
+
+## Bug Fixes
+
+### UI
+
+❯ Fixed unreadable text color on pending search result highlights. (#32 in PR #39, @syedelec)
+
+
Before After
+
+# 0.5.0
+
+ [](https://github.com/nordtheme/vim/projects/8) [](https://github.com/nordtheme/vim/milestone/7)
+
+## Improvements
+
+### Language Support
+
+❯ Implemented optimized styles for Ruby (@hahuang65, #29, 085c1337)
+
+- Symbols (`rubySymbol`) now have a bold font style
+- Block parameter list symbols (`rubyBlockParameterList`) are now colorized as keywords
+- Local (variable) methods (`rubyLocalVariableOrMethod`) are now colorized as methods
+
+
+
+## Bug Fixes
+
+### Documentation
+
+❯ Fixed a typo in the project description. (@svengreb, #28, b2134029)
+
+# 0.4.0
+
+ [](https://github.com/nordtheme/vim/projects/7) [](https://github.com/nordtheme/vim/milestone/6)
+
+## Features
+
+### Configurations
+
+❯ Added a configuration to enable [italic comments](https://github.com/nordtheme/vim#italic-comments).
+To adhere to the Nord style guide this option is disabled by default. It can be enabled by setting the `g:nord_italic_comments` variable to `1`.
+
+```vim
+let g:nord_italic_comments = 1
+```
+
+(@kepbod, #13 (PR #16), dc6149f4)
+
+## Improvements
+
+### Plugin Support
+
+❯ The method/function signature live preview of the [`jedi-vim`](https://github.com/davidhalter/jedi-vim) plugin is now colorized correctly. (@mkalinski, #14, a5c3459a)
+
+
Before After
+
+### Language Support
+
+❯ Implemented optimized styles for the Python syntax group `pythonEscape`. (@mkalinski, #22, 360a76ea)
+
+
+❯ Implemented optimized styles for the SQL syntax groups `sqlSpecial` which is now linked to the `sqlKeyword` group to colorize constants like `true`/`false` and `null` as keywords. (@mkalinski, #23, dcfb441e)
+
+### Documentation
+
+❯ Added the new terminal emulator port project [Nord Hyper](https://github.com/arcticicestudio/nord-hyper)
+[](https://github.com/arcticicestudio/nord-hyper)
+
+# 0.3.0
+
+ [](https://github.com/nordtheme/vim/projects/6) [](https://github.com/nordtheme/vim/milestone/5)
+
+## Improvements
+
+### Plugin Support
+
+❯ The [Nord lightline.vim][2] UI plugin theme now includes better support for the [tmuxline.vim](https://github.com/edkolev/tmuxline.vim) plugin. Before this implementation text shown in the main segment of the tmuxline, generated via the `:Tmuxline lightline` command, has been colorized using `nord0` which resulted in unreadable text due to a `nord3` background.
+This has been fixed by using `nord5` as foreground color. (@scottwillmoore, #11, 4ea37f7e)
+
+
Before After With unicode separators Without specified configurations (tmuxline.vim autodetect)
+
+## Bug Fixes
+
+### Documentation
+
+❯ Fixed a typo in the [README installation guide](https://github.com/nordtheme/vim#via-pluginruntimepath-manager) for Vundle. (@kepbod, #10, 29145bbb)
+
+❯ Fixed the banner of the [Nord iTerm2](https://github.com/arcticicestudio/nord-iterm2) port project showing the [Nord GNOME Terminal](https://github.com/arcticicestudio/nord-gnome-terminal) banner instead. (@shvetsovdm, #8 / [nord/#9](https://github.com/nordthenme/nord/issues/9), 7a447b40)
+
+# 0.2.0
+
+ [](https://github.com/nordtheme/vim/projects/5) [](https://github.com/nordtheme/vim/milestone/4)
+
+## Improvements
+
+❯ Characters under block cursors are now colored darker (`nord0`) while the block cursor is visible to achieve a optimal contrast and to avoid unreadability due to the same cursor- and foreground color (`nord4`). (@svengreb / @scottwillmoore, #9, 30e1f7e3)
+
+
Before After
+
+❯ The background color of visual mode selections is now colored in `nord1` instead of `nord3` to avoid a color collision with comments which has led to unreadable text.(@scottwillmoore, #7, bdb209f5)
+
+
Before After
+
+# 0.1.2
+
+_2017-01-01_
+
+ [](https://github.com/nordtheme/vim/projects/4) [](https://github.com/nordtheme/vim/milestone/3)
+
+## Bug Fixes
+
+❯ Fixed a bug where the `g:colors_name` variable has been unset caused by the `syntax reset` call due to the execution
+order. (@shuei72, #5, f8ffce24)
+
+# 0.1.1
+
+ [](https://github.com/nordtheme/vim/projects/3) [](https://github.com/nordtheme/vim/milestone/2)
+
+## Bug Fixes
+
+❯ Fixed wrong color variables (`*_term` to `*_gui`) for the `guisp` attribute of all `Spell*` highlighting groups which caused error logs while loading `vim`/`gvim`/MacVim. (@kamwitsta, #4, 4d642b9b)
+
+# 0.1.0
+
+ [](https://github.com/nordtheme/vim/projects/2) [](https://github.com/nordtheme/vim/milestone/1)
+
+## Features
+
+Detailed information about features, supported plugins/languages and install instructions can be found in the [README](https://github.com/nordtheme/vim/blob/main/readme.md#installation) and in the [project wiki](https://github.com/nordtheme/vim/wiki).
+
+❯ Implemented the main color theme file [`nord.vim`](https://github.com/nordtheme/vim/blob/main/colors/nord.vim). (@svengreb, #1, e2832b9)
+
+
+
+❯ Implemented the [lightline](https://github.com/itchyny/lightline.vim) color scheme file [`nord.vim`](https://github.com/nordtheme/vim/blob/main/autoload/lightline/colorscheme/nord.vim). (@svengreb, #2, f9891ffe)
+
+
+
+❯ Implemented the [airline](https://github.com/vim-airline/vim-airline) color theme file [`nord.vim`](https://github.com/nordtheme/vim/blob/main/autoload/airline/themes/nord.vim). (@svengreb, #3, e54464a7)
+
+
+
+Build for Vim's terminal- and GUI mode with _true colors_ with support for many third-party syntax and UI plugins including bundled themes for [lightline.vim][1] and [vim-airline][4].
+
+## Getting Started
+
+Visit the [official website][23] to learn all about the [syntax highlighting][27] features, details and elements of [UI and editor elements][25], the [various theme configurations][24] and the [support for many plugins][26].
+
+Learn about the [installation and activation][20], how to [configure][18] and [customize][19] the theme from the [official documentations][22].
+
+### Quick Start
+
+Thanks to existing plugin/_runtimepath_ managers for Vim, Nord Vim can be installed for all platforms and the various variants/forks of Vim in a uniform way within a few lines of codes. The recommended manager is [vim-plug][2], but any other manager like [pathogen][3] or [Vundle][5] can also be used.
+
+To automatically download and activate Nord Vim, follow the install instructions for [vim-plug][2] and
+
+1. add `Plug 'nordtheme/vim'` to your [`vimrc`][28] within _vim-plug_'s plugin loading function
+2. run the `:PlugInstall` command in Vim
+3. activate the theme by adding `colorscheme nord` to the [vimrc][28] or change it on-the-fly by running `:colorscheme nord`
+
+
+
+
+
+
+
+See the Nord Vim's documentation for [more installation options][20] and how to [set it up manually][21].
+
+## Features
+
+
+ A unified UI and editor syntax element design provides a clutter-free and fluidly merging appearance.
+
+
+
+
+
+
+ Small details with unobtrusive styles for popular and common code editor features like search result marker and brace matching — designed to get out of your way with a visually attractive appearance.
+
+
+
+
+
+
+ Support for a wide range of programming languages — from bundled plugins up to many popular syntax and UI third-party plugins.
+
+
+
+
+
+## Contributing
+
+Nord is an open source project and we love to receive contributions from the [community][6]!
+
+There are many ways to contribute, from [writing- and improving documentation and tutorials][9], [reporting bugs][8], [submitting enhancement suggestions][10] that can be added to Nord by [submitting pull requests][14].
+
+Please take a moment to read Nord's full [contributing guide][17] to learn about the development process, the project's used [styleguides][15], [branch organization][7] and [versioning][16] model.
+
+The guide also includes information about [minimal, complete, and verifiable examples][13] and other ways to contribute to the project like [improving existing issues][12] and [giving feedback on issues and pull requests][11].
+
+