diff --git a/.gitignore b/.gitignore index b8ea170..67c0fd7 100755 --- a/.gitignore +++ b/.gitignore @@ -2,8 +2,7 @@ .git tmux/.config/tmux/plugins/* -vim/.vim/plugged/* -vim/.vim/undodir/* +vim/ jupyter/.ipython/* jupyter/.jupyter/* diff --git a/skhd/.config/skhd/skhdrc b/skhd/.config/skhd/skhdrc index e51de2a..475d830 100755 --- a/skhd/.config/skhd/skhdrc +++ b/skhd/.config/skhd/skhdrc @@ -81,7 +81,7 @@ shift + alt - 7 : yabai -m window --space 7; ctrl + shift - t : open -a /Applications/WezTerm.app/Contents/MacOS/wezterm ctrl + shift - b : open -an /Applications/Firefox.app/Contents/MacOS/firefox ctrl + shift - v : open -an /Applications/VSCodium.app/Contents/MacOS/Electron -ctrl + shift - m : open -an Mail.app +ctrl + shift - m : open -a Mail.app ctrl + shift - w : open -a /Applications/Bitwarden.app/Contents/MacOS/Bitwarden # stop/start/restart yabai diff --git a/vim/.vim/.netrwhist b/vim/.vim/.netrwhist deleted file mode 100755 index 4d7e55e..0000000 --- a/vim/.vim/.netrwhist +++ /dev/null @@ -1,12 +0,0 @@ -let g:netrw_dirhistmax =10 -let g:netrw_dirhistcnt =1 -let g:netrw_dirhist_1='/Users/jfraeys/.local/bin/scripts' -let g:netrw_dirhist_0='/Users/jfraeys' -let g:netrw_dirhist_9='/Users/jfraeys/.dotfiles/nvim/.config/nvim/lua/custom/plugins' -let g:netrw_dirhist_8='/Users/jfraeys/.dotfiles/nvim/.config/nvim/lua/custom/snippets' -let g:netrw_dirhist_7='/Users/jfraeys/.dotfiles/nvim/.config/nvim/lua/custom' -let g:netrw_dirhist_6='/Users/jfraeys/.dotfiles/nvim/.config/nvim/lua/custom/plugins' -let g:netrw_dirhist_5='/Users/jfraeys/Documents/projects/job-req/resume-recomm/job_req_resume_recomm' -let g:netrw_dirhist_4='/Users/jfraeys/Documents/projects/job-req/resume-recomm' -let g:netrw_dirhist_3='/Users/jfraeys/Documents/projects/job-req/resume-recomm/job_req_resume_recomm' -let g:netrw_dirhist_2='/Users/jeremiefraeys/.ssh' diff --git a/vim/.vim/autoload/plug.vim b/vim/.vim/autoload/plug.vim deleted file mode 100755 index 9c3011f..0000000 --- a/vim/.vim/autoload/plug.vim +++ /dev/null @@ -1,2812 +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 'preservim/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 has('nvim') - let home = stdpath('data') . '/plugged' - 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 get(g:, 'did_load_filetypes', 0) - 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) - 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('.')) - endif - - 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' title - else - execute 'pedit' title - wincmd P - endif - setlocal previewwindow filetype=git buftype=nofile bufhidden=wipe nobuflisted modifiable - let batchfile = '' - try - let [sh, shellcmdflag, shrd] = s:chsh(1) - let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && '.command - 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") && 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) - 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, '\\\@ -" https://github.com/tomasr/molokai -" -" Note: Based on the Monokai theme for TextMate -" by Wimer Hazenberg and its darker variant -" by Hamish Stuart Macpherson -" - -hi clear - -if version > 580 - " no guarantees for version 5.8 and below, but this makes it stop - " complaining - hi clear - if exists("syntax_on") - syntax reset - endif -endif -let g:colors_name="molokai" - -if exists("g:molokai_original") - let s:molokai_original = g:molokai_original -else - let s:molokai_original = 0 -endif - - -hi Boolean guifg=#AE81FF -hi Character guifg=#E6DB74 -hi Number guifg=#AE81FF -hi String guifg=#E6DB74 -hi Conditional guifg=#F92672 gui=bold -hi Constant guifg=#AE81FF gui=bold -hi Cursor guifg=#000000 guibg=#F8F8F0 -hi iCursor guifg=#000000 guibg=#F8F8F0 -hi Debug guifg=#BCA3A3 gui=bold -hi Define guifg=#66D9EF -hi Delimiter guifg=#8F8F8F -hi DiffAdd guibg=#13354A -hi DiffChange guifg=#89807D guibg=#4C4745 -hi DiffDelete guifg=#960050 guibg=#1E0010 -hi DiffText guibg=#4C4745 gui=italic,bold - -hi Directory guifg=#A6E22E gui=bold -hi Error guifg=#E6DB74 guibg=#1E0010 -hi ErrorMsg guifg=#F92672 guibg=#232526 gui=bold -hi Exception guifg=#A6E22E gui=bold -hi Float guifg=#AE81FF -hi FoldColumn guifg=#465457 guibg=#000000 -hi Folded guifg=#465457 guibg=#000000 -hi Function guifg=#A6E22E -hi Identifier guifg=#FD971F -hi Ignore guifg=#808080 guibg=bg -hi IncSearch guifg=#C4BE89 guibg=#000000 - -hi Keyword guifg=#F92672 gui=bold -hi Label guifg=#E6DB74 gui=none -hi Macro guifg=#C4BE89 gui=italic -hi SpecialKey guifg=#66D9EF gui=italic - -hi MatchParen guifg=#000000 guibg=#FD971F gui=bold -hi ModeMsg guifg=#E6DB74 -hi MoreMsg guifg=#E6DB74 -hi Operator guifg=#F92672 - -" complete menu -hi Pmenu guifg=#66D9EF guibg=#000000 -hi PmenuSel guibg=#808080 -hi PmenuSbar guibg=#080808 -hi PmenuThumb guifg=#66D9EF - -hi PreCondit guifg=#A6E22E gui=bold -hi PreProc guifg=#A6E22E -hi Question guifg=#66D9EF -hi Repeat guifg=#F92672 gui=bold -hi Search guifg=#000000 guibg=#FFE792 -" marks -hi SignColumn guifg=#A6E22E guibg=#232526 -hi SpecialChar guifg=#F92672 gui=bold -hi SpecialComment guifg=#7E8E91 gui=bold -hi Special guifg=#66D9EF guibg=bg gui=italic -if has("spell") - hi SpellBad guisp=#FF0000 gui=undercurl - hi SpellCap guisp=#7070F0 gui=undercurl - hi SpellLocal guisp=#70F0F0 gui=undercurl - hi SpellRare guisp=#FFFFFF gui=undercurl -endif -hi Statement guifg=#F92672 gui=bold -hi StatusLine guifg=#455354 guibg=fg -hi StatusLineNC guifg=#808080 guibg=#080808 -hi StorageClass guifg=#FD971F gui=italic -hi Structure guifg=#66D9EF -hi Tag guifg=#F92672 gui=italic -hi Title guifg=#ef5939 -hi Todo guifg=#FFFFFF guibg=bg gui=bold - -hi Typedef guifg=#66D9EF -hi Type guifg=#66D9EF gui=none -hi Underlined guifg=#808080 gui=underline - -hi VertSplit guifg=#808080 guibg=#080808 gui=bold -hi VisualNOS guibg=#403D3D -hi Visual guibg=#403D3D -hi WarningMsg guifg=#FFFFFF guibg=#333333 gui=bold -hi WildMenu guifg=#66D9EF guibg=#000000 - -hi TabLineFill guifg=#1B1D1E guibg=#1B1D1E -hi TabLine guibg=#1B1D1E guifg=#808080 gui=none - -if s:molokai_original == 1 - hi Normal guifg=#F8F8F2 guibg=#272822 - hi Comment guifg=#75715E - hi CursorLine guibg=#3E3D32 - hi CursorLineNr guifg=#FD971F gui=none - hi CursorColumn guibg=#3E3D32 - hi ColorColumn guibg=#3B3A32 - hi LineNr guifg=#BCBCBC guibg=#3B3A32 - hi NonText guifg=#75715E - hi SpecialKey guifg=#75715E -else - hi Normal guifg=#F8F8F2 guibg=#1B1D1E - hi Comment guifg=#7E8E91 - hi CursorLine guibg=#293739 - hi CursorLineNr guifg=#FD971F gui=none - hi CursorColumn guibg=#293739 - hi ColorColumn guibg=#232526 - hi LineNr guifg=#465457 guibg=#232526 - hi NonText guifg=#465457 - hi SpecialKey guifg=#465457 -end - -" -" Support for 256-color terminal -" -if &t_Co > 255 - if s:molokai_original == 1 - hi Normal ctermbg=234 - hi CursorLine ctermbg=235 cterm=none - hi CursorLineNr ctermfg=208 cterm=none - else - hi Normal ctermfg=252 ctermbg=233 - hi CursorLine ctermbg=234 cterm=none - hi CursorLineNr ctermfg=208 cterm=none - endif - hi Boolean ctermfg=135 - hi Character ctermfg=144 - hi Number ctermfg=135 - hi String ctermfg=144 - hi Conditional ctermfg=161 cterm=bold - hi Constant ctermfg=135 cterm=bold - hi Cursor ctermfg=16 ctermbg=253 - hi Debug ctermfg=225 cterm=bold - hi Define ctermfg=81 - hi Delimiter ctermfg=241 - - hi DiffAdd ctermbg=24 - hi DiffChange ctermfg=181 ctermbg=239 - hi DiffDelete ctermfg=162 ctermbg=53 - hi DiffText ctermbg=102 cterm=bold - - hi Directory ctermfg=118 cterm=bold - hi Error ctermfg=219 ctermbg=89 - hi ErrorMsg ctermfg=199 ctermbg=16 cterm=bold - hi Exception ctermfg=118 cterm=bold - hi Float ctermfg=135 - hi FoldColumn ctermfg=67 ctermbg=16 - hi Folded ctermfg=67 ctermbg=16 - hi Function ctermfg=118 - hi Identifier ctermfg=208 cterm=none - hi Ignore ctermfg=244 ctermbg=232 - hi IncSearch ctermfg=193 ctermbg=16 - - hi keyword ctermfg=161 cterm=bold - hi Label ctermfg=229 cterm=none - hi Macro ctermfg=193 - hi SpecialKey ctermfg=81 - - hi MatchParen ctermfg=233 ctermbg=208 cterm=bold - hi ModeMsg ctermfg=229 - hi MoreMsg ctermfg=229 - hi Operator ctermfg=161 - - " complete menu - hi Pmenu ctermfg=81 ctermbg=16 - hi PmenuSel ctermfg=255 ctermbg=242 - hi PmenuSbar ctermbg=232 - hi PmenuThumb ctermfg=81 - - hi PreCondit ctermfg=118 cterm=bold - hi PreProc ctermfg=118 - hi Question ctermfg=81 - hi Repeat ctermfg=161 cterm=bold - hi Search ctermfg=0 ctermbg=222 cterm=NONE - - " marks column - hi SignColumn ctermfg=118 ctermbg=235 - hi SpecialChar ctermfg=161 cterm=bold - hi SpecialComment ctermfg=245 cterm=bold - hi Special ctermfg=81 - if has("spell") - hi SpellBad ctermbg=52 - hi SpellCap ctermbg=17 - hi SpellLocal ctermbg=17 - hi SpellRare ctermfg=none ctermbg=none cterm=reverse - endif - hi Statement ctermfg=161 cterm=bold - hi StatusLine ctermfg=238 ctermbg=253 - hi StatusLineNC ctermfg=244 ctermbg=232 - hi StorageClass ctermfg=208 - hi Structure ctermfg=81 - hi Tag ctermfg=161 - hi Title ctermfg=166 - hi Todo ctermfg=231 ctermbg=232 cterm=bold - - hi Typedef ctermfg=81 - hi Type ctermfg=81 cterm=none - hi Underlined ctermfg=244 cterm=underline - - hi VertSplit ctermfg=244 ctermbg=232 cterm=bold - hi VisualNOS ctermbg=238 - hi Visual ctermbg=235 - hi WarningMsg ctermfg=231 ctermbg=238 cterm=bold - hi WildMenu ctermfg=81 ctermbg=16 - - hi Comment ctermfg=59 - hi CursorColumn ctermbg=236 - hi ColorColumn ctermbg=236 - hi LineNr ctermfg=250 ctermbg=236 - hi NonText ctermfg=59 - - hi SpecialKey ctermfg=59 - - if exists("g:rehash256") && g:rehash256 == 1 - hi Normal ctermfg=252 ctermbg=234 - hi CursorLine ctermbg=236 cterm=none - hi CursorLineNr ctermfg=208 cterm=none - - hi Boolean ctermfg=141 - hi Character ctermfg=222 - hi Number ctermfg=141 - hi String ctermfg=222 - hi Conditional ctermfg=197 cterm=bold - hi Constant ctermfg=141 cterm=bold - - hi DiffDelete ctermfg=125 ctermbg=233 - - hi Directory ctermfg=154 cterm=bold - hi Error ctermfg=222 ctermbg=233 - hi Exception ctermfg=154 cterm=bold - hi Float ctermfg=141 - hi Function ctermfg=154 - hi Identifier ctermfg=208 - - hi Keyword ctermfg=197 cterm=bold - hi Operator ctermfg=197 - hi PreCondit ctermfg=154 cterm=bold - hi PreProc ctermfg=154 - hi Repeat ctermfg=197 cterm=bold - - hi Statement ctermfg=197 cterm=bold - hi Tag ctermfg=197 - hi Title ctermfg=203 - hi Visual ctermbg=238 - - hi Comment ctermfg=244 - hi LineNr ctermfg=239 ctermbg=235 - hi NonText ctermfg=239 - hi SpecialKey ctermfg=239 - endif -end - -" Must be at the end, because of ctermbg=234 bug. -" https://groups.google.com/forum/#!msg/vim_dev/afPqwAFNdrU/nqh6tOM87QUJ -set background=dark diff --git a/vim/.vim/pack/kite/start/vim-plugin/.travis.yml b/vim/.vim/pack/kite/start/vim-plugin/.travis.yml deleted file mode 100755 index 2ab9a27..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/.travis.yml +++ /dev/null @@ -1,36 +0,0 @@ -dist: trusty - -env: - global: - - DEPS=$HOME/deps - - PATH=$DEPS/bin:$PATH - -before_install: - - sudo apt-get install python-pip - - pip install --user awscli - - export PATH="$PATH:$HOME/.local/bin" - - curl --silent -L "https://s3-us-west-1.amazonaws.com/kite-data/tensorflow/libtensorflow-cpu-linux-x86_64-1.9.0.tar.gz" | tar -C $HOME -xz - - curl --silent --compressed --output "$HOME/kited-test" "https://s3-us-west-1.amazonaws.com/kited-test/linux/kited-test" - - chmod u+x "$HOME/kited-test" - -install: | - git config --global user.email "you@example.com" - git config --global user.name "Your Name" - C_OPTS="--prefix=$DEPS --with-features=huge --disable-gui " - git clone --depth 1 https://github.com/vim/vim - cd vim - export PATH=/usr/bin:$PATH - ./configure $C_OPTS - make - make install - cd - - export PATH=$DEPS/bin:$PATH - export VIM="$(which vim)" - - -script: - - vim --version - - cd test && bash test - - export LD_LIBRARY_PATH="$HOME/lib:$LD_LIBRARY_PATH" - - echo "Running tests with kited-local --------------" && $HOME/kited-test > ~/kite.log 2>&1 & sleep 20 && bash editor_tests && killall kited-test - diff --git a/vim/.vim/pack/kite/start/vim-plugin/DEVELOPMENT.md b/vim/.vim/pack/kite/start/vim-plugin/DEVELOPMENT.md deleted file mode 100755 index a4e7981..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/DEVELOPMENT.md +++ /dev/null @@ -1,30 +0,0 @@ -# Installation - -## Manual installation - -### Vim - -Assuming your Vim configuration is in `~/.vim/`: - -```sh -$ mkdir -p ~/.vim/pack/kite/start/kite -$ git clone https://github.com/kiteco/vim-plugin.git ~/.vim/pack/kite/start/kite/ -``` - -Restart Vim. - - -### Neovim - -Assuming your Neovim configuration is in `~/.config/nvim`: - -```sh -$ mkdir -p ~/.config/nvim/pack/kite/start/kite -$ git clone https://github.com/kiteco/vim-plugin.git ~/.config/nvim/pack/kite/start/kite/ -``` - -Restart Neovim. - -# Development - -When working on the plugin, ensure the file `~/.kite/vim-development` (or `$LOCALAPPDATA$\Kite\vim-development` on Windows) is present. This tells the plugin to use development mode, i.e. to use the non-production key when POSTing metrics to Segment. diff --git a/vim/.vim/pack/kite/start/vim-plugin/LICENSE b/vim/.vim/pack/kite/start/vim-plugin/LICENSE deleted file mode 100755 index 5d27330..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/LICENSE +++ /dev/null @@ -1,4 +0,0 @@ -Copyright (c) 2017 Manhattan Engineering, Inc - All Rights Reserved - -Reproduction of this material is strictly forbidden unless prior written -permission is obtained from Manhattan Engineering, Inc. diff --git a/vim/.vim/pack/kite/start/vim-plugin/LSP.md b/vim/.vim/pack/kite/start/vim-plugin/LSP.md deleted file mode 100755 index bd8fe52..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/LSP.md +++ /dev/null @@ -1,57 +0,0 @@ -## Kite-LSP - -Kite comes with a language server adapter that may be used to enable Kite -completions via your favorite LSP client. -Other Kite features than completions are not well-supported via LSP, so you -should still install the Kite plugin for Vim. - -The Kite-LSP adapter may be run as follows, depending on your operating system: -```bash -/Applications/Kite.app/Contents/MacOS/kite-lsp --editor=vim -~/.local/share/kite/current/kite-lsp --editor=vim -C:\Program Files\Kite\kite-lsp.exe --editor=vim -``` - -If you installed Kite to a non-standard location, you may need to appropriately -modify the executable path. - -### Neovim-LSP - -As today the [LSP integration in neovim](https://github.com/neovim/nvim-lspconfig) is just avalaible in the nightlies. -To enable the support in this case: - -``` -au User lsp_setup call lsp#register_server({ - \ 'name': 'kite', - \ 'cmd': '~/.local/share/kite/current/kite-lsp --editor=vim', - \ 'whitelist': ["php", "javascript", "python", "bash"], - \ }) -``` - -### Coc.nvim - -We have tested Kite-LSP with the full-featured -[coc.nvim](https://github.com/neoclide/coc.nvim) completions plugin. -However, it should likely work with most LSP client plugins. - -In order to enable Kite-LSP, add the following to your coc.nvim configuration -(`:CocConfig`): -```json -{ - "languageserver": { - "kite": { - "command": "/Applications/Kite.app/Contents/MacOS/kite-lsp --editor=vim", - "filetypes": ["python", "go", "javascript"] - } - } -} -``` - -Add to `"filetypes"` any languages for which you would like to enable Kite -completions. - -You should also disable the Kite plugin's completions to avoid getting -duplicate completions: -```viml -let g:kite_completions=0 -``` diff --git a/vim/.vim/pack/kite/start/vim-plugin/README.md b/vim/.vim/pack/kite/start/vim-plugin/README.md deleted file mode 100755 index 5b47454..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/README.md +++ /dev/null @@ -1,222 +0,0 @@ -# Kite Python Plugin for Vim/Neovim - -Kite is an AI-powered programming assistant that helps you write Python code inside Vim. Kite helps you write code faster by showing you the right information at the right time. Learn more about how Kite helps you while you're using Vim at https://kite.com/integrations/vim/. - -At a high level, Kite provides you with: -* 🧠 __[Line-of-Code Completions](#Line-of-Code-Completions)__ powered by machine learning models trained on the entire open source code universe -* 📝 __[Intelligent Snippets](#Intelligent-Snippets)__ that automatically provide context-relevant code snippets for your function calls -* 🔍 __[Instant documentation](#Kite-Copilot-for-Python-Documentation)__ for the symbol underneath your cursor so you save time searching for Python docs - - -## Requirements - -* macOS 10.10+ or Windows 7+ or Linux (Ubuntu, Debian, Fedora, Arch Linux, Linux Mint, openSUSE, KDE, XFCE, Gnome 2, Gnome 3) -* Vim 8 or Neovim -* [Kite Engine](https://kite.com/) - -Use another editor? Check out [Kite’s other editor integrations](https://kite.com/integrations/). - - -## Installation - -### Installing the Kite Engine - -The [Kite Engine](https://kite.com/) needs to be installed and running on your computer in order for the package to work properly. The package itself provides the frontend that interfaces with the Kite Engine, which performs all the code analysis and machine learning 100% locally on your computer (no code is sent to a cloud server). - -__macOS Instructions__ -1. Download the [installer](https://kite.com/download/) and open the downloaded `.dmg` file. -2. Drag the Kite icon into the `Applications` folder. -3. Run `Kite.app` to start the Kite Engine. - -__Windows Instructions__ -1. Download the [installer](https://kite.com/download/) and run the downloaded `.exe` file. -2. The installer should run the Kite Engine automatically after installation is complete. - -__Linux Instructions__ -1. Visit https://kite.com/linux/ to learn how to install Kite. -2. The installer should run the Kite Engine automatically after installation is complete. - -### Installing the Kite plugin for Vim/Neovim - -When running the Kite Engine for the first time, you'll be guided through a setup process which will allow you to install the Vim/Neovim plugin. You can also install or uninstall the Vim plugin at any time using the Kite Engine's [plugin manager](https://help.kite.com/article/62-managing-editor-plugins). - -Alternatively, you can follow the instructions in the [DEVELOPMENT.md](https://github.com/kiteco/vim-plugin/blob/master/DEVELOPMENT.md) file to learn how to manually install the Vim/Neovim plugin. - -Once installed, the plugin will be automatically updated by Kite when necessary. - -### Configuring supported languages - -Kite supports 12 languages and counting. By default only Python is enabled. You can configure the languages for which Kite is enabled: - -```viml -" Python, JavaScript, Go -let g:kite_supported_languages = ['python', 'javascript', 'go'] - -" All the languages Kite supports -let g:kite_supported_languages = ['*'] - -" Turn off Kite -let g:kite_supported_languages = [] -``` - -[Learn more about why Kite is the best autocomplete for Vim.](https://kite.com/integrations/vim/) - - -## Features - -Kite's Vim/Neovim plugin provides a number of features to help you code better and faster. - - -### Line-of-Code Completions - -Kite's ranked completions are integrated with Vim's insert-mode completion, specifically the user-defined completion. Kite shows normal completions or signature-completions as appropriate for the cursor position. - -By default Kite's completions will show up automatically as you type. You can opt out via: - -```viml -let g:kite_auto_complete=0 -``` - -You can manually invoke the completions in insert mode with ``. See `:h i_CTRL-X_CTRL-U` for details. - -You can disable Kite's completions altogether with this in your vimrc: - -```viml -let g:kite_completions=0 -``` - -Kite's completions include snippets by default. To opt out of the snippets, add this to your vimrc: - -```viml -let g:kite_snippets=0 -``` - -Normally you insert the currently selected completion option with ``. If you'd like to use `` instead / as well, add this to your vimrc: - -```viml -let g:kite_tab_complete=1 -``` - -For any kind of completion you must set 'completopt' as follows: - -```viml -set completeopt+=menuone -``` - -For automatic completion, you also need either: - -```viml -set completeopt+=noselect -``` - -or: - -```viml -set completeopt+=noinsert -``` - -To see documentation in the preview window for each completion option, copy all the lines above into your vimrc and change the preview line to: - -```viml -set completeopt+=preview -``` - -To have the preview window automatically closed once a completion has been inserted: - -```viml -autocmd CompleteDone * if !pumvisible() | pclose | endif -``` - -We also recommend: - -```viml -set belloff+=ctrlg " if vim beeps during completion -``` - - -### Intelligent Snippets - -Some completions are actually autogenerated code snippets which can be filled in. These will be highlighted with the Underline highlight group. - -You can navigate between placeholders with `` (forward) and `` (backward), even after you have typed over the original placeholder text. - -To change these keys: - -```viml -let g:kite_previous_placeholder = '' -let g:kite_next_placeholder = '` -``` - - -### Signatures - -Kite can show how other people used the signature you are using. By default this is off to save space. - -To turn it on: `:KiteShowPopularPatterns`. - -To turn it off: `:KiteHidePopularPatterns`. - - -### Kite Copilot for Python Documentation - -As you edit your code, the [Kite Copilot](https://kite.com/copilot/) will automatically show examples and docs for the code under your cursor. - -Alternatively, you can press `K` when the cursor is on a symbol to view its documentation in Kite Copilot. - -If you have mapped `K` already, the plugin won't overwrite your mapping. You can set an alternative mapping, e.g. to `gK`, like this: - -```viml -nmap gK (kite-docs) -``` - -By default you need to type `K` (or whatever you have mapped to `(kite-docs)`) each time you want to see documentation for the keyword under the cursor. To have the documentation continually update itself as you move from keyword to keyword: - -```viml -let g:kite_documentation_continual=1 -``` - - -### Goto Definition - -Use `` or `:KiteGotoDefinition` to jump to a method's definition. - - -### Commands - -- `KiteDocsAtCursor` - show documentation for the keyword under the cursor. -- `KiteOpenCopilot` - open the Kite Copilot and focus on it. -- `KiteGeneralSettings` - open Kite's settings in the Copilot. -- `KitePermissions` - open Kite's permission settings in the Copilot. -- `KiteTutorial` - show a tutorial for how to use Kite with Vim. -- `KiteEnableAutoStart` - start Kite automatically when Vim starts. -- `KiteDisableAutoStart` - do not start Kite automatically when Vim starts. -- `KiteGotoDefinition` - jump to a method's definition. - - - -### Statusline - -Add `%{kite#statusline()}` to your statusline to get an indicator of what Kite is doing. If you don't have a status line, this one matches the default when `&ruler` is set: - -```viml -set statusline=%<%f\ %h%m%r%{kite#statusline()}%=%-14.(%l,%c%V%)\ %P -set laststatus=2 " always display the status line -``` - - -### Debugging - -Use `let g:kite_log=1` to switch on logging. Logs are written to `kite-vim.log` in Vim's current working directory. - - ---- - -#### About Kite - -Kite is built by a team in San Francisco devoted to making programming easier and more enjoyable for all. Follow Kite on -[Twitter](https://twitter.com/kitehq) and get the latest news and programming tips on the -[Kite Blog](https://kite.com/blog/). -Kite has been featured in [Wired](https://www.wired.com/2016/04/kites-coding-asssitant-spots-errors-finds-better-open-source/), -[VentureBeat](https://venturebeat.com/2019/01/28/kite-raises-17-million-for-its-ai-powered-developer-environment/), -[The Next Web](https://thenextweb.com/dd/2016/04/14/kite-plugin/), and -[TechCrunch](https://techcrunch.com/2019/01/28/kite-raises-17m-for-its-ai-driven-code-completion-tool/). diff --git a/vim/.vim/pack/kite/start/vim-plugin/VERSION b/vim/.vim/pack/kite/start/vim-plugin/VERSION deleted file mode 100755 index 7260243..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.0.84 diff --git a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite.vim b/vim/.vim/pack/kite/start/vim-plugin/autoload/kite.vim deleted file mode 100755 index 01ab8bf..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite.vim +++ /dev/null @@ -1,264 +0,0 @@ -let s:status_poll_interval = 5 * 1000 " 5sec in milliseconds -let s:timer = -1 -let s:watch_timer = -1 - -if !kite#utils#windows() - let s:kite_symbol = nr2char(printf('%d', '0x27E0')) -else - let s:kite_symbol = '[k]' -endif - -let s:inited = 0 -let s:kite_auto_launched = 0 - - -function kite#enable_auto_start() - call kite#utils#set_setting('start_kited_at_startup', 1) - call s:launch_kited() - call kite#utils#info('Kite: auto-start enabled') -endfunction - -function kite#disable_auto_start() - call kite#utils#set_setting('start_kited_at_startup', 0) - call kite#utils#info('Kite: auto-start disabled') -endfunction - -function kite#symbol() - return s:kite_symbol -endfunction - - -function kite#statusline() - if exists('b:kite_status') - return b:kite_status - else - return '' - endif -endfunction - - -function! kite#max_file_size() - " Fallback to 1MB - return get(b:, 'kite_max_file_size', 1048576) -endfunction - - -function! kite#configure_completeopt() - " If the user has configured completeopt, leave it alone. - redir => output - silent verbose set completeopt - redir END - if len(split(output, '\n')) > 1 | return | endif - - set completeopt=menuone,noinsert -endfunction - - -function! s:setup_options() - let s:pumheight = &pumheight - if &pumheight == 0 - set pumheight=10 - endif - - let s:updatetime = &updatetime - if &updatetime == 4000 - set updatetime=100 - endif - - let s:shortmess = &shortmess - set shortmess+=c - - if kite#utils#windows() - " Avoid taskbar flashing on Windows when executing system() calls. - let s:shelltemp = &shelltemp - set noshelltemp - endif -endfunction - - -function! s:restore_options() - if !exists('s:pumheight') | return | endif - - let &pumheight = s:pumheight - unlet s:pumheight - let &updatetime = s:updatetime - let &shortmess = s:shortmess - if kite#utils#windows() - let &shelltemp = s:shelltemp - endif -endfunction - - -function! kite#bufenter() - if kite#languages#supported_by_plugin() - call s:launch_kited() - - if !kite#utils#kite_running() - call kite#status#status() - call s:start_status_timer() - - call s:start_watching_for_kited() - return - endif - - call s:stop_watching_for_kited() - - if kite#languages#supported_by_kited() - if g:kite_completions - call s:disable_completion_plugins() - endif - call s:setup_options() - call s:setup_events() - call s:setup_mappings() - call s:set_max_file_size() - - if g:kite_completions - setlocal completefunc=kite#completion#complete - endif - - call kite#events#event('focus') - call kite#status#status() - call s:start_status_timer() - - return - end - end - - " Buffer is not a supported language. - call s:restore_options() - call s:stop_status_timer() -endfunction - - -function s:setup_events() - augroup KiteEvents - autocmd! * - - autocmd CursorHold,CursorHoldI call kite#events#event('selection') - autocmd TextChanged,TextChangedI call kite#events#event('edit') - autocmd FocusGained call kite#events#event('focus') - - if g:kite_completions - autocmd InsertCharPre call kite#completion#insertcharpre() - autocmd TextChangedI call kite#completion#autocomplete() - - autocmd CompleteDone call kite#completion#replace_range() - - if &ft == 'go' - autocmd CompleteDone call kite#completion#expand_newlines() - endif - if &ft == 'python' - autocmd CompleteDone call kite#snippet#complete_done() - endif - endif - - if exists('g:kite_documentation_continual') && g:kite_documentation_continual - autocmd CursorHold,CursorHoldI call kite#docs#docs() - endif - augroup END -endfunction - - -function! s:setup_mappings() - if exists('g:kite_tab_complete') && g:kite_completions - imap pumvisible() ? "\" : "\" - endif - - if empty(maparg('K', 'n')) && !hasmapto('(kite-docs)', 'n') - nmap K (kite-docs) - endif - - if empty(maparg('', 'n')) - nmap :KiteGotoDefinition - endif -endfunction - - -function! s:set_max_file_size() - let max_file_size = kite#client#max_file_size() - if max_file_size != -1 - let b:kite_max_file_size = max_file_size - endif -endfunction - - -function! s:start_status_timer() - if s:timer == -1 - let s:timer = timer_start(s:status_poll_interval, - \ function('kite#status#status'), - \ {'repeat': -1} - \ ) - else - call timer_pause(s:timer, 0) " unpause - endif -endfunction - - -function! s:stop_status_timer() - call timer_pause(s:timer, 1) -endfunction - - -function! s:launch_kited() - if !s:kite_auto_launched && kite#utils#get_setting('start_kited_at_startup', 1) - call kite#utils#launch_kited() - let s:kite_auto_launched = 1 - endif -endfunction - - -function! s:start_watching_for_kited() - if s:watch_timer == -1 - let s:watch_timer = timer_start(s:status_poll_interval, - \ function('kite#activate_when_ready'), - \ {'repeat': -1} - \ ) - else - call timer_pause(s:watch_timer, 0) " unpause - endif -endfunction - -function! kite#activate_when_ready(...) - if kite#utils#kite_running() - call kite#bufenter() - endif -endfunction - -function! s:stop_watching_for_kited() - call timer_pause(s:watch_timer, 1) -endfunction - - -function! s:disable_completion_plugins() - " coc.nvim - if exists('g:did_coc_loaded') - let b:coc_suggest_disable = 1 - " Alternatively: - " autocmd BufEnter *.python :CocDisable - " autocmd BufLeave *.python :CocEnable - call kite#utils#warn("disabling coc.nvim's completions in this buffer") - endif - - " Jedi - if exists('*jedi#setup_completion') - " This may not be enough: https://github.com/davidhalter/jedi-vim/issues/614 - let g:jedi#completions_enabled = 0 - call kite#utils#warn("disabling jedi-vim's completions") - " Alternatively: - " call kite#utils#warn('please uninstall jedi-vim and restart vim/nvim') - " finish - endif - - " YouCompleteMe - if exists('g:loaded_youcompleteme') && !exists('g:ycm_filetype_blacklist.python') - let g:ycm_filetype_blacklist.python = 1 - call kite#utils#warn("disabling YouCompleteMe's completions for python files") - endif - - " Deoplete - if exists('*deoplete#disable') - call deoplete#disable() - call kite#utils#warn("disabling deoplete's completions") - endif -endfunction - diff --git a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/async.vim b/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/async.vim deleted file mode 100755 index 167b7f3..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/async.vim +++ /dev/null @@ -1,123 +0,0 @@ -let s:async_sync_id = 0 -let s:async_sync_outputs = {} - -function! s:next_async_sync_id() - let async_sync_id = s:async_sync_id - let s:async_sync_id += 1 - return async_sync_id -endfunction - -function! s:async_sync_output(async_sync_id, output) - if type(a:output) == v:t_list - " Ensure empty list becomes an empty string. - let output = join(a:output, "\n") - else - " Assume this is a string - let output = a:output - endif - let s:async_sync_outputs[a:async_sync_id] = output " job can now be garbage collected -endfunction - - -" Executes `cmd` asynchronously but looks synchronous to the caller. -function! kite#async#sync(cmd) - let async_sync_id = s:next_async_sync_id() - let job_handle = kite#async#execute(a:cmd, function('s:async_sync_output', [async_sync_id])) - let s:async_sync_outputs[async_sync_id] = job_handle - let job_type = type(job_handle) " Assume not a string - - let vim = !has('nvim') - while type(s:async_sync_outputs[async_sync_id]) == job_type - if vim | call job_status(job_handle) | endif - sleep 5m - endwhile - - let output = s:async_sync_outputs[async_sync_id] - unlet s:async_sync_outputs[async_sync_id] - - return output -endfunction - - -" Optional argument is data (JSON) to pass to cmd's stdin. -" Returns the job / job id. -function! kite#async#execute(cmd, handler, ...) - let options = { - \ 'stdoutbuffer': [], - \ 'handler': a:handler, - \ } - let command = s:build_command(a:cmd) - - if has('nvim') - let jobid = jobstart(command, extend(options, { - \ 'on_stdout': function('s:on_stdout_nvim'), - \ 'on_exit': function('s:on_exit_nvim') - \ })) - if a:0 - call chansend(jobid, a:1) - call chanclose(jobid, 'stdin') - endif - return jobid - else - let job = job_start(command, { - \ 'out_cb': function('s:on_stdout_vim', options), - \ 'exit_cb': function('s:on_exit_vim', options) - \ }) - if a:0 - let channel = job_getchannel(job) - call ch_sendraw(channel, a:1) - call ch_close_in(channel) - endif - return job - endif -endfunction - - -function! s:build_command(cmd) - if has('nvim') - if has('unix') - return ['sh', '-c', a:cmd] - elseif has('win64') || has('win32') - return ['cmd.exe', '/c', a:cmd] - else - throw 'unknown os' - endif - else - if has('unix') - return ['sh', '-c', a:cmd] - elseif has('win64') || has('win32') - return 'cmd.exe /c '.a:cmd - else - throw 'unknown os' - endif - endif -endfunction - - -function! s:on_stdout_vim(_channel, data) dict - " a:data - an output line - call add(self.stdoutbuffer, a:data) -endfunction - -function! s:on_exit_vim(job, exit_status) dict - " Allow time for any buffered data to trigger out_cb. - " 5m is an educated guess. - sleep 5m - call self.handler(self.stdoutbuffer) -endfunction - -function! s:on_stdout_nvim(_job_id, data, event) dict - if empty(self.stdoutbuffer) - let self.stdoutbuffer = a:data - else - let self.stdoutbuffer = self.stdoutbuffer[:-2] + - \ [self.stdoutbuffer[-1] . a:data[0]] + - \ a:data[1:] - endif -endfunction - - -function! s:on_exit_nvim(_job_id, _data, _event) dict - call map(self.stdoutbuffer, 'substitute(v:val, "\r$", "", "")') - call self.handler(self.stdoutbuffer) -endfunction diff --git a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/client.vim b/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/client.vim deleted file mode 100755 index bf37bf2..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/client.vim +++ /dev/null @@ -1,329 +0,0 @@ -let s:port = empty($KITED_TEST_PORT) ? 46624 : $KITED_TEST_PORT -let s:channel_base = 'localhost:'.s:port -let s:base_url = 'http://127.0.0.1:'.s:port -let s:editor_path = '/clientapi/editor' -let s:onboarding_path = '/clientapi/plugins/onboarding_file?editor=vim' -let s:hover_path = '/api/buffer/vim' -let s:docs_path = 'kite://docs/' -let s:status_path = '/clientapi/status?filename=' -let s:languages_path = '/clientapi/languages' -let s:copilot_path = 'kite://home' -let s:counter_path = '/clientapi/metrics/counters' -let s:settings_path = 'kite://settings' -let s:permissions_path = 'kite://settings/permissions' -let s:max_file_size_path = '/clientapi/settings/max_file_size_kb' -let s:codenav_path = '/codenav/editor/related' - - -function! kite#client#docs(word) - let url = s:docs_path.a:word - call kite#utils#browse(url) -endfunction - - -function! kite#client#settings() - call kite#utils#browse(s:settings_path) -endfunction - - -function! kite#client#permissions() - call kite#utils#browse(s:permissions_path) -endfunction - - -function! kite#client#copilot() - call kite#utils#browse(s:copilot_path) -endfunction - - -function! kite#client#counter(json, handler) - let path = s:counter_path - if has('channel') - call s:async(function('s:timer_post', [path, g:kite_long_timeout, a:json, a:handler])) - else - call kite#async#execute(s:external_http_cmd(s:base_url.path, g:kite_long_timeout, 1), a:handler, a:json) - endif -endfunction - - -function! kite#client#onboarding_file(handler) - let path = s:onboarding_path - if has('channel') - let response = s:internal_http(path, g:kite_short_timeout) - else - let response = s:external_http(s:base_url.path, g:kite_short_timeout) - endif - return a:handler(s:parse_response(response)) -endfunction - - -function! kite#client#status(filename, handler) - let path = s:status_path.kite#utils#url_encode(a:filename) - if has('channel') - let response = s:internal_http(path, g:kite_short_timeout) - else - let response = s:external_http(s:base_url.path, g:kite_short_timeout) - endif - return a:handler(s:parse_response(response)) -endfunction - - -function! kite#client#languages(handler) - let path = s:languages_path - if has('channel') - let response = s:internal_http(path, g:kite_short_timeout) - else - let response = s:external_http(s:base_url.path, g:kite_short_timeout) - endif - return a:handler(s:parse_response(response)) -endfunction - - -" Returns max file size in bytes, or -1 if not available. -function! kite#client#max_file_size() - let path = s:max_file_size_path - if has('channel') - let response = s:internal_http(path, g:kite_short_timeout) - else - let response = s:external_http(s:base_url.path, g:kite_short_timeout) - endif - let result = s:parse_response(response) - if result.status == 200 - return result.body * 1024 - else - return -1 - endif -endfunction - - -function! kite#client#hover(filename, hash, cursor, handler) - call s:wait_for_pending_events() - - let path = s:hover_path.'/'.a:filename.'/'.a:hash.'/hover?cursor_runes='.a:cursor - if has('channel') - call s:async(function('s:timer_get', [path, g:kite_long_timeout, a:handler])) - else - call kite#async#execute(s:external_http_cmd(s:base_url.path, g:kite_long_timeout, 0), - \ function('s:parse_and_handle', [a:handler])) - endif -endfunction - - -function! kite#client#signatures(json, handler) - let path = s:editor_path.'/signatures' - if has('channel') - call s:async(function('s:timer_post', [path, g:kite_long_timeout, a:json, a:handler])) - else - call kite#async#execute(s:external_http_cmd(s:base_url.path, g:kite_long_timeout, 1), - \ function('s:parse_and_handle', [a:handler]), a:json) - endif -endfunction - - -function! kite#client#completions(json, handler) - let path = s:editor_path.'/complete' - if has('channel') - call s:async(function('s:timer_post', [path, g:kite_long_timeout, a:json, a:handler])) - else - call kite#async#execute(s:external_http_cmd(s:base_url.path, g:kite_long_timeout, 1), - \ function('s:parse_and_handle', [a:handler]), a:json) - endif -endfunction - - -function! kite#client#request_related(json, handler) - let path = s:codenav_path - let timeout = 10000 "10s - if has('channel') - call s:async(function('s:timer_post', [path, timeout, a:json, a:handler])) - else - call kite#async#execute(s:external_http_cmd(s:base_url.path, timeout, 1), - \ function('s:parse_and_handle', [a:handler]), a:json) - endif -endfunction - - -function! kite#client#post_event(json, handler) - let path = s:editor_path.'/event' - if has('channel') - call s:async(function('s:timer_post', [path, g:kite_short_timeout, a:json, a:handler])) - else - call kite#async#execute(s:external_http_cmd(s:base_url.path, g:kite_short_timeout, 1), - \ function('s:parse_and_handle', [a:handler]), a:json) - endif -endfunction - - -function! s:timer_get(path, timeout, handler, timer) - call a:handler(s:parse_response(s:internal_http(a:path, a:timeout))) -endfunction - -function! s:timer_post(path, timeout, json, handler, timer) - call a:handler(s:parse_response(s:internal_http(a:path, a:timeout, a:json))) -endfunction - -function! s:async(callback) - call timer_start(0, a:callback) -endfunction - - -function! s:on_std_out(_channel, message) dict - let self.stdoutbuffer .= a:message -endfunction - - -" Optional argument is json to be posted -function! s:internal_http(path, timeout, ...) - " Use HTTP 1.0 (not 1.1) to avoid having to parse chunked responses. - if a:0 - let str = 'POST '.a:path." HTTP/1.0\nHost: localhost\nContent-Type: application/x-www-form-urlencoded\nContent-Length: ".len(a:1)."\n\n".a:1 - else - let str = 'GET '.a:path." HTTP/1.0\nHost: localhost\n\n" - endif - call kite#utils#log('') - call kite#utils#log(map(split(str, '\n', 1), '"> ".v:val')) - - let options = {'stdoutbuffer': ''} - try - let channel = ch_open(s:channel_base, { - \ 'mode': 'raw', - \ 'callback': function('s:on_std_out', options) - \ }) - catch /E898\|E901\|E902/ - call kite#utils#log('| Cannot open channel: '.str) - return '' - endtry - - try - call ch_sendraw(channel, str) - catch /E630\|E631\|E906/ - call kite#utils#log('| Cannot send over channel: '.str) - return '' - endtry - - let start = reltime() - - while ch_status(channel) !=# 'closed' - if reltimefloat(reltime(start))*1000 > a:timeout - call kite#utils#log('| Timed out waiting for response (timeout: '.a:timeout.'ms)') - try - call ch_close(channel) - catch /E906/ - " noop - endtry - return '' - endif - - sleep 5m - endwhile - - call kite#utils#log('| Received complete response: '.string(reltimefloat(reltime(start))*1000).'ms') - - return options.stdoutbuffer -endfunction - - -" Optional argument is json to be posted -function! s:external_http(url, timeout, ...) - let cmd = s:external_http_cmd(a:url, a:timeout, a:0) - if a:0 - return system(cmd, a:1) - else - return system(cmd) - endif -endif -endfunction - - -" data argument is a boolean -function! s:external_http_cmd(endpoint, timeout, data) - let cmd = s:http_binary - let cmd .= ' --timeout '.a:timeout.'ms' - if a:data - let cmd .= ' -' - endif - let cmd .= ' '.s:shellescape(a:endpoint) - call kite#utils#log('') - call kite#utils#log('> '.cmd) - return cmd -endfunction - - -function! s:parse_and_handle(handler, out) - call a:handler(s:parse_response(a:out)) -endfunction - - -" Returns the integer HTTP response code and the string body in a dictionary. -" -" lines - either a list (from async commands) or a string (from sync) -function! s:parse_response(lines) - if empty(a:lines) - return {'status': 0, 'body': ''} - endif - - if type(a:lines) == v:t_string - let lines = split(a:lines, '\r\?\n', 1) - else - let lines = a:lines - endif - call kite#utils#log(map(copy(lines), '"< ".v:val')) - - if type(a:lines) == v:t_string - let lines = split(a:lines, '\r\?\n') - else - let lines = a:lines - endif - - " Ignore occasional 100 Continue. - let i = match(lines, '^HTTP/1.[01] [2345]\d\d ') - if i == -1 - return {'status': 0, 'body': ''} - endif - let status = split(lines[i], ' ')[1] - - let sep = match(lines, '^$', i) - let body = join(lines[sep+1:], "\n") - - return {'status': status, 'body': body} -endfunction - - -function! s:wait_for_pending_events() - while kite#events#any_events_pending() - sleep 5m - endwhile -endfunction - - -" Only used with NeoVim on not-Windows, in async jobs. -function! s:shellescape(str) - let [_shell, &shell] = [&shell, 'sh'] - let escaped = shellescape(a:str) - let &shell = _shell - return escaped -endfunction - - -let s:http_binary = kite#utils#lib('kite-http') - - -if !empty($KITED_TEST_PORT) - function! kite#client#request_history() - let ret = json_decode( - \ s:parse_response( - \ s:internal_http('/testapi/request-history', 500) - \ ).body - \ ) - - if type(ret) != type([]) - throw '/testapi/request-history did not return a list (type '.type(ret).')' - endif - - return ret - endfunction - - function! kite#client#reset_request_history() - call s:internal_http('/testapi/request-history/reset', 500) - endfunction -endif diff --git a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/codenav.vim b/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/codenav.vim deleted file mode 100755 index f68ac3d..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/codenav.vim +++ /dev/null @@ -1,39 +0,0 @@ -function! kite#codenav#from_file() - let filepath = kite#utils#filepath(0) - call kite#codenav#request_related(filepath, v:null) -endfunction - - -function! kite#codenav#from_line() - let filepath = kite#utils#filepath(0) - call kite#codenav#request_related(filepath, line(".")) -endfunction - - -function! kite#codenav#request_related(filename, line) - let json = json_encode({ - \ 'editor': 'vim', - \ 'location': {'filename': a:filename, 'line': a:line} - \ }) - call kite#client#request_related(json, function('kite#codenav#handler')) -endfunction - - -function! kite#codenav#handler(response) abort - if a:response.status != 200 - if a:response.status == 0 - call kite#utils#warn("Kite could not be reached. Please check that Kite Engine is running.") - return - endif - - - let err = json_decode(a:response.body) - - if empty(err) || type(err.message) != v:t_string - call kite#utils#warn("Oops! Something went wrong with Code Finder. Please try again later.") - return - endif - - call kite#utils#warn(err.message) - endif -endfunction diff --git a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/completion.vim b/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/completion.vim deleted file mode 100755 index 5f64280..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/completion.vim +++ /dev/null @@ -1,454 +0,0 @@ -let s:should_trigger_completion = 0 -let s:completion_counter = 0 -let s:begin = 0 -let s:end = 0 - - -function! kite#completion#replace_range() - if empty(v:completed_item) | return | endif - if !exists('s:startcol') | return | endif - let startcol = s:startcol - unlet s:startcol - - if has_key(v:completed_item, 'user_data') && !empty(v:completed_item.user_data) - let range = json_decode(v:completed_item.user_data).range - let placeholders = json_decode(v:completed_item.user_data).placeholders - elseif exists('b:kite_completions') && has_key(b:kite_completions, v:completed_item.word) - let range = json_decode(b:kite_completions[v:completed_item.word]).range - let placeholders = json_decode(b:kite_completions[v:completed_item.word]).placeholders - else - return - endif - - " The range seems to be wrong when placeholders are involved so stop here. - if !empty(placeholders) | return | endif - - let col = col('.') - let _col = col - - " end of range - let n = range.end - s:offset_before_completion - if n > 0 - execute 'normal! "_'.n.'x' - let col -= n - endif - - " start of range - let range_begin_col = col('.') - (kite#utils#character_offset() - range.begin) - let n = startcol - range_begin_col - if n > 0 - call kite#utils#goto_character(range.begin + 1) - execute 'normal! "_'.n.'x' - let col -= n - endif - - " restore cursor position - if col != _col - execute 'normal!' (col+1).'|' - call s:feedkeys("\la") - endif -endfunction - - -function! kite#completion#expand_newlines() - if empty(v:completed_item) | return | endif - if match(v:completed_item.word, '\n') == -1 | return | endif - - let parts = split(getline('.'), '\n', 1) - delete _ - call append(line('.')-1, parts) - -1 - " startinsert! doesn't seem to work with: package main^@import ""^@ - call s:feedkeys("\A") -endfunction - - -function! kite#completion#insertcharpre() - let s:should_trigger_completion = 1 - - " Trigger a fresh completion after every keystroke when the popup menu - " is visible (by calling the function which TextChangedI would call - " (TextChangedI is not triggered when the popup menu is visible)). - if pumvisible() - call kite#utils#log('# Trigger autocomplete because of pumvisible(): '.v:char) - call kite#completion#autocomplete() - endif -endfunction - - -function! kite#completion#autocomplete() - if !g:kite_auto_complete | return | endif - if exists('b:kite_skip') && b:kite_skip | return | endif - if wordcount().bytes > kite#max_file_size() | return | endif - - if s:should_trigger_completion - let s:should_trigger_completion = 0 - call s:feedkeys("\\") - endif -endfunction - - -" Manual invocation calls this method. -function! kite#completion#complete(findstart, base) - if a:findstart - if !s:completeopt_suitable() - let g:kite_auto_complete = 0 - return -3 - endif - - " Store the buffer contents and cursor position here because when Vim - " calls this function the second time (with a:findstart == 0) Vim has - " already deleted the text between `start` and the cursor position. - let s:cursor = kite#utils#character_offset() - let s:text = kite#utils#buffer_contents() - - let s:startcol = s:findstart() - return s:startcol - else - " Leave CTRL-X submode so user can invoke other completion methods. - call s:feedkeys("\") - call s:get_completions() - if has('patch-8.1.0716') - return v:none - else - return [] - endif - endif -endfunction - - -function! s:findstart() - let line = getline('.') - let start = col('.') - 1 - - let s:signature = s:before_function_call_argument(line[:start-1]) && s:begin == 0 - - if !s:signature - while start > 0 && line[start - 1] =~ '\w' - let start -= 1 - endwhile - endif - - return start -endfunction - - -function! s:get_completions() - if s:signature - call kite#signature#increment_completion_counter() - else - let s:completion_counter = s:completion_counter + 1 - endif - - let filename = kite#utils#filepath(0) - - if s:signature - let params = { - \ 'filename': filename, - \ 'editor': 'vim', - \ 'text': s:text, - \ 'cursor_runes': s:cursor, - \ 'offset_encoding': 'utf-32' - \ } - else - let params = { - \ 'no_snippets': (g:kite_snippets ? v:false : v:true), - \ 'no_unicode': (kite#utils#windows() ? v:true : v:false), - \ 'filename': filename, - \ 'editor': 'vim', - \ 'text': s:text, - \ 'position': { - \ 'begin': (s:begin > 0 ? s:begin : s:cursor), - \ 'end': (s:end > 0 ? s:end : s:cursor), - \ }, - \ 'offset_encoding': 'utf-32', - \ 'placeholders': [] - \ } - let s:begin = 0 - let s:end = 0 - endif - - let json = json_encode(params) - - if s:signature - call kite#client#signatures(json, function('kite#signature#handler', [kite#signature#completion_counter(), s:startcol])) - else - call kite#client#completions(json, function('kite#completion#handler', [s:completion_counter, s:startcol])) - endif -endfunction - - -function! kite#completion#handler(counter, startcol, response) abort - call kite#utils#log('completion: '.a:response.status) - - " Ignore old completion results. - if a:counter != s:completion_counter - return - endif - - if a:response.status != 200 - return - endif - - " This should not happen but evidently it sometimes does (#107). - if empty(a:response.body) - return - endif - - let json = json_decode(a:response.body) - - " API should return 404 status when no completions but it sometimes - " return 200 status and an empty response body, or "completions":"null". - if empty(json) || type(json.completions) != v:t_list - return - endif - - " 'display' is the LHS of each option in the completion menu - let max_display_length = s:max_display_length(json.completions, 0) - " 'hint' is the RHS of each option in the completion menu - " Add 1 for leading space we add - let max_hint_length = s:max_hint_length(json.completions) + 1 - - let available_win_width = s:winwidth() - a:startcol - let max_width = available_win_width > g:kite_completion_max_width - \ ? g:kite_completion_max_width : available_win_width - - " pad LHS text gap RHS text gap kite branding pad scrollbar - " | | | | | | | | - let menu_width = 1 + max_display_length + 1 + max_hint_length + 1 + strdisplaywidth(kite#symbol()) + 2 + 1 - - if menu_width < max_width " no truncation - let lhs_width = max_display_length - let rhs_width = max_hint_length - - elseif menu_width - 1 - max_hint_length < max_width " truncate rhs - let lhs_width = max_display_length - let rhs_width = max_width - (1 + max_display_length + 1 + strdisplaywidth(kite#symbol()) + 2 + 1) - - else " drop rhs and truncate lhs - let lhs_width = max_width - (1 + 1 + strdisplaywidth(kite#symbol()) + 2 + 1) - let rhs_width = 0 - endif - - let matches = [] - for c in json.completions - call add(matches, s:adapt(c, lhs_width, rhs_width, 0)) - - if has_key(c, 'children') - for child in c.children - call add(matches, s:adapt(child, lhs_width, rhs_width, 1)) - endfor - endif - endfor - - if !has('patch-8.0.1493') - let b:kite_completions = {} - for item in filter(copy(matches), 'has_key(v:val, "user_data")') - let b:kite_completions[item.word] = item.user_data - endfor - endif - - if mode(1) ==# 'i' - let s:startcol = a:startcol+1 - let s:offset_before_completion = kite#utils#character_offset() - call complete(a:startcol+1, matches) - endif -endfunction - - -function! s:adapt(completion_option, lhs_width, rhs_width, nesting) - let display = s:indent(a:nesting) . a:completion_option.display - let display = kite#utils#truncate(display, a:lhs_width) - - " Ensure a minimum separation between abbr and menu of two spaces. - " (Vim lines up the menus so that they are left-aligned 1 space after the longest abbr). - let hint = ' ' . a:completion_option.hint - - let hint = kite#utils#ralign(hint, a:rhs_width) - - " Add the branding - let hint .= ' '.kite#symbol() - - return { - \ 'word': a:completion_option.snippet.text, - \ 'abbr': display, - \ 'info': a:completion_option.documentation.text, - \ 'menu': hint, - \ 'equal': 1, - \ 'user_data': json_encode({'placeholders': a:completion_option.snippet.placeholders, 'range': a:completion_option.replace}) - \ } -endfunction - - -function! s:max_hint_length(completions) - let max = 0 - - for e in a:completions - let len = strdisplaywidth(e.hint) - if len > max - let max = len - endif - - if has_key(e, 'children') - let len = s:max_hint_length(e.children) - if len > max - let max = len - endif - endif - endfor - - return max -endfunction - - -function! s:max_display_length(completions, nesting) - let max = 0 - - for e in a:completions - let len = strdisplaywidth(s:indent(a:nesting) . e.display) - if len > max - let max = len - endif - - if has_key(e, 'children') - let len = s:max_display_length(e.children, a:nesting+1) - if len > max - let max = len - endif - endif - endfor - - return max -endfunction - - -function! s:indent(nesting) - return repeat(' ', a:nesting) -endfunction - - -" Returns truthy if the cursor is: -" -" - just after an open parenthesis; or -" - just after a comma inside a function call; or -" - just after an equals sign inside a function call. -" -" Note this differs from all the other editor plugins. They can all show both -" a signature popup and a completions popup at the same time, whereas Vim can -" only show one popup. Therefore we need to switch its purpose between -" signature info and completions info at appropriate points inside a function -" call's arguments. -" -" line - the line up to the cursor position -function! s:before_function_call_argument(line) - " Other editors basically do this: - " return a:line =~ '\v[(][^)]*$' - - return a:line =~ '\v[(]([^)]+[=,])?\s*$' -endfunction - - -" Returns the width of the part of the current window which holds the buffer contents. -function! s:winwidth() - let w = winwidth(0) - - if &number - let w -= &numberwidth - endif - - let w -= &foldcolumn - - if &signcolumn == 'yes' || (&signcolumn == 'auto' && s:signs_in_buffer()) - " TODO: neovim multiple sign columns - let w -= 2 - endif - - return w -endfunction - - -" Returns 1 if the current buffer has any signs, 0 otherwise. -function! s:signs_in_buffer() - let bufinfo = getbufinfo(bufnr(''))[0] - let signs = has_key(bufinfo, 'signs') ? bufinfo.signs : [] - return !empty(signs) -endfunction - - -function! s:completeopt_suitable() - let copts = split(&completeopt, ',') - - if g:kite_auto_complete - if index(copts, 'menuone') == -1 - call s:popup_warn("Kite: completeopt must contain 'menuone'") - return 0 - endif - - if index(copts, 'noinsert') == -1 && index(copts, 'noselect') == -1 - call s:popup_warn("Kite: completeopt must contain 'noinsert' and/or 'noselect'") - return 0 - endif - endif - - return 1 -endfunction - - -" feedkeys() by default adds keys to the end of the typeahead buffer. Any -" keys already in the buffer will be processed first and may change Vim's -" state, making the queued keys no longer appropriate (e.g. an insert mode key -" combo being applied in normal mode). To avoid this we use the 'i' flag -" which ensures the keys are processed immediately. -function s:feedkeys(keys) - call feedkeys(a:keys, 'i') -endfunction - - -function! s:popup_warn(msg) - if exists('*popup_notification') - call popup_notification(a:msg, { - \ 'pos': 'botleft', - \ 'line': 'cursor-1', - \ 'col': 'cursor', - \ 'moved': 'any', - \ 'time': 2000 - \ }) - elseif exists('*nvim_open_win') - let lines = s:border(a:msg) - let buf = nvim_create_buf(v:false, v:true) - call nvim_buf_set_lines(buf, 0, -1, v:true, lines) - let winid = nvim_open_win(buf, v:false, { - \ 'relative': 'cursor', - \ 'anchor': 'SW', - \ 'row': 0, - \ 'col': 0, - \ 'width': strdisplaywidth(lines[0]), - \ 'height': len(lines), - \ 'focusable': v:false, - \ 'style': 'minimal' - \ }) - call nvim_win_set_option(winid, 'winhighlight', 'Normal:WarningMsg') - call timer_start(2000, {-> execute("call nvim_win_close(".winid.", v:true)")}) - else - call kite#utils#warn(a:msg) - endif -endfunction - - -" Converts: -" -" A quick brown fox. -" -" Into: -" -" +--------------------+ -" | A quick brown fox. | -" +--------------------+ -" -function! s:border(text) - return [ - \ '+'.repeat('-', strdisplaywidth(a:text)+2).'+', - \ '| '.a:text.' |', - \ '+'.repeat('-', strdisplaywidth(a:text)+2).'+' - \ ] -endfunction diff --git a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/docs.vim b/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/docs.vim deleted file mode 100755 index 8557df7..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/docs.vim +++ /dev/null @@ -1,24 +0,0 @@ -function! kite#docs#docs() - if &filetype != 'python' - call kite#utils#warn('Docs are only available for Python') - return - endif - - if empty(expand('')) | return | endif - - let b:kite_id = '' - - call kite#hover#hover() - - while b:kite_id == '' - sleep 5m - endwhile - - if b:kite_id == -1 - call kite#utils#info('No documentation available.') - return - endif - - call kite#client#docs(b:kite_id) -endfunction - diff --git a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/document.vim b/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/document.vim deleted file mode 100755 index 5348b4f..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/document.vim +++ /dev/null @@ -1,42 +0,0 @@ -let kite#document#Document = {} - - -" NOTE: this has to be called with a g: prefix. -function! kite#document#Document.New(dict) - let newDocument = copy(self) - let newDocument.dict = a:dict - return newDocument -endfunction - - -" Query the document, returning `default` if `key` does not exist -" or if the value at `key` is not the same type as `default`. -function! kite#document#Document.dig(key, default) - let v = copy(self.dict) - - for k in split(a:key, '\.') - let matchlist = matchlist(k, '\v(\w+)\[(-?\d+)\]') " foo[42] - - if !empty(matchlist) - let kk = matchlist[1] " foo - if has_key(v, kk) - let v = get(v[kk], str2nr(matchlist[2]), a:default) - else - return a:default - endif - - elseif type(v) == v:t_dict && has_key(v, k) - let v = v[k] - - else - return a:default - endif - endfor - - if type(v) == type(a:default) - return v - endif - - return a:default -endfunction - diff --git a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/events.vim b/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/events.vim deleted file mode 100755 index a662884..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/events.vim +++ /dev/null @@ -1,46 +0,0 @@ -let s:events_pending = 0 - -function! kite#events#any_events_pending() - return s:events_pending > 0 -endfunction - - -function! kite#events#event(action) - let filename = kite#utils#filepath(0) - - if wordcount().bytes < kite#max_file_size() - let action = a:action - let text = kite#utils#buffer_contents() - else - let action = 'skip' - let text = '' - endif - - let [sel_start, sel_end] = kite#utils#selected_region_characters() - if [sel_start, sel_end] == [-1, -1] - return - endif - let selections = [{ 'start': sel_start, 'end': sel_end, 'encoding': 'utf-32' }] - - let json = json_encode({ - \ 'source': 'vim', - \ 'filename': filename, - \ 'text': text, - \ 'action': action, - \ 'selections': selections, - \ 'editor_version': kite#utils#vim_version(), - \ 'plugin_version': kite#utils#plugin_version() - \ }) - - let s:events_pending += 1 - - call kite#client#post_event(json, function('kite#events#handler', [bufnr('')])) -endfunction - - -function! kite#events#handler(bufnr, response) - let s:events_pending -= 1 - - call setbufvar(a:bufnr, 'kite_skip', (a:response.status == 0 || a:response.status == 403)) -endfunction - diff --git a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/hover.vim b/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/hover.vim deleted file mode 100755 index 5203aa0..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/hover.vim +++ /dev/null @@ -1,66 +0,0 @@ -function! kite#hover#hover() - if exists('b:kite_skip') && b:kite_skip | return | endif - if wordcount().bytes > kite#max_file_size() | return | endif - - let filename = kite#utils#filepath(1) - let hash = kite#utils#buffer_md5() - let cursor = kite#utils#cursor_characters() - - call kite#client#hover(filename, hash, cursor, function('kite#hover#handler')) -endfunction - - -function! kite#hover#goto_definition() - if &filetype != 'python' - call kite#utils#warn('Go to definition is only available for Python') - return - endif - - if exists('b:kite_skip') && b:kite_skip | return | endif - if wordcount().bytes > kite#max_file_size() | return | endif - - let filename = kite#utils#filepath(1) - let hash = kite#utils#buffer_md5() - let cursor = kite#utils#cursor_characters() - - call kite#client#hover(filename, hash, cursor, function('kite#hover#goto_definition_handler')) -endfunction - - -function! kite#hover#handler(response) - if a:response.status == 200 - let json = json_decode(a:response.body) - let sym = type(json.symbol) == v:t_list ? json.symbol[0] : json.symbol - let id = sym.id - if empty(id) - let b:kite_id = -1 - else - let b:kite_id = id - endif - - else - let b:kite_id = -1 - endif -endfunction - - -function! kite#hover#goto_definition_handler(response) - if a:response.status != 200 - call kite#utils#warn('unable to find a definition.') - return - endif - - let json = json_decode(a:response.body) - let definition = json.report.definition - - if type(definition) != type({}) - call kite#utils#warn('unable to find a definition.') - return - endif - - if definition.filename !=# expand('%:p') - execute 'edit' definition.filename - end - execute definition.line - normal! zz -endfunction diff --git a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/languages.vim b/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/languages.vim deleted file mode 100755 index dedf7cb..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/languages.vim +++ /dev/null @@ -1,65 +0,0 @@ -let s:languages_supported_by_kited = [] - -" Returns true if we want Kite completions for the current buffer, false otherwise. -function! kite#languages#supported_by_plugin() - " Return false if the file extension is not recognised by kited. - let recognised_extensions = [ - \ 'c', - \ 'cc', - \ 'cpp', - \ 'cs', - \ 'css', - \ 'go', - \ 'h', - \ 'hpp', - \ 'html', - \ 'java', - \ 'js', - \ 'jsx', - \ 'kt', - \ 'less', - \ 'm', - \ 'php', - \ 'py', - \ 'pyw', - \ 'rb', - \ 'scala', - \ 'sh', - \ 'ts', - \ 'tsx', - \ 'vue', - \ ] - if index(recognised_extensions, expand('%:e')) == -1 - return 0 - endif - - if g:kite_supported_languages == ['*'] - return 1 - endif - - " Return false if the buffer's language is not one for which we want Kite completions. - if index(g:kite_supported_languages, &filetype) == -1 - return 0 - endif - - return 1 -endfunction - - -" Returns true if the current buffer's language is supported by kited, false otherwise. -function! kite#languages#supported_by_kited() - " Only check kited's languages once. - if empty(s:languages_supported_by_kited) - " A list of language names, e.g. ['bash', 'c', 'javascript', 'ruby', ...] - let s:languages_supported_by_kited = kite#client#languages(function('kite#languages#handler')) - endif - - return index(s:languages_supported_by_kited, &filetype) != -1 -endfunction - - -function! kite#languages#handler(response) - if a:response.status != 200 | return [] | endif - - return json_decode(a:response.body) -endfunction diff --git a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/metrics.vim b/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/metrics.vim deleted file mode 100755 index 868c72c..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/metrics.vim +++ /dev/null @@ -1,29 +0,0 @@ -" -" Editor feature metrics -" - -let s:prompted = 0 - - -" Optional argument is value by which to increment named metric. -" Defaults to 1. -function! kite#metrics#requested(name) - call s:increment('vim_'.a:name.'_requested') -endfunction - - -function! kite#metrics#fulfilled(name) - call s:increment('vim_'.a:name.'_fulfilled') -endfunction - - -function! s:increment(name) - let json = json_encode({'name': a:name, 'value': 1}) - call kite#client#counter(json, function('kite#metrics#handler')) -endfunction - - -function! kite#metrics#handler(response) - " Noop -endfunction - diff --git a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/onboarding.vim b/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/onboarding.vim deleted file mode 100755 index 4313a10..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/onboarding.vim +++ /dev/null @@ -1,77 +0,0 @@ -let s:text = [ - \ 'Kite is now integrated with Vim', - \ '', - \ 'Kite is an AI-powered programming assistant', - \ 'that shows you the right information at the right', - \ 'time to keep you in the flow.', - \ '', - \ 'Please choose:', - \ '', - \ 'Learn how to use Kite', - \ 'Hide', - \ 'Hide forever', - \ ] -let s:option = 'onboarding_required' - - -function! kite#onboarding#call(force) - if !a:force - if !kite#utils#get_setting(s:option, 1) - return - endif - endif - - call kite#client#onboarding_file(function('kite#onboarding#handler')) -endfunction - - -function! kite#onboarding#handler(response) abort - if a:response.status == 200 - silent execute 'tabedit' json_decode(a:response.body) - call kite#utils#set_setting(s:option, 0) - - else - if exists('*popup_menu') - if !has('patch-8.1.1799') - call s:unmap_menu_keys() - endif - let title = s:text[0] - let winid = popup_menu(s:text[1:], { - \ 'title': ' '.title.' ', - \ 'callback': 'kite#onboarding#popup_callback', - \ }) - call win_execute(winid, "normal! ".repeat('j', len(s:text[1:])-3)) - - else - let s:text[-3] = '1. '.s:text[-3] - let s:text[-2] = '2. '.s:text[-2] - let s:text[-1] = '3. '.s:text[-1] - - call s:handle_choice(inputlist(s:text)-1) - endif - endif -endfunction - - -" Invoked when popup closes. -function! kite#onboarding#popup_callback(_, result) - call s:handle_choice(2 - len(s:text[1:]) + a:result) -endfunction - - -function! s:handle_choice(index) - if a:index == 0 " learn now - call kite#utils#browse('https://help.kite.com/category/47-vim-integration') - elseif a:index == 2 " hide forever - call kite#utils#set_setting(s:option, 0) - endif -endfunction - - -function! s:unmap_menu_keys() - silent! nunmap - silent! nunmap - silent! nunmap j - silent! nunmap k - silent! nunmap x -endfunction diff --git a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/signature.vim b/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/signature.vim deleted file mode 100755 index c9a0872..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/signature.vim +++ /dev/null @@ -1,209 +0,0 @@ -let s:completion_counter = 0 - -function! kite#signature#increment_completion_counter() - let s:completion_counter = s:completion_counter + 1 -endfunction - -function! kite#signature#completion_counter() - return s:completion_counter -endfunction - - -function! kite#signature#handler(counter, startcol, response) abort - call kite#utils#log('signature: '.a:response.status) - - " Ignore old completion results. - if a:counter != s:completion_counter - return - endif - - if a:response.status != 200 - return - endif - - let json = json_decode(a:response.body) - let call = g:kite#document#Document.New(json.calls[0]) - - let function_name = call.dig('func_name', '') - if empty(function_name) - let function_name = call.dig('callee.repr', '') - endif - let function_name = split(function_name, '\.')[-1] - - let spacer = {'word': '', 'empty': 1, 'dup': 1} - let indent = ' ' - let completions = [] - let wrap_width = 50 - - - " - " Signature - " - let parameters = [] - let return_type = '' - let [current_arg, in_kwargs] = [call.dig('arg_index', 0), call.dig('language_details.python.in_kwargs', 0)] - let kind = call.dig('callee.kind', '') - - " 1. Name of function with parameters. - if kind ==# 'function' - " 1.b.1. Parameters - for parameter in call.dig('callee.details.function.parameters', []) - " 1.b.1.a. Name - let name = parameter.name - " 1.b.1.b. Default value - if kite#utils#present(parameter.language_details.python, 'default_value') - let name .= '='.parameter.language_details.python.default_value[0].repr - endif - " 2. Highlight current argument - if !in_kwargs && len(parameters) == current_arg - let name = '*'.name.'*' - endif - call add(parameters, name) - endfor - " 1.b.2. vararg indicator - let vararg = call.dig('callee.details.function.language_details.python.vararg', {}) - if !empty(vararg) - call add(parameters, '*'.vararg.name) - endif - " 1.b.3. keyword arguments indicator - let kwarg = call.dig('callee.details.function.language_details.python.kwarg', {}) - if !empty(kwarg) - call add(parameters, '**'.kwarg.name) - endif - " 1.b.4. Return type - let return_value = call.dig('callee.details.function.return_value', []) - if !empty(return_value) - let return_type = ' -> '.return_value[0].type - endif - - elseif kind ==# 'type' - " 1.c.1. Parameters - for parameter in call.dig('callee.details.type.language_details.python.constructor.parameters', []) - " 1.c.1.a. Name - let name = parameter.name - " 1.c.1.b. Default value - if kite#utils#present(parameter.language_details.python, 'default_value') - let name .= '='.parameter.language_details.python.default_value[0].repr - endif - " 2. Highlight current argument - if !in_kwargs && len(parameters) == current_arg - let name = '*'.name.'*' - endif - call add(parameters, name) - endfor - " 1.c.2. vararg indicator - let vararg = call.dig('callee.details.type.language_details.python.constructor.language_details.python.vararg', {}) - if !empty(vararg) - call add(parameters, '*'.vararg.name) - endif - " 1.c.3. keyword arguments indicator - let kwarg = call.dig('callee.details.type.language_details.python.constructor.language_details.python.kwarg', {}) - if !empty(kwarg) - call add(parameters, '*'.kwarg.name) - endif - " 1.c.4. Return type - let return_type = ' -> '.function_name - endif - - " The completion popup does not wrap long lines so we wrap manually. - for line in kite#utils#wrap(kite#symbol().' '.function_name.'('.join(parameters, ', ').')'.return_type, wrap_width, 4) - let completion = { - \ 'word': '', - \ 'abbr': line, - \ 'empty': 1, - \ 'dup': 1 - \ } - call add(completions, completion) - endfor - - - " 3. Keyword arguments - let kwarg_parameters = call.dig('callee.details.function.kwarg_parameters', []) - if !empty(kwarg_parameters) - call add(completions, spacer) - call add(completions, s:heading('**kw')) - - for kwarg in kwarg_parameters - let name = kwarg.name - let types = kite#utils#map_join(kwarg.inferred_value, 'repr', '|') - if empty(types) - let types = '' - endif - - call add(completions, { - \ 'word': name.'=', - \ 'abbr': indent.name, - \ 'menu': types, - \ 'empty': 1, - \ 'dup': 1 - \ }) - endfor - endif - - - " 4. Popular patterns - if kite#signature#should_show_popular_patterns() - let signatures = call.dig('signatures', []) - if len(signatures) > 0 - call add(completions, spacer) - call add(completions, s:heading('How Others Used This')) - endif - - for signature in signatures - let sigdoc = g:kite#document#Document.New(signature) - - " b. Arguments - let arguments = [] - for arg in sigdoc.dig('args', []) - call add(arguments, arg.name) - endfor - - " c. Keyword arguments - for kwarg in sigdoc.dig('language_details.python.kwargs', []) - let name = kwarg.name - let examples = kite#utils#coerce(kwarg.types[0], 'examples', []) - if len(examples) > 0 - let name .= '='.examples[0] - endif - call add(arguments, name) - endfor - - - for line in kite#utils#wrap(function_name.'('.join(arguments, ', ').')', wrap_width, 2) - let completion = { - \ 'word': '', - \ 'abbr': indent.line, - \ 'empty': 1, - \ 'equal': 1, - \ 'dup': 1 - \ } - call add(completions, completion) - endfor - endfor - endif - - if mode(1) ==# 'i' - call complete(a:startcol+1, completions) - endif -endfunction - - -function! kite#signature#should_show_popular_patterns() - return kite#utils#get_setting('show_popular_patterns', 0) -endfunction - - - -function! kite#signature#show_popular_patterns() - call kite#utils#set_setting('show_popular_patterns', 1) -endfunction - - -function! kite#signature#hide_popular_patterns() - call kite#utils#set_setting('show_popular_patterns', 0) -endfunction - - -function s:heading(text) - return {'abbr': a:text.':', 'word': '', 'empty': 1, 'dup': 1} -endfunction diff --git a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/snippet.vim b/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/snippet.vim deleted file mode 100755 index a327228..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/snippet.vim +++ /dev/null @@ -1,413 +0,0 @@ -function! s:setup_stack() - if exists('b:kite_stack') | return | endif - - " stack: - " [ - " { index: 0, placeholders: { ... } }, <-- depth 0 - " { index: 0, placeholders: { ... } }, <-- depth 1 - " ... <-- depth n - " ] - " - " index - the currently active placeholder at that depth - let b:kite_stack = {'stack': []} - - function! b:kite_stack.pop() - return remove(self.stack, -1) - endfunction - - function! b:kite_stack.peek() - return get(self.stack, -1) - endfunction - - function! b:kite_stack.push(item) - call add(self.stack, a:item) - endfunction - - function! b:kite_stack.is_empty() - return empty(self.stack) - endfunction - - function! b:kite_stack.empty() - let self.stack = [] - endfunction -endfunction - - -function! kite#snippet#complete_done() - if empty(v:completed_item) | return | endif - call s:setup_stack() - - if has_key(v:completed_item, 'user_data') && !empty(v:completed_item.user_data) - let placeholders = json_decode(v:completed_item.user_data).placeholders - elseif exists('b:kite_completions') && has_key(b:kite_completions, v:completed_item.word) - let placeholders = json_decode(b:kite_completions[v:completed_item.word]).placeholders - let b:kite_completions = {} - else - return - endif - - " Send the edit event. Normally this is sent automatically on TextChanged(I). - " But for some reason this doesn't fire when a completion has a snippet placeholder. - call kite#events#event('edit') - - if empty(placeholders) - if b:kite_stack.is_empty() - return - else - call kite#snippet#next_placeholder() - return - endif - endif - - let b:kite_linenr = line('.') - let b:kite_line_length = col('$') - - call s:setup_maps() - call s:setup_autocmds() - - " Calculate column number (col_begin) of start of each placeholder, and placeholder length. - let inserted_text = v:completed_item.word - let insertion_start = col('.') - strdisplaywidth(inserted_text) - let b:kite_insertion_end = col('.') - - for ph in placeholders - let ph.col_begin = insertion_start + ph.begin - let ph.length = ph.end - ph.begin - unlet ph.begin ph.end - endfor - - " Update placeholder locations. - " - " todo move this into the push() function? - " note this is very similar to s:update_placeholder_locations() - if !b:kite_stack.is_empty() - " current placeholder which has just been completed - let level = b:kite_stack.peek() - let ph = level.placeholders[level.index] - let ph_new_length = col('.') - ph.col_begin - let ph_length_delta = ph_new_length - ph.length - let ph.length = ph_new_length - let marker = ph.col_begin - - " following placeholders at same level - for ph in level.placeholders[level.index+1:] - let ph.col_begin += ph_length_delta - endfor - - " placeholders at outer levels - for level in b:kite_stack.stack[:-2] - for ph in level.placeholders - if ph.col_begin > marker - let ph.col_begin += ph_length_delta - endif - endfor - endfor - endif - - call b:kite_stack.push({'placeholders': placeholders, 'index': 0}) - - " Move to first placeholder. - call s:placeholder(0) -endfunction - - -" Go to next placeholder at current level, if there is one, or first placeholder at next level otherwise. -function! kite#snippet#next_placeholder() - call s:update_placeholder_locations() - call s:placeholder(b:kite_stack.peek().index + 1) -endfunction - - - -function! kite#snippet#previous_placeholder(...) - call s:placeholder(b:kite_stack.peek().index - 1 - (a:0 ? a:1 : 0)) -endfunction - - -" Move to the placeholder at index and select its text. -function! s:placeholder(index) - let index = a:index - - let level = b:kite_stack.peek() - let placeholders = level.placeholders - - " Clear highlights before we pop the stack. - call s:clear_all_placeholder_highlights() - - if index < 0 - " If no other levels in stack - if len(b:kite_stack.stack) == 1 - " Stay with first placeholder and proceed - let index = 0 - else - call b:kite_stack.pop() - call s:placeholder(b:kite_stack.peek().index - 1) - return - endif - endif - - " if navigating forward from last placeholder of current level - if index == len(placeholders) - " If no other levels in stack - if len(b:kite_stack.stack) == 1 - call s:goto_initial_completion_end() - else - call b:kite_stack.pop() - call s:placeholder(b:kite_stack.peek().index + 1) - endif - return - endif - - call s:highlight_current_level_placeholders() - - let level.index = index - let ph = placeholders[index] - - " store line length before placeholder gets changed by user - " let b:kite_line_length = col('$') - - if ph.length == 0 - normal! h - return - endif - - " insert mode -> normal mode - stopinsert - - let linenr = line('.') - call setpos("'<", [0, linenr, ph.col_begin]) - call setpos("'>", [0, linenr, ph.col_begin + ph.length - (mode() == 'n' ? 1 : 0)]) - " normal mode -> visual mode -> select mode - execute "normal! gv\" - if mode() ==# 'S' - execute "normal! \gh" - endif -endfunction - - -function! s:goto_initial_completion_end() - " call setpos('.', [0, b:kite_linenr, b:kite_insertion_end + col('$') - b:kite_line_length - 1]) - call setpos('.', [0, b:kite_linenr, col('$')]) - startinsert! - call s:teardown() -endfunction - - -" Adjust current and subsequent placeholders for the amount of text entered -" at the placeholder we are leaving. -function! s:update_placeholder_locations() - if !exists('b:kite_line_length') | return | endif - - let line_length_delta = col('$') - b:kite_line_length - - " current placeholder - let level = b:kite_stack.peek() - let ph = level.placeholders[level.index] - let marker = ph.col_begin - let ph.length += line_length_delta - - " subsequent placeholders at current level - for ph in level.placeholders[level.index+1:] - let ph.col_begin += line_length_delta - endfor - - " placeholders at outer levels - for level in b:kite_stack.stack[:-2] - for ph in level.placeholders - if ph.col_begin > marker - let ph.col_begin += line_length_delta - endif - endfor - endfor - - let b:kite_line_length = col('$') -endfunction - - -function! s:highlight_current_level_placeholders() - let group = s:highlight_group_for_placeholders() - if empty(group) | return | endif - - let linenr = line('.') - for ph in b:kite_stack.peek().placeholders - let ph.matchid = matchaddpos(group, [[linenr, ph.col_begin, ph.length]]) - endfor -endfunction - - -" Clears highlights of placeholders in the stack. -" -" Note: if we need a way to clear highlights of placeholders which are no -" longer in the stack (because they have been popped) we could use a custom -" highlight group (e.g. KiteUnderline linked to Underline), call getmatches(), -" and remove all matches using the custom highlight group. -function! s:clear_all_placeholder_highlights() - for level in b:kite_stack.stack - for ph in level.placeholders - if has_key(ph, 'matchid') - call matchdelete(ph.matchid) - unlet ph.matchid - endif - endfor - endfor -endfunction - - -" Many plugins use vmap for visual-mode mappings but vmap maps both -" visual-mode and select-mode (they should use xmap instead). Assume any -" visual-mode mappings for printable characters are not wanted and remove them -" (but remember them so we can restore them afterwards). Similarly for map. -" Assume any select-only-mode maps are deliberate. -" -" :help mapmode-s -" :help Select-mode-mapping -function! s:remove_smaps_for_printable_characters() - let b:kite_maps = [] - let printable_keycodes = [ - \ '', - \ '', - \ '', - \ '', - \ '', - \ '', - \ '', - \ '', - \ '' - \ ] - - " Get a list of maps active in select mode. - for scope in ['', ''] - redir => maps | silent execute 'smap' scope | redir END - - let mappings = split(maps, "\n") - - " 'No mapping found' or localised equivalent (starts with capital letter). - if len(mappings) == 1 && mappings[0][0] =~ '\u' | continue | endif - - " Assume select-mode maps are deliberate and ignore them. - call filter(mappings, 'v:val[0:2] !~# "s"') - - for mapping in mappings - let lhs = matchlist(mapping, '\v^...(\S+)\s.*')[1] - " ^^^ ^^^ - " mode lhs - - " Ignore keycodes for non-printable characters, e.g. - if lhs[0] == '<' && index(printable_keycodes, lhs) == -1 | continue | endif - - " Remember the mapping so we can restore it later. - call add(b:kite_maps, maparg(lhs, 's', 0, 1)) - - " Remove the mapping. - silent! execute 'sunmap' scope lhs - endfor - endfor -endfunction - - -function! s:restore_smaps() - for mapping in b:kite_maps - silent! execute mapping.mode . (mapping.noremap ? 'nore' : '') . 'map ' - \ . (mapping.buffer ? ' ' : '') - \ . (mapping.expr ? ' ' : '') - \ . (mapping.nowait ? ' ' : '') - \ . (mapping.silent ? ' ' : '') - \ . mapping.lhs . ' ' - \ . substitute(mapping.rhs, '', ''.mapping.sid.'_', 'g') - endfor - - unlet! b:kite_maps -endfunction - - -function! s:setup_maps() - execute 'inoremap ' g:kite_next_placeholder 'pumvisible() ? "" : ":call kite#snippet#next_placeholder()"' - execute 'inoremap ' g:kite_previous_placeholder 'pumvisible() ? ":call kite#snippet#previous_placeholder(2)" : ":call kite#snippet#previous_placeholder()"' - execute 'snoremap ' g:kite_next_placeholder ':call kite#snippet#next_placeholder()' - execute 'snoremap ' g:kite_previous_placeholder ':call kite#snippet#previous_placeholder()' - - call s:remove_smaps_for_printable_characters() -endfunction - - -function! kite#snippet#teardown_maps() - execute 'silent! iunmap ' g:kite_next_placeholder - execute 'silent! iunmap ' g:kite_previous_placeholder - execute 'silent! sunmap ' g:kite_next_placeholder - execute 'silent! sunmap ' g:kite_previous_placeholder -endfunction - - -function! s:setup_autocmds() - augroup KiteSnippets - autocmd! * - - autocmd CursorMovedI - \ call s:update_placeholder_locations() | - \ call s:clear_all_placeholder_highlights() | - \ call s:highlight_current_level_placeholders() - autocmd CursorMoved,CursorMovedI call s:cursormoved() - autocmd InsertLeave call s:insertleave() - augroup END -endfunction - - -function! s:teardown_autocmds() - autocmd! KiteSnippets * -endfunction - - -" Called to deactivate all placeholders. -function! s:teardown() - call s:clear_all_placeholder_highlights() - call kite#snippet#teardown_maps() - call s:teardown_autocmds() - call s:restore_smaps() - call b:kite_stack.empty() - unlet! b:kite_linenr b:kite_line_length b:kite_insertion_end -endfunction - - -function! s:highlight_group_for_placeholders() - for group in ['Special', 'SpecialKey', 'Underline', 'DiffChange'] - if hlexists(group) - return group - endif - endfor - return '' -endfunction - - -function! s:cursormoved() - if !exists('b:kite_linenr') | return | endif - if b:kite_linenr == line('.') | return | endif - - " TODO check whether the cursor is outside the bounds of the completion? - - call s:teardown() -endfunction - - -function! s:insertleave() - " Modes established by experimentation. - if mode(1) !=# 's' && mode(1) !=# ((has('patch-8.1.0225') || has('nvim-0.4.0')) ? 'niI' : 'n') - call s:teardown() - endif -endfunction - - -function! s:debug_stack() - if b:kite_stack.is_empty() - echom 'stack empty' - return - endif - let i = 0 - for level in b:kite_stack.stack - echom 'level' i - echom ' index' level.index - for pholder in level.placeholders - echom ' '.string(pholder) - endfor - let i += 1 - endfor -endfunction diff --git a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/status.vim b/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/status.vim deleted file mode 100755 index 202c6c5..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/status.vim +++ /dev/null @@ -1,62 +0,0 @@ -" Updates the status of the current buffer. -" -" Optional argument is a timer id (when called by a timer). -function! kite#status#status(...) - if !s:status_in_status_line() | return | endif - - let buf = bufnr('') - let msg = 'NOT SET' - - " Check kited status (installed / running) every 10 file status checks. - let counter = getbufvar(buf, 'kite_status_counter', 0) - if counter == 0 - if !kite#utils#kite_running() - let msg = 'Kite: not running' - if !kite#utils#kite_installed() - let msg = 'Kite: not installed' - endif - endif - endif - call setbufvar(buf, 'kite_status_counter', (counter + 1) % 10) - - if wordcount().bytes > kite#max_file_size() - let msg = 'Kite: file too large' - endif - - if msg !=# 'NOT SET' - if msg !=# getbufvar(buf, 'kite_status') - call setbufvar(buf, 'kite_status', msg) - redrawstatus - endif - return - endif - - let filename = kite#utils#filepath(0) - call kite#client#status(filename, function('kite#status#handler', [buf])) -endfunction - - -function! kite#status#handler(buffer, response) - call kite#utils#log('kite status status: '.a:response.status.', body: '.a:response.body) - if a:response.status != 200 | return | endif - - let json = json_decode(a:response.body) - - let msg = '' - - let suffix = get(json, 'short', 'FIELD MISSING') - if suffix !=# 'FIELD MISSING' - let msg = join(['Kite: ', suffix], '') - endif - - if msg !=# getbufvar(a:buffer, 'kite_status') - call setbufvar(a:buffer, 'kite_status', msg) - redrawstatus - endif -endfunction - - -function! s:status_in_status_line() - return stridx(&statusline, 'kite#statusline()') != -1 -endfunction - diff --git a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/utils.vim b/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/utils.vim deleted file mode 100755 index 0484ff2..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/autoload/kite/utils.vim +++ /dev/null @@ -1,611 +0,0 @@ -" Values for s:os are used in plugin directory structure -" and also metric values. -if has('win64') || has('win32') || has('win32unix') - let s:os = 'windows' -else - let s:os = empty(findfile('/sbin/launchd')) ? 'linux' : 'macos' -endif - -function! kite#utils#windows() - return s:os ==# 'windows' -endfunction - -function! kite#utils#macos() - return s:os ==# 'macos' -endfunction - -let s:separator = !exists('+shellslash') || &shellslash ? '/' : '\' -let s:plugin_dir = expand(':p:h:h:h') -let s:doc_dir = s:plugin_dir.s:separator.'doc' -let s:lib_dir = s:plugin_dir.s:separator.'lib' -let s:lib_subdir = s:lib_dir.s:separator.(s:os) -let s:vim_version = '' -let s:plugin_version = '' - - -function! kite#utils#vim_version() - if !empty(s:vim_version) - return s:vim_version - endif - let s:vim_version = kite#utils#normalise_version(execute('version')) - return s:vim_version -endfunction - - -function! kite#utils#normalise_version(version) - let lines = split(a:version, '\n') - - if lines[0] =~ 'NVIM' - " Or use api_info().version. - return lines[0] " e.g. NVIM v0.2.2 - else - let [major, minor] = matchlist(lines[0], '\v(\d)\.(\d+)')[1:2] - - let patch_line = match(lines, ': \d') - if patch_line == -1 - let patches = '0' - else - let patches = substitute(split(lines[patch_line], ': ')[1], ' ', '', 'g') - endif - return join([major, minor, patches], '.') " e.g. 8.1.1-582 - endif -endfunction - - -function! kite#utils#plugin_version() - if !empty(s:plugin_version) - return s:plugin_version - endif - - let s:plugin_version = readfile(s:plugin_dir.s:separator.'VERSION')[0] - - return s:plugin_version -endfunction - - -" From tpope/vim-fugitive -function! s:winshell() - return kite#utils#windows() && &shellcmdflag !~# '^-' -endfunction - - -function! kite#utils#browse(url) - if kite#utils#windows() - let cmd = 'cmd /c start "" "'.a:url.'"' - else - let cmd = 'open "'.a:url.'"' - endif - silent call system(cmd) -endfunction - - -" From tpope/vim-fugitive -function! s:shellescape(arg) - if a:arg =~ '^[A-Za-z0-9_/.-]\+$' - return a:arg - elseif s:winshell() - return '"'.substitute(substitute(a:arg, '"', '""', 'g'), '%', '"%"', 'g').'"' - else - return shellescape(a:arg) - endif -endfunction - -if kite#utils#windows() - let s:settings_dir = join([$LOCALAPPDATA, 'Kite'], s:separator) -else - let s:settings_dir = expand('~/.kite') -endif -if !isdirectory(s:settings_dir) - call mkdir(s:settings_dir, 'p') -endif -let s:settings_path = s:settings_dir.s:separator.'vim-plugin.json' - - -" Get the value for the given key. -" If the key has not been set, returns the default value if given -" (i.e. the optional argument) or -1 otherwise. -function! kite#utils#get_setting(key, ...) - let settings = s:settings() - return get(settings, a:key, (a:0 ? a:1 : -1)) -endfunction - -" Sets the value for the key. -function! kite#utils#set_setting(key, value) - let settings = s:settings() - let settings[a:key] = a:value - let json_str = json_encode(settings) - call writefile([json_str], s:settings_path) -endfunction - -function! s:settings() - if filereadable(s:settings_path) - let json_str = join(readfile(s:settings_path), '') - return json_decode(json_str) - else - return {} - endif -endfunction - - -function! kite#utils#os() - return s:os -endfunction - - -function! kite#utils#lib(filename) - return s:lib_subdir.s:separator.a:filename -endfunction - - -function! kite#utils#kite_installed() - return !empty(s:kite_install_path()) -endfunction - -" Returns the kite installation path including the filename, or an empty string if not installed. -function! s:kite_install_path() - if kite#utils#windows() - let output = kite#async#sync('reg query HKEY_LOCAL_MACHINE\Software\Kite\AppData /v InstallPath /s /reg:64') - let lines = filter(split(output, '\n'), 'v:val =~ "InstallPath"') - if empty(lines) - return '' - endif - return substitute(lines[0], '\v^\s+InstallPath\s+REG_\w+\s+', '', '').s:separator.'kited.exe' - elseif kite#utils#macos() - return kite#async#sync('mdfind ''kMDItemCFBundleIdentifier = "com.kite.Kite" || kMDItemCFBundleIdentifier = "enterprise.kite.Kite"''') - else - let path = exepath('/opt/kite/kited') - if !empty(path) - return path - endif - let path = exepath(expand('~/.local/share/kite/kited')) - if !empty(path) - return path - endif - return '' - endif -endfunction - - -function! kite#utils#kite_running() - if kite#utils#windows() - let [cmd, process] = ['tasklist /FI "IMAGENAME eq kited.exe"', '^kited.exe'] - elseif kite#utils#macos() - let [cmd, process] = ['ps -axco command', '^Kite$'] - else - let process_name = empty($KITED_TEST_PORT) ? 'kited' : 'kited-test' - let [cmd, process] = ['ps -axco command', '^'.process_name.'$'] - endif - - return match(split(kite#async#sync(cmd), '\n'), process) > -1 -endfunction - - -function! kite#utils#launch_kited() - if kite#utils#kite_running() - return - endif - - let path = s:kite_install_path() - - if empty(path) - return - endif - - if kite#utils#windows() - let $KITE_SKIP_ONBOARDING = 1 - silent execute "!start" s:shellescape(path) - elseif kite#utils#macos() - call system('open -a '.path.' --args "--plugin-launch"') - else - silent execute '!'.path.' --plugin-launch >/dev/null 2>&1 &' - endif -endfunction - - -" msg - a list or a string -function! kite#utils#log(msg) - if g:kite_log - if type(a:msg) == v:t_string - let msg = [a:msg] - else - let msg = a:msg - endif - call writefile(msg, 'kite-vim.log', 'a') - endif -endfunction - - -function! kite#utils#warn(msg) - echohl WarningMsg - echom 'Kite: '.a:msg - echohl None - let v:warningmsg = a:msg -endfunction - - -function! kite#utils#info(msg) - echohl Question - echom a:msg - echohl None -endfunction - - -" Returns the absolute path to the current file after resolving symlinks. -" -" url_format - when truthy, return the path in a URL-compatible format. -function! kite#utils#filepath(url_format) - let path = resolve(expand('%:p')) - - if a:url_format - let path = substitute(path, '[\/]', ':', 'g') - if kite#utils#windows() - let path = substitute(path, '^\(\a\)::', '\1:', '') - let path = ':windows:'.path - endif - let path = kite#utils#url_encode(path) - endif - - return path -endfunction - - -" Returns a 2-element list of 0-based character indices into the buffer. -" -" When no text is selected, both elements are the cursor position. -" -" When text is selected, the elements are the start (inclusive) and -" end (exclusive) of the selection. -" -" Returns [-1, -1] when not in normal, insert, or visual mode. -function! kite#utils#selected_region_characters() - return s:selected_region('c') -endfunction - - -" Returns a 2-element list of 0-based byte indices into the buffer. -" -" When no text is selected, both elements are the cursor position. -" -" When text is selected, the elements are the start (inclusive) and -" end (exclusive) of the selection. -" -" Returns [-1, -1] when not in normal, insert, or visual mode. -function! kite#utils#selected_region_bytes() - return s:selected_region('b') -endfunction - - -" Returns a 2-element list of 0-based indices into the buffer. -" -" When no text is selected, both elements are the cursor position. -" -" When text is selected, the elements are the start (inclusive) and -" end (exclusive) of the selection. -" -" Returns [-1, -1] when not in normal, insert, or visual mode. -" -" param type (String) - 'c' for character indices, 'b' for byte indices -" -" NOTE: the cursor is moved during the function (but finishes where it started). -function! s:selected_region(type) - if mode() ==# 'n' || mode() ==# 'i' - if a:type == 'c' - let offset = kite#utils#character_offset() - else - let offset = kite#utils#byte_offset_start() - endif - return [offset, offset] - endif - - if mode() ==? 'v' - let pos_start = getpos('v') - let pos_end = getpos('.') - - if (pos_start[1] > pos_end[1]) || (pos_start[1] == pos_end[1] && pos_start[2] > pos_end[2]) - let [pos_start, pos_end] = [pos_end, pos_start] - endif - - " switch to normal mode - execute "normal! \" - - call setpos('.', pos_start) - if a:type == 'c' - let offset1 = kite#utils#character_offset() - else - let offset1 = kite#utils#byte_offset_start() - endif - - call setpos('.', pos_end) - " end position is exclusive - if a:type == 'c' - let offset2 = kite#utils#character_offset() + 1 - else - let offset2 = kite#utils#byte_offset_end() + 1 - endif - - " restore visual selection - normal! gv - - return [offset1, offset2] - endif - - return [-1, -1] -endfunction - - -" Returns the 0-based index of the cursor in the buffer. -" -" Returns -1 when the buffer is empty. -function! kite#utils#cursor_characters() - if mode() ==? 'v' - " switch to normal mode - execute "normal! \" - - let cursor = kite#utils#character_offset() - - " restore visual selection - normal! gv - - return cursor - endif - - return kite#utils#character_offset() -endfunction - - -" Returns the 0-based index into the buffer of the cursor position. -" Returns -1 when the buffer is empty. -" -" Does not work in visual mode. -function! kite#utils#character_offset() - " wordcount().cursor_chars is 1-based so we need to subtract 1. - let offset = wordcount().cursor_chars - 1 - - " In insert mode the cursor isn't really between two characters; - " it is actually on the second character, but that's what we want - " anyway. - - " If the cursor is just before (i.e. on) the end of the line, and - " the file has dos line endings, wordcount().cursor_chars will - " regard the cursor as on the second character of the \r\n. In this - " case we want the offset of the first, i.e. the \r. - - if col('.') == col('$') && &ff ==# 'dos' - let offset -= 1 - endif - - return offset -endfunction - - -" Returns the 0-based index into the buffer of the cursor position. -" If the cursor is on a multibyte character, it reports the character's -" first byte. -function! kite#utils#byte_offset_start() - let offset = line2byte(line('.')) - 1 + col('.') - 1 - if offset < 0 - let offset = 0 - endif - return offset -endfunction - -" Returns the 0-based index into the buffer of the cursor position. -" If the cursor is on a multibyte character, it reports the character's -" last byte. -function! kite#utils#byte_offset_end() - let offset = wordcount().cursor_bytes - 1 - if offset < 0 - let offset = 0 - endif - return offset -endfunction - - -function! kite#utils#buffer_contents() - let line_ending = {"unix": "\n", "dos": "\r\n", "mac": "\r"}[&fileformat] - return join(getline(1, '$'), line_ending).(&eol ? line_ending : '') -endfunction - - -" Similar to the goto command, but for characters. -" index is 1-based, the start of the file. -function! kite#utils#goto_character(index) - call search('\m\%^\_.\{'.a:index.'}', 'es') - - " The search() function above counts a newline as 1 character even if it is - " actually 2. Therefore we need to adjust the cursor position when newlines - " are 2 characters. - if &ff ==# 'dos' - let [_whichwrap, &whichwrap] = [&whichwrap, "h,l"] - let delta = wordcount().cursor_chars - a:index - while delta != 0 - " Cannot land on a newline character. - if (delta == -1 || delta == -2) && col('.') == col('$') - 1 - break - endif - execute "normal! ".delta.(delta > 0 ? 'h' : 'l') - let delta = wordcount().cursor_chars - a:index - endwhile - let &whichwrap = _whichwrap - endif -endfunction - - -" Returns the MD5 hash of the buffer contents. -function! kite#utils#buffer_md5() - return s:MD5(kite#utils#buffer_contents()) -endfunction - - -" https://github.com/tpope/vim-unimpaired/blob/3a7759075cca5b0dc29ce81f2747489b6c8e36a7/plugin/unimpaired.vim#L327-L329 -function! kite#utils#url_encode(str) - return substitute(a:str,'[^A-Za-z0-9_.~-]','\="%".printf("%02X",char2nr(submatch(0)))','g') -endfunction - - -" Capitalises the first letter of str. -function! kite#utils#capitalize(str) - return substitute(a:str, '^.', '\u\0', '') -endfunction - - -function! kite#utils#map_join(list, prop, sep) - return join(map(copy(a:list), {_,v -> v[a:prop]}), a:sep) -endfunction - - -" Returns a list of lines, each no longer than length. -" The last line may be longer than length if it has no spaces. -" Assumes str is a constructor or function call. -" -" Example: json.dumps -" -" dumps(obj, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, encoding, default, sort_keys, *args, **kwargs) -" -" - becomes when wrapped: -" -" dumps(obj, skipkeys, ensure_ascii, check_circular, -" allow_nan, cls, indent, separators, encoding, -" default, sort_keys, *args, **kwargs) -" -function! kite#utils#wrap(str, length, indent) - let lines = [] - - let str = a:str - let [prefix; str] = split(a:str, '(\zs') - let str = join(str) - - while v:true - let line = prefix.str - - if len(line) <= a:length - call add(lines, line) - break - endif - - let i = strridx(str[0:a:length-len(prefix)], ' ') - - if i == -1 - call add(lines, line) - break - endif - - let line = prefix . str[0:i-1] - call add(lines, line) - let str = str[i+1:] - - let prefix = repeat(' ', a:indent) - endwhile - - return lines -endfunction - - -function! kite#utils#coerce(dict, key, default) - if has_key(a:dict, a:key) - let v = a:dict[a:key] - if type(v) == type(a:default) " check type in case of null - return v - endif - endif - return a:default -endfunction - - -function! kite#utils#present(dict, key) - return has_key(a:dict, a:key) && !empty(a:dict[a:key]) -endfunction - - -" Returns a string of the given length. -" -" If length is 0 or negative, returns an empty string. -" -" If text is less than length, it is padded with leading spaces so that it is -" right-aligned. -" -" If text is greater than length, it is truncated with an ellipsis. -" If there isn't room for an ellipsis, or room for only an ellipsis, empty spaces are used. -function! kite#utils#ralign(text, length) - if a:length <= 0 - return '' - endif - - let text_width = strdisplaywidth(a:text) - - " The required length - if text_width == a:length - return a:text - endif - - " Less than the required length: left-pad - if text_width < a:length - return repeat(' ', a:length-text_width) . a:text - endif - - " Greater than the required length: truncate - - if kite#utils#windows() - let ellipsis = '...' - else - let ellipsis = '…' - endif - let ellipsis_width = strdisplaywidth(ellipsis) - - if ellipsis_width >= a:length - return repeat(' ', a:length) - endif - - return a:text[: a:length-ellipsis_width-1] . ellipsis -endfunction - - -function! kite#utils#truncate(text, length) - let text_width = strdisplaywidth(a:text) - - if text_width <= a:length - return a:text - endif - - if kite#utils#windows() - let ellipsis = '...' - else - let ellipsis = '…' - endif - let ellipsis_width = strdisplaywidth(ellipsis) - - if ellipsis_width >= a:length - return a:text[0] . ellipsis[0: a:length-2] - endif - - return a:text[: a:length-ellipsis_width-1] . ellipsis -endfunction - - -function! s:chomp(str) - return substitute(a:str, '\n$', '', '') -endfunction - - -function! s:md5(text) - return s:chomp(system('md5', a:text)) -endfunction - -function! s:md5sum(text) - return split(system('md5sum', a:text), ' ')[0] -endfunction - -function! s:md5bin(text) - return s:chomp(system(s:md5_binary, a:text)) -endfunction - - -if executable('md5') - let s:MD5 = function('s:md5') -elseif executable('md5sum') - let s:MD5 = function('s:md5sum') -else - let s:md5_binary = kite#utils#lib('md5Sum.exe') - let s:MD5 = function('s:md5bin') -endif - diff --git a/vim/.vim/pack/kite/start/vim-plugin/doc/kite.txt b/vim/.vim/pack/kite/start/vim-plugin/doc/kite.txt deleted file mode 100755 index 7b6d8eb..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/doc/kite.txt +++ /dev/null @@ -1,35 +0,0 @@ -*kite.txt* Kite for VIM - - -Kite for VIM -============ - -VIM is now integrated with Kite! To get a taste of what Kite can do, open a -saved Python file and start coding away. - -1. Autocompletions - -As you code, Kite will provide autocompletion suggestions ranked by popularity -using all the open source code on GitHub. - -2. Documentation - -Press |K| when your cursor is over a identifier to open a split window with -documentation about the identifier. In addition to documentation, Kite also -provides information about where you've used the identifier in your codebase, -as well as curated code examples showing you how to use the identifier. - -3. Goto Definition - -Press |C-]| to jump to a method's defintion. - -4. Copilot integration - -While you code in VIM, the Copilot will automatically show you information -about the code that you're currently working with. To open the Copilot, click -on the Kite menubar icon and select "Open Copilot". - -To learn more about Kite and how to use the VIM plugin, visit our [help -page](http://help.kite.com). - - vim:tw=78:et:ft=help:norl diff --git a/vim/.vim/pack/kite/start/vim-plugin/lib/linux/kite-http b/vim/.vim/pack/kite/start/vim-plugin/lib/linux/kite-http deleted file mode 100755 index bfd3ced..0000000 Binary files a/vim/.vim/pack/kite/start/vim-plugin/lib/linux/kite-http and /dev/null differ diff --git a/vim/.vim/pack/kite/start/vim-plugin/lib/macos/kite-http b/vim/.vim/pack/kite/start/vim-plugin/lib/macos/kite-http deleted file mode 100755 index 0bed133..0000000 Binary files a/vim/.vim/pack/kite/start/vim-plugin/lib/macos/kite-http and /dev/null differ diff --git a/vim/.vim/pack/kite/start/vim-plugin/lib/windows/kite-http.exe b/vim/.vim/pack/kite/start/vim-plugin/lib/windows/kite-http.exe deleted file mode 100755 index 69b4611..0000000 Binary files a/vim/.vim/pack/kite/start/vim-plugin/lib/windows/kite-http.exe and /dev/null differ diff --git a/vim/.vim/pack/kite/start/vim-plugin/lib/windows/md5Sum.exe b/vim/.vim/pack/kite/start/vim-plugin/lib/windows/md5Sum.exe deleted file mode 100755 index eab8024..0000000 Binary files a/vim/.vim/pack/kite/start/vim-plugin/lib/windows/md5Sum.exe and /dev/null differ diff --git a/vim/.vim/pack/kite/start/vim-plugin/plugin/kite.vim b/vim/.vim/pack/kite/start/vim-plugin/plugin/kite.vim deleted file mode 100755 index 4ef2c34..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/plugin/kite.vim +++ /dev/null @@ -1,105 +0,0 @@ -if exists('g:loaded_kite') || &cp - finish -endif - -if has('nvim') - if !has('nvim-0.3') - echoerr 'Kite requires Neovim 0.3 or greater' - finish - endif -else - if v:version < 800 || !has('patch-8.0.0027') - echoerr 'Kite requires Vim 8.0.0027 or greater' - finish - endif -endif - - -let g:loaded_kite = 1 - - -filetype on - - -" The list of languages / file types for which we want Kite's completions. -if !exists('g:kite_supported_languages') - let g:kite_supported_languages = ['python'] -endif - -if !exists('g:kite_auto_complete') - let g:kite_auto_complete = 1 -endif - -if !exists('g:kite_snippets') - let g:kite_snippets = 1 -endif - -if !exists('g:kite_previous_placeholder') - let g:kite_previous_placeholder = '' -endif - -if !exists('g:kite_next_placeholder') - let g:kite_next_placeholder = '' -endif - -if !exists('g:kite_documentation_continual') - let g:kite_documentation_continual = 0 -endif - -if !exists('g:kite_completions') - let g:kite_completions = 1 -endif - -if !exists('g:kite_log') - let g:kite_log = 0 -endif - -if !exists('g:kite_short_timeout') - let g:kite_short_timeout = 120 " ms -endif - -if !exists('g:kite_long_timeout') - let g:kite_long_timeout = 400 " ms -endif - -if !exists('g:kite_completion_max_width') - let g:kite_completion_max_width = 75 -endif - -if !(has('nvim') || has('job')) - call kite#utils#warn('disabled - requires nvim or vim with the +job feature') - finish -endif - -if !(has('nvim') || has('timers')) - call kite#utils#warn('disabled - requires nvim or vim with the +timers feature') - finish -endif - -" Nvim-QT -if exists('g:GuiLoaded') - GuiPopupmenu 0 -endif - -augroup Kite - autocmd! - autocmd BufEnter * call kite#bufenter() - autocmd VimEnter * if g:kite_completions | call kite#configure_completeopt() | endif - autocmd VimEnter * nested if kite#utils#kite_running() && &filetype !~# '^git' | call kite#onboarding#call(0) | endif -augroup END - - -nnoremap (kite-docs) :call kite#docs#docs() - -command! KiteDocsAtCursor call kite#docs#docs() -command! KiteOpenCopilot call kite#client#copilot() -command! KiteGeneralSettings call kite#client#settings() -command! KitePermissions call kite#client#permissions() -command! KiteTutorial call kite#onboarding#call(1) -command! KiteDisableAutoStart call kite#disable_auto_start() -command! KiteEnableAutoStart call kite#enable_auto_start() -command! KiteShowPopularPatterns call kite#signature#show_popular_patterns() -command! KiteHidePopularPatterns call kite#signature#hide_popular_patterns() -command! KiteGotoDefinition call kite#hover#goto_definition() -command! KiteFindRelatedCodeFromFileExperimental call kite#codenav#from_file() -command! KiteFindRelatedCodeFromLineExperimental call kite#codenav#from_line() diff --git a/vim/.vim/pack/kite/start/vim-plugin/syntax/kite.vim b/vim/.vim/pack/kite/start/vim-plugin/syntax/kite.vim deleted file mode 100755 index 781d562..0000000 --- a/vim/.vim/pack/kite/start/vim-plugin/syntax/kite.vim +++ /dev/null @@ -1,27 +0,0 @@ -if exists('b:current_syntax') - finish -endif - - -" Section headings -syntax match kiteHeading /\v^[A-Z* ]+$/ -highlight link kiteHeading String - - -" Usages / Definitions -syntax include @python syntax/python.vim -syntax region kiteSnippet start=/\v^\[.+:\d+\]/ end=/$/ keepend contains=kiteRef,kiteCode -syntax match kiteRef /\v^\[.+:\d+\]/ contained -syntax region kiteCode start=/ / end=/$/ contains=@python contained -highlight link kiteRef Comment - - -" Links -syntax region MyLink start=/^-> /hs=e end=/\v(\s\(\a+[.]\a{2,3}\))?$/he=s-1 contains=Domain -syntax match Domain /\v\(\a+[.]\a{2,3}\)/ -highlight link MyLink Underlined -highlight link Domain Comment - - -let b:current_syntax = 'kite' - diff --git a/vim/.vimrc b/vim/.vimrc deleted file mode 100755 index a805416..0000000 --- a/vim/.vimrc +++ /dev/null @@ -1,81 +0,0 @@ -" Disable Terminus Focus Reporting -let g:TerminusFocusReporting = 0 - -" Set Molokai theme options -let g:molokai_original = 1 - -" Set indenting preferences -set autoindent -set expandtab -set tabstop=4 -set shiftwidth=4 - -" Add fzf to runtime path -set rtp+=/usr/local/opt/fzf - -" Set terminal title and title string -set title -set titlestring=%<%F\ -\ (%{expand('%:p:h')}) - -" Enable line numbers -set number - -" Enable syntax highlighting -syntax on - -" Enable file type detection and plugin support -filetype plugin indent on - -" Show matching brackets -set showmatch - -" Enable incremental search -set incsearch - -" Enable search highlighting -set hlsearch - -" Ignore case while searching -set ignorecase - -" Override ignorecase if search pattern contains upper case -set smartcase - -" Enable clipboard to use system clipboard -set clipboard=unnamedplus - -" Display incomplete commands -set showcmd - -" Show the mode you're in -set showmode - -" Set wildmenu for command-line completion -set wildmenu - -" Better display for messages -set cmdheight=2 - -" Auto read when a file is changed from outside -set autoread - -" Use spaces instead of tabs -set expandtab - -" Remember cursor position for each file -if has("autocmd") - au BufReadPost * - \ if line("'\"") > 1 && line("'\"") <= line("$") | - \ exe "normal! g'\"" | - \ endif -endif - -" Automatically reload files changed outside of Vim -set autoread -autocmd FocusGained,BufEnter * checktime - -" Map leader key to space -let mapleader = " " - -" Map :W to :w -command! W w diff --git a/yabai/.config/yabai/yabairc b/yabai/.config/yabai/yabairc index abfceb9..4697575 100755 --- a/yabai/.config/yabai/yabairc +++ b/yabai/.config/yabai/yabairc @@ -1,35 +1,30 @@ #!/usr/bin/env sh # Global settings -yabai -m config mouse_follows_focus off -yabai -m config focus_follows_mouse off -yabai -m config window_placement second_child -yabai -m config window_topmost off -yabai -m config window_opacity off -yabai -m config window_opacity_duration 0.0 -yabai -m config window_shadow off +yabai -m config mouse_follows_focus off +yabai -m config focus_follows_mouse off +yabai -m config window_placement second_child +# yabai -m config window_topmost off +yabai -m config window_opacity off +yabai -m config window_opacity_duration 0.0 +yabai -m config window_shadow off # Uncomment the following line to disable window borders # yabai -m config window_border off -yabai -m config window_border_width 2 +# yabai -m config window_border_width 2 -yabai -m config active_window_opacity 1.0 -yabai -m config normal_window_opacity 0.75 -yabai -m config split_ratio 0.65 -yabai -m config auto_balance on -yabai -m config mouse_modifier fn -yabai -m config mouse_action1 move -yabai -m config mouse_action2 resize +yabai -m config active_window_opacity 1.0 +yabai -m config normal_window_opacity 0.75 +yabai -m config split_ratio 0.65 +yabai -m config auto_balance on +yabai -m config mouse_modifier fn +yabai -m config mouse_action1 move +yabai -m config mouse_action2 resize # General space settings -yabai -m config layout bsp -yabai -m config top_padding 1 -yabai -m config bottom_padding 50 -yabai -m config left_padding 5 -yabai -m config right_padding 5 -yabai -m config window_gap 3 - -# Space-specific settings -yabai -m config --space 2 window_gap 0 - -echo "yabai configuration loaded.." +yabai -m config layout bsp +yabai -m config top_padding 1 +yabai -m config bottom_padding 50 +yabai -m config left_padding 5 +yabai -m config right_padding 5 +yabai -m config window_gap 3