diff --git a/.vimrc b/.vimrc index 38a857f8..d27efe11 100644 --- a/.vimrc +++ b/.vimrc @@ -93,7 +93,12 @@ set fileencodings=utf8,ucs-bom,gbk,cp936,gb2312,gb18030 " gvim/macvim设置 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" if has("gui_running") - set guifont=Droid\ Sans\ Mono\ Nerd\ Font\ Complete:h18 " 设置字体 + let system = system('uname -s') + if system == "Darwin\n" + set guifont=Droid\ Sans\ Mono\ Nerd\ Font\ Complete:h18 " 设置字体 + else + set guifont=DroidSansMono\ Nerd\ Font\ Regular\ 18 " 设置字体 + endif set guioptions-=m " 隐藏菜单栏 set guioptions-=T " 隐藏工具栏 set guioptions-=L " 隐藏左侧滚动条 @@ -103,6 +108,16 @@ if has("gui_running") set guicursor=n-v-c:ver5 " 设置光标为竖线 endif +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" 卸载默认插件UnPlug +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +function! s:deregister(repo) + let repo = substitute(a:repo, '[\/]\+$', '', '') + let name = fnamemodify(repo, ':t:s?\.git$??') + call remove(g:plugs, name) +endfunction +command! -nargs=1 -bar UnPlug call s:deregister() + """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 插件列表 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -114,16 +129,14 @@ Plug 'chxuan/change-colorscheme' Plug 'chxuan/prepare-code' Plug 'chxuan/vim-buffer' Plug 'chxuan/vimplus-startify' -Plug 'chxuan/tagbar' +Plug 'preservim/tagbar' Plug 'Valloric/YouCompleteMe' Plug 'Yggdroot/LeaderF' Plug 'mileszs/ack.vim' Plug 'easymotion/vim-easymotion' Plug 'haya14busa/incsearch.vim' -Plug 'iamcco/mathjax-support-for-mkdp' -Plug 'iamcco/markdown-preview.vim' Plug 'jiangmiao/auto-pairs' -Plug 'scrooloose/nerdtree' +Plug 'preservim/nerdtree' Plug 'tiagofumo/vim-nerdtree-syntax-highlight' Plug 'Xuyuanp/nerdtree-git-plugin' Plug 'godlygeek/tabular' @@ -146,19 +159,25 @@ Plug 'sgur/vim-textobj-parameter' Plug 'Shougo/echodoc.vim' Plug 'terryma/vim-smooth-scroll' Plug 'rhysd/clever-f.vim' -Plug 'rhysd/github-complete.vim' Plug 'vim-scripts/indentpython.vim' -call plug#end() +" 加载自定义插件 +if filereadable(expand($HOME . '/.vimrc.custom.plugins')) + source $HOME/.vimrc.custom.plugins +endif + +call plug#end() " load vim default plugin runtime macros/matchit.vim -" 编辑vimrc文件 +" 编辑vimrc相关配置文件 nnoremap e :edit $MYVIMRC +nnoremap vc :edit ~/.vimrc.custom.config +nnoremap vp :edit ~/.vimrc.custom.plugins " 查看vimplus的help文件 -nnoremap h :edit ~/.vimplus/help.md +nnoremap h :view +let\ &l:modifiable=0 ~/.vimplus/help.md " 打开当前光标所在单词的vim帮助文档 nnoremap H :execute ":help " . expand("") @@ -177,10 +196,16 @@ nnoremap k nnoremap h nnoremap l +" 复制当前选中到系统剪切板 +vmap y "+y + +" 将系统剪切板内容粘贴到vim +nnoremap p "+p + " 打开文件自动定位到最后编辑的位置 autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | execute "normal! g'\"" | endif -" 主题 +" 主题设置 set background=dark let g:onedark_termcolors=256 colorscheme onedark @@ -204,6 +229,8 @@ nnoremap U :GoToFunImpl nnoremap a :Switch nnoremap fp :FormatFunParam nnoremap if :FormatIf +nnoremap t dd :GenTryCatch +xnoremap t d :GenTryCatch " change-colorscheme nnoremap :PreviousColorScheme @@ -232,7 +259,6 @@ nnoremap r :ReplaceTo " nerdtree nnoremap n :NERDTreeToggle -inoremap n :NERDTreeToggle let g:NERDTreeFileExtensionHighlightFullName = 1 let g:NERDTreeExactMatchHighlightFullName = 1 let g:NERDTreePatternMatchHighlightFullName = 1 @@ -242,14 +268,28 @@ let g:NERDTreeDirArrowExpandable='▷' let g:NERDTreeDirArrowCollapsible='▼' " YCM +" 如果不指定python解释器路径,ycm会自己搜索一个合适的(与编译ycm时使用的python版本匹配) +" let g:ycm_server_python_interpreter = '/usr/bin/python2.7' let g:ycm_confirm_extra_conf = 0 let g:ycm_error_symbol = '✗' let g:ycm_warning_symbol = '✹' let g:ycm_seed_identifiers_with_syntax = 1 let g:ycm_complete_in_comments = 1 let g:ycm_complete_in_strings = 1 -let g:ycm_server_python_interpreter = '/usr/bin/python' -let g:ycm_python_binary_path = 'python' +let g:ycm_collect_identifiers_from_tags_files = 1 +let g:ycm_semantic_triggers = { + \ 'c' : ['->', '.','re![_a-zA-z0-9]'], + \ 'objc' : ['->', '.', 're!\[[_a-zA-Z]+\w*\s', 're!^\s*[^\W\d]\w*\s', + \ 're!\[.*\]\s'], + \ 'ocaml' : ['.', '#'], + \ 'cpp,objcpp' : ['->', '.', '::','re![_a-zA-Z0-9]'], + \ 'perl' : ['->'], + \ 'php' : ['->', '::'], + \ 'cs,java,javascript,typescript,d,python,perl6,scala,vb,elixir,go' : ['.'], + \ 'ruby' : ['.', '::'], + \ 'lua' : ['.', ':'], + \ 'erlang' : [':'], + \ } nnoremap u :YcmCompleter GoToDeclaration " 已经使用cpp-mode插件提供的转到函数实现的功能 " nnoremap i :YcmCompleter GoToDefinition @@ -257,69 +297,36 @@ nnoremap o :YcmCompleter GoToInclude nnoremap ff :YcmCompleter FixIt nmap :YcmDiags -" ctags -set tags+=/usr/include/tags -set tags+=~/.vim/systags -set tags+=~/.vim/x86_64-linux-gnu-systags -let g:ycm_collect_identifiers_from_tags_files = 1 -let g:ycm_semantic_triggers = { - \ 'c' : ['->', '.','re![_a-zA-z0-9]'], - \ 'objc' : ['->', '.', 're!\[[_a-zA-Z]+\w*\s', 're!^\s*[^\W\d]\w*\s', - \ 're!\[.*\]\s'], - \ 'ocaml' : ['.', '#'], - \ 'cpp,objcpp' : ['->', '.', '::','re![_a-zA-Z0-9]'], - \ 'perl' : ['->'], - \ 'php' : ['->', '::'], - \ 'cs,java,javascript,typescript,d,python,perl6,scala,vb,elixir,go' : ['.'], - \ 'ruby' : ['.', '::'], - \ 'lua' : ['.', ':'], - \ 'erlang' : [':'], - \ } -let g:ycm_semantic_triggers.c = ['->', '.', ' ', '(', '[', '&',']'] - " tagbar let g:tagbar_width = 30 nnoremap t :TagbarToggle -inoremap t :TagbarToggle " incsearch.vim map / (incsearch-forward) map ? (incsearch-backward) map g/ (incsearch-stay) -" markdown -let uname = system('uname -s') -if uname == "Darwin\n" - let g:mkdp_path_to_chrome = "/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome" -else - let g:mkdp_path_to_chrome = '/usr/bin/google-chrome-stable %U' -endif -nmap MarkdownPreview -imap MarkdownPreview -nmap StopMarkdownPreview -imap StopMarkdownPreview - " vim-easymotion let g:EasyMotion_smartcase = 1 map w (easymotion-bd-w) nmap w (easymotion-overwin-w) " nerdtree-git-plugin -let g:NERDTreeIndicatorMapCustom = { - \ "Modified" : "✹", - \ "Staged" : "✚", - \ "Untracked" : "✭", - \ "Renamed" : "➜", - \ "Unmerged" : "═", - \ "Deleted" : "✖", - \ "Dirty" : "✗", - \ "Clean" : "✔︎", - \ 'Ignored' : '☒', - \ "Unknown" : "?" - \ } +let g:NERDTreeGitStatusIndicatorMapCustom = { + \ "Modified" : "✹", + \ "Staged" : "✚", + \ "Untracked" : "✭", + \ "Renamed" : "➜", + \ "Unmerged" : "═", + \ "Deleted" : "✖", + \ "Dirty" : "✗", + \ "Clean" : "✔︎", + \ 'Ignored' : '☒', + \ "Unknown" : "?" + \ } " LeaderF -nnoremap f :LeaderfFile ~ +nnoremap f :LeaderfFile . let g:Lf_WildIgnore = { \ 'dir': ['.svn','.git','.hg','.vscode','.wine','.deepinwine','.oh-my-zsh'], \ 'file': ['*.sw?','~$*','*.bak','*.exe','*.o','*.so','*.py[co]'] @@ -347,7 +354,9 @@ nnoremap g :GV nnoremap G :GV! nnoremap gg :GV? -" 个性化 -if filereadable(expand($HOME . '/.vimrc.local')) - source $HOME/.vimrc.local +" 加载自定义配置 +if filereadable(expand($HOME . '/.vimrc.custom.config')) + source $HOME/.vimrc.custom.config endif + + diff --git a/.vimrc.custom.config b/.vimrc.custom.config new file mode 100644 index 00000000..89cf8d63 --- /dev/null +++ b/.vimrc.custom.config @@ -0,0 +1,40 @@ + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" 用户自定义配置(该文件放一般性配置,可覆盖~/.vimrc里的配置,若要增加、卸载插件,请放入~/.vimrc.custom.plugins) +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" 开启相对行号 +" set relativenumber + +" 开启鼠标 +" set mouse=a + +" 设置光标所在列高亮 +" set cursorcolumn + +" indentLine 开启代码对齐线 +" let g:indentLine_enabled = 1 + +" markdown +" let system = system('uname -s') +" if system == "Darwin\n" +" let g:mkdp_path_to_chrome = "/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome" +" else +" let g:mkdp_path_to_chrome = '/usr/bin/google-chrome-stable %U' +" endif +" nmap MarkdownPreview +" imap MarkdownPreview +" nmap StopMarkdownPreview +" imap StopMarkdownPreview + +" Doxygen +" let g:DoxygenToolkit_authorName="chxuan, 787280310@qq.com" +" let s:licenseTag = "Copyright(C)\" +" let s:licenseTag = s:licenseTag . "For free\" +" let s:licenseTag = s:licenseTag . "All right reserved\" +" let g:DoxygenToolkit_licenseTag = s:licenseTag +" let g:DoxygenToolkit_briefTag_funcName="yes" +" let g:doxygen_enhanced_color=1 +" let g:DoxygenToolkit_commentType="Qt" + + diff --git a/.vimrc.custom.plugins b/.vimrc.custom.plugins new file mode 100644 index 00000000..0c0d0c46 --- /dev/null +++ b/.vimrc.custom.plugins @@ -0,0 +1,18 @@ + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" 用户自定义插件列表(该文件只放插件,若要增加其他配置,请放入~/.vimrc.custom.config) +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" 增加~/.vimrc里没有的插件 +" 增加插件后需要进行插件安装,安装步骤如下: +" 1.执行:w保存修改 +" 2.执行,s重新加载vim配置 +" 3.执行,,i进行插件安装 +" Plug 'iamcco/mathjax-support-for-mkdp' +" (需要自己安装nodejs和yarn) Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' } +" Plug 'Yggdroot/indentLine' +" Plug 'gorodinskiy/vim-coloresque' +" Plug 'vim-scripts/DoxygenToolkit.vim' + +" 卸载/禁用~/.vimrc里的默认插件 +" UnPlug 'chxuan/prepare-code' diff --git a/.vimrc.local b/.vimrc.local deleted file mode 100644 index f2fc826d..00000000 --- a/.vimrc.local +++ /dev/null @@ -1,2 +0,0 @@ -"set relativenumber " 开启相对行号 - diff --git a/.ycm_extra_conf.py b/.ycm_extra_conf.py index bda4afae..eb302d68 100644 --- a/.ycm_extra_conf.py +++ b/.ycm_extra_conf.py @@ -75,13 +75,27 @@ '-isystem', '/usr/include/c++/8', '-isystem', +'/usr/include/c++/9', +'-isystem', '/usr/include/c++/9.1.0', '-isystem', +'/usr/include/c++/9.3.0', +'-isystem', +'/usr/include/c++/10.2.0', +'-isystem', '/usr/include', '-isystem', '/usr/include/x86_64-linux-gnu', '-isystem', '/usr/local/include', + +# Termux +'-isystem', +'/data/data/com.termux/files/usr/include', +'-isystem', +'/data/data/com.termux/files/usr/include/c++/v1', +'-isystem', +'/data/data/com.termux/files/usr/include/c++/v1/experimental', ] diff --git a/README.md b/README.md index 1d07c924..d79c9c3e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,9 @@ An automatic configuration program for vim

- + + +

@@ -26,10 +28,19 @@ An automatic configuration program for vim cd ~/.vimplus ./install.sh +注: apline用户请预先安装git,bash: apk add git bash + #### 设置Nerd Font 为防止vimplus显示乱码,需设置mac终端字体为`Droid Sans Mono Nerd Font`。 +#### 更新vimplus + +紧跟vimplus的步伐,尝鲜新特性 + + ./update.sh + + ### Linux 64-bit #### 支持以下发行版 @@ -39,18 +50,27 @@ An automatic configuration program for vim

+

+

+ +

+

+

+

+

+

-#### 安装vimplus(请在普通用户下安装) +#### 安装vimplus git clone https://github.com/chxuan/vimplus.git ~/.vimplus cd ~/.vimplus @@ -60,10 +80,46 @@ An automatic configuration program for vim 为防止vimplus显示乱码,需设置linux终端字体为`Droid Sans Mono Nerd Font`。 +#### 多用户支持 + +将vimplus在某个用户下安装好后,若需要在其他用户也能够使用vimplus,则执行 + + sudo ./install_to_user.sh username1 username2 //替换为真实用户名 + +#### 更新vimplus + +紧跟vimplus的步伐,尝鲜新特性 -## 个性化 + ./update.sh + + +### Android 64-bit([Termux][87]) + +#### 安装vimplus + + git clone https://github.com/chxuan/vimplus.git ~/.vimplus + cd ~/.vimplus + ./install.sh + +#### 更新vimplus + +紧跟vimplus的步伐,尝鲜新特性 + + ./update.sh + -修改 `~/.vimrc.local` 文件内容,以启用个性化定制,可覆盖 `~/.vimrc` 中的设置。 +### Docker + +[ubuntu-vimplus][79]是vimplus基于ubuntu18.04的docker镜像,无需安装vimplus,即可快速体验vimplus带来的快乐 + + docker run -it chxuan/ubuntu-vimplus + + +## 自定义 + +> * [~/.vimrc][82]为vimplus的默认配置,一般不做修改 +> * [~/.vimrc.custom.plugins][83]为用户自定义插件列表,用户增加、卸载插件请修改该文件 +> * [~/.vimrc.custom.config][84]为用户自定义配置文件,一般性配置请放入该文件,可覆盖[~/.vimrc][82]里的配置 ## 插件列表 @@ -76,7 +132,7 @@ An automatic configuration program for vim | [prepare-code][67] | 新建文件时,生成预定义代码片段(I'm author:smile:) | | [vim-buffer][70] | vim缓存操作(I'm author:smile:) | | [vimplus-startify][66] | vimplus开始页面(修改自[mhinz/vim-startify][25]) | -| [tagbar][74] | 使用[majutsushi/tagbar][13]的v2.3版本,[taglist][14]的替代品,显示类/方法/变量 | +| [tagbar][13] | 使用[preservim/tagbar][13]的最新版本,[taglist][14]的替代品,显示类/方法/变量 | | [vim-plug][4] | 比[Vundle][54]下载更快的插件管理软件 | | [YouCompleteMe][5] | 史上最强大的基于语义的自动补全插件,支持C/C++、C#、Python、PHP等语言 | | [NerdTree][6] | 代码资源管理器 | @@ -94,85 +150,92 @@ An automatic configuration program for vim | [tabular][20] | 代码、注释、表格对齐 | | [vim-easymotion][23] | 强大的光标快速移动工具,强大到颠覆你的插件观 | | [incsearch.vim][24] | 模糊字符搜索插件 | -| [markdown-preview][26] | markdown实时预览 | | [vim-fugitive][36] | 集成Git | | [gv][64] | 显示git提交记录 | | [vim-slash][50] | 优化搜索,移动光标后清除高亮 | | [echodoc][57] | 补全函数时在命令栏显示函数签名 | | [vim-smooth-scroll][60] | 让翻页更顺畅 | | [clever-f.vim][68] | 强化f和F键 | -| [github-complete.vim][69] | Emoji:dog:补全 | ## 快捷键 -以下是部分快捷键,更详细的快捷键请查阅[vimplus帮助文档][59]。 - -| 快捷键 | 说明 | -| ------- | ----- | -| `,` | Leader Key | -| `n` | 打开/关闭代码资源管理器 | -| `t` | 打开/关闭函数列表 | -| `a` | .h .cpp 文件切换 | -| `u` | 转到函数声明 | -| `U` | 转到函数实现 | -| `u` | 转到变量声明 | -| `o` | 打开include文件 | -| `y` | 拷贝函数声明 | -| `p` | 生成函数实现 | -| `w` | 单词跳转 | -| `f` | 搜索~目录下的文件 | -| `F` | 搜索当前目录下的文本 | -| `g` | 显示git仓库提交记录 | -| `G` | 显示当前文件提交记录 | -| `gg` | 显示当前文件在某个commit下的完整内容 | -| `ff` | 语法错误自动修复(FixIt) | -| `` | 切换到上一个buffer | -| `` | 切换到下一个buffer | -| `d` | 删除当前buffer | -| `D` | 删除当前buffer外的所有buffer | -| `vim` | 运行vim编辑器时,默认启动开始页面 | -| `` | 显示语法错误提示窗口 | -| `` | 启用markdown实时预览 | -| `` | 关闭markdown实时预览 | -| `` | 显示上一主题 | -| `` | 显示下一主题 | -| `l` | 按竖线对齐 | -| `=` | 按等号对齐 | -| `Ya` | 复制行文本到字母a | -| `Da` | 剪切行文本到字母a | -| `Ca` | 改写行文本到字母a | -| `rr` | 替换文本 | -| `r` | 全局替换,目前只支持单个文件 | -| `gcc` | 注释代码 | -| `gcap` | 注释段落 | -| `vif` | 选中函数内容 | -| `dif` | 删除函数内容 | -| `cif` | 改写函数内容 | -| `vaf` | 选中函数内容(包括函数名 花括号) | -| `daf` | 删除函数内容(包括函数名 花括号) | -| `caf` | 改写函数内容(包括函数名 花括号) | -| `fa` | 查找字母a,然后再按f键查找下一个 | -| `` | Emoji:dog:补全 | - - -## Q & A +以下是部分快捷键,可通过vimplus的`,h`命令查看[vimplus帮助文档][59]。 + +| 快捷键 | 说明 | +| ------- | ----- | +| `,` | Leader Key | +| `n` | 打开/关闭代码资源管理器 | +| `t` | 打开/关闭函数列表 | +| `a` | .h .cpp 文件切换 | +| `u` | 转到函数声明 | +| `U` | 转到函数实现 | +| `u` | 转到变量声明 | +| `o` | 打开include文件 | +| `y` | 拷贝函数声明 | +| `p` | 生成函数实现 | +| `w` | 单词跳转 | +| `f` | 搜索~目录下的文件 | +| `F` | 搜索当前目录下的文本 | +| `g` | 显示git仓库提交记录 | +| `G` | 显示当前文件提交记录 | +| `gg` | 显示当前文件在某个commit下的完整内容 | +| `ff` | 语法错误自动修复(FixIt) | +| `` | 切换到上一个buffer | +| `` | 切换到下一个buffer | +| `d` | 删除当前buffer | +| `D` | 删除当前buffer外的所有buffer | +| `vim` | 运行vim编辑器时,默认启动开始页面 | +| `` | 显示语法错误提示窗口 | +| `` | 显示上一主题 | +| `` | 显示下一主题 | +| `l` | 按竖线对齐 | +| `=` | 按等号对齐 | +| `Ya` | 复制行文本到字母a | +| `Da` | 剪切行文本到字母a | +| `Ca` | 改写行文本到字母a | +| `rr` | 替换文本 | +| `r` | 全局替换,目前只支持单个文件 | +| `rev` | 翻转当前光标下的单词或使用V模式选择的文本 | +| `gcc` | 注释代码 | +| `gcap` | 注释段落 | +| `vif` | 选中函数内容 | +| `dif` | 删除函数内容 | +| `cif` | 改写函数内容 | +| `vaf` | 选中函数内容(包括函数名 花括号) | +| `daf` | 删除函数内容(包括函数名 花括号) | +| `caf` | 改写函数内容(包括函数名 花括号) | +| `fa` | 查找字母a,然后再按f键查找下一个 | +| `e` | 快速编辑~/.vimrc文件 | +| `s` | 重新加载~/.vimrc文件 | +| `vp` | 快速编辑~/.vimrc.custom.plugins文件 | +| `vc` | 快速编辑~/.vimrc.custom.config文件 | +| `h` | 打开vimplus帮助文档 | +| `H` | 打开当前光标所在单词的vim帮助文档 | +| `t` | 生成try-catch代码块 | +| `y` | 复制当前选中到系统剪切板 | +| `i` | 安装插件 | +| `u` | 更新插件 | +| `c` | 删除插件 | + + +## FAQ + +- **`vimplus怎么安装新插件?`** + + 编辑[~/.vimrc.custom.plugins][83],添加自定义插件。 + +- **`vimplus怎么添加自定义配置?`** + + 编辑[~/.vimrc.custom.config][84],添加自定义配置。 - **`vimplus安装脚本会在自己电脑上安装哪些软件?`** 网络良好情况下,vimplus只需30分钟左右即可将vim cpp环境配置好,vimplus真正的做到了一键配置,不让用户操心。vimplus会安装一些必备软件,比如说python、cmake、gcc、fontconfig等,vimplus也考虑到了有些系统的vim不支持python,它会自动去下载vim源码将python支持编译进去,vimplus也会安装nerd-font不让vim显示出现乱码,最最重要的是vimplus实现了ycm自动编译安装,给折腾了几天ycm都没有安装好的用户带来了新的希望,而且vimplus也支持macos和linux众多发行版,让linux发烧友频繁切换发行版而不用操心vim环境配置。最后说了这么多,不如看[vimplus安装脚本][78]来的直接:smile:。 -- **`插件安装界面显示YouCompleteMe安装失败`** - - 在执行install.sh安装脚本时,ycm比其他插件早安装,当用户看到插件安装界面显示ycm安装失败时,其实ycm已经提前安装好了,忽略掉该错误即可。 +- **`启动vim报错:RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.`** -- **`插件安装界面不更新进度,一直显示进度Installing plugins (24/40)`** - - vimplus使用vim-plug作为插件管理器,vim-plug可能由于界面没有刷新(其实在安装),所以进度一直停留在`Installing plugins (24/40)`,用户只需要耐心等待所有插件安装完成即可,或者直接`Ctrl+C`终止安装,通过vim打开`~/.vimrc`并执行`:PlugInstall`命令安装剩余插件。 - -- **`The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). YCM core library compiled for Python 3 but loaded in Python 2. Set the 'g:ycm_server_python_interpreter' option to a Python 3 interpreter path`** - - 编译ycm和运行ycmd server的python版本不一致导致的,比如说,编译ycm时使用系统默认版本python3,后来又将系统默认版本改为python2,解决该问题有三种方法,第一:编辑.vimrc,将g:ycm_server_python_interpreter指向编译ycm时的python版本,第二:使用当前python版本重新编译ycm,第三:恢复系统默认的python版本。 + 可以尝试将cryptography删掉,具体见[issues #208][81]。 - **`vimplus不支持目前用户正在使用的系统怎么办?`** @@ -194,9 +257,9 @@ An automatic configuration program for vim vimplus安装完毕之后,`~`目录下将会生成两个隐藏文件分别是.vimrc和.ycm_extra_conf.py,其中.vimrc是vim的配置文件,.ycm_extra_conf.py是ycm插件的配置文件,当你需要创建一个project时,需要将.ycm_extra_conf.py拷贝到project的顶层目录,通过修改该配置文件里面的`flags`变量来添加你的第三方库路径。 -- **`在A用户下安装了vimplus,在B用户下不能使用?`** +- **`使用vi命令报错:E492: Not an editor command:`** - 目前vimplus是基于用户的,如果你想在其他用户下也能使用vimplus,也需要单独安装。 + vimplus安装完成后,linux下可能会同时存在vi和vim命令,执行vi时,vi加载~/.vimrc文件可能会报错,但不影响使用,如果要消除错误可以设置软链接`ln -s /usr/bin/vim /usr/bin/vi` - **`怎么自定义文件头,比如说添加作者、创建时间?`** @@ -215,33 +278,83 @@ An automatic configuration program for vim 那就麻烦您打赏一颗:star::star:吧,给予我继续维护的动力。 +## 贡献者 + +> 有代码贡献或有好的建议,帮助vimplus发展的小伙伴 + + +chxuan + + +dofy + + +urain39 + + +freedomDR + + +starifly + + +Shaloc + + +jokerkeny + + +xuthus5 + + +zhoumengkang + + +tuberry + + +wyg1997 + + +happinesslijian + + +wangling12 + + +ardinzh + + +BD7IWD + + +Ro0tk1t + + + ## 支持开源:heart: +> 有意愿献爱心的小伙伴,务必将github账号写入捐款备注哦,谢谢大家 + | wechat | alipay | | ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | | | | - -## 贡献者 - - - - - - - - - - - - - -

chxuan

dofy

urain39

freedomDR

starifly

Shaloc

jokerkeny

+| 序号 | 支持者 | RMB | 时间 | +| ----- | ------- | ----- | ----- | +| 1 | [zhoumengkang][80] | ¥50 | 2019-09-28 | +| 2 | [zhoumengkang][80] | ¥50 | 2019-09-29 | +| 3 | [zibraque][85] | ¥50 | 2019-11-25 | +| 4 | [gfreewind][86] | ¥20 | 2019-12-27 | +| 5 | [wh656325437][88] | ¥20 | 2020-07-02 | +| 6 | [luguifang][89] | ¥20 | 2020-07-12 | +| 7 | [liyewen521][90] | ¥20 | 2020-07-27 | +| 8 | [xht19980305][91] | ¥20 | 2020-08-14 | ## vimplus:star:趋势图 -[![Sparkline](https://stars.medv.io/chxuan/vimplus.svg)](https://stars.medv.io/chxuan/vimplus) +![Stargazers over time](https://starchart.cc/chxuan/vimplus.svg) ## License @@ -254,12 +367,12 @@ This software is licensed under the [MIT license][75]. © 2016 chxuan [3]: https://brew.sh/ [4]: https://github.com/junegunn/vim-plug [5]: https://github.com/Valloric/YouCompleteMe - [6]: https://github.com/scrooloose/nerdtree + [6]: https://github.com/preservim/nerdtree [8]: https://github.com/vim-airline/vim-airline [9]: https://github.com/powerline/powerline [10]: https://github.com/jiangmiao/auto-pairs [12]: https://github.com/ctrlpvim/ctrlp.vim - [13]: https://github.com/majutsushi/tagbar + [13]: https://github.com/preservim/tagbar [14]: https://github.com/vim-scripts/taglist.vim [15]: https://github.com/ryanoasis/vim-devicons [16]: https://github.com/tpope/vim-surround @@ -270,7 +383,6 @@ This software is licensed under the [MIT license][75]. © 2016 chxuan [23]: https://github.com/easymotion/vim-easymotion [24]: https://github.com/haya14busa/incsearch.vim [25]: https://github.com/mhinz/vim-startify - [26]: https://github.com/iamcco/markdown-preview.vim [27]: https://github.com/chxuan/change-colorscheme [36]: https://github.com/tpope/vim-fugitive [38]: https://github.com/Valloric/YouCompleteMe @@ -290,12 +402,23 @@ This software is licensed under the [MIT license][75]. © 2016 chxuan [66]: https://github.com/chxuan/vimplus-startify [67]: https://github.com/chxuan/prepare-code [68]: https://github.com/rhysd/clever-f.vim - [69]: https://github.com/rhysd/github-complete.vim [70]: https://github.com/chxuan/vim-buffer [72]: https://github.com/chxuan/vim-edit - [74]: https://github.com/chxuan/tagbar [75]: https://github.com/chxuan/vimplus/blob/master/LICENSE [76]: https://blog.csdn.net/wang73ying/article/details/82491993 [77]: https://blog.csdn.net/liuyangbo121/article/details/82971736 [78]: https://github.com/chxuan/vimplus/blob/master/install.sh + [79]: https://hub.docker.com/r/chxuan/ubuntu-vimplus + [80]: https://github.com/zhoumengkang + [81]: https://github.com/chxuan/vimplus/issues/208 + [82]: https://github.com/chxuan/vimplus/blob/master/.vimrc + [83]: https://github.com/chxuan/vimplus/blob/master/.vimrc.custom.plugins + [84]: https://github.com/chxuan/vimplus/blob/master/.vimrc.custom.config + [85]: https://github.com/zibraque + [86]: https://github.com/gfreewind + [87]: https://termux.com/ + [88]: https://github.com/wh656325437 + [89]: https://github.com/luguifang + [90]: https://github.com/liyewen521 + [91]: https://github.com/xht19980305 diff --git a/autoload/plug.vim b/autoload/plug.vim new file mode 100644 index 00000000..ec12a9e4 --- /dev/null +++ b/autoload/plug.vim @@ -0,0 +1,2542 @@ +" 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-master branch +" Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' } +" +" " Using a tagged release; wildcard allowed (requires git 1.9.2 or above) +" Plug 'fatih/vim-go', { 'tag': '*' } +" +" " Plugin options +" Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' } +" +" " 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') +let s:me = resolve(expand(':p')) +let s:base_spec = { 'branch': 'master', '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! plug#begin(...) + if a:0 > 0 + let s:plug_home_org = a:1 + let home = s:path(fnamemodify(expand(a:1), ':p')) + elseif exists('g:plug_home') + let home = s:path(g:plug_home) + elseif !empty(&rtp) + let home = s:path(split(&rtp, ',')[0]) . '/plugged' + else + return s:err('Unable to determine plug home. Try calling plug#begin() with a path argument.') + endif + if fnamemodify(home, ':t') ==# 'plugin' && fnamemodify(home, ':h') ==# s:first_rtp + return s:err('Invalid plug home. '.home.' is a standard Vim runtime path and is not allowed.') + endif + + let g:plug_home = home + let g:plugs = {} + 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 + 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('Call plug#begin() first') + endif + + if exists('#PlugLOD') + augroup PlugLOD + autocmd! + augroup END + augroup! PlugLOD + endif + let lod = { 'ft': {}, 'map': {}, 'cmd': {} } + + if exists('g:did_load_filetypes') + filetype off + endif + for name in g:plugs_order + if !has_key(g:plugs, name) + continue + endif + let plug = g:plugs[name] + if get(s:loaded, name, 0) || !s:lazy(plug, 'on') && !s:lazy(plug, 'for') + let s:loaded[name] = 1 + continue + endif + + if has_key(plug, 'on') + let s:triggers[name] = { 'map': [], 'cmd': [] } + for cmd in s:to_a(plug.on) + if cmd =~? '^.\+' + if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i')) + call s:assoc(lod.map, cmd, name) + endif + call add(s:triggers[name].map, cmd) + elseif cmd =~# '^[A-Z]' + let cmd = substitute(cmd, '!*$', '', '') + if exists(':'.cmd) != 2 + call s:assoc(lod.cmd, cmd, name) + endif + call add(s:triggers[name].cmd, cmd) + else + call s:err('Invalid `on` option: '.cmd. + \ '. Should start with an uppercase letter or ``.') + endif + endfor + endif + + if has_key(plug, 'for') + let types = s:to_a(plug.for) + if !empty(types) + augroup filetypedetect + call s:source(s:rtp(plug), 'ftdetect/**/*.vim', 'after/ftdetect/**/*.vim') + augroup END + endif + for type in types + call s:assoc(lod.ft, type, name) + endfor + endif + endfor + + for [cmd, names] in items(lod.cmd) + execute printf( + \ 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "", , , , %s)', + \ cmd, string(cmd), string(names)) + endfor + + for [map, names] in items(lod.map) + for [mode, map_prefix, key_prefix] in + \ [['i', '', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']] + execute printf( + \ '%snoremap %s %s:call lod_map(%s, %s, %s, "%s")', + \ mode, map, map_prefix, string(map), string(names), mode != 'i', key_prefix) + endfor + endfor + + for [ft, names] in items(lod.ft) + augroup PlugLOD + execute printf('autocmd FileType %s call lod_ft(%s, %s)', + \ ft, string(ft), string(names)) + augroup END + endfor + + call s:reorg_rtp() + filetype plugin indent on + if has('vim_starting') + if has('syntax') && !exists('g:syntax_on') + syntax enable + end + else + call s:reload_plugins() + endif +endfunction + +function! s:loaded_names() + return filter(copy(g:plugs_order), 'get(s:loaded, v:val, 0)') +endfunction + +function! s:load_plugin(spec) + call s:source(s:rtp(a:spec), 'plugin/**/*.vim', 'after/plugin/**/*.vim') +endfunction + +function! s:reload_plugins() + for name in s:loaded_names() + call s:load_plugin(g:plugs[name]) + endfor +endfunction + +function! s:trim(str) + return substitute(a:str, '[\/]\+$', '', '') +endfunction + +function! s:version_requirement(val, min) + for idx in range(0, len(a:min) - 1) + let v = get(a:val, idx, 0) + if v < a:min[idx] | return 0 + elseif v > a:min[idx] | return 1 + endif + endfor + return 1 +endfunction + +function! s:git_version_requirement(...) + if !exists('s:git_version') + let s:git_version = map(split(split(s:system('git --version'))[2], '\.'), 'str2nr(v:val)') + endif + return s:version_requirement(s:git_version, a:000) +endfunction + +function! s:progress_opt(base) + return a:base && !s:is_win && + \ s:git_version_requirement(1, 7, 1) ? '--progress' : '' +endfunction + +function! s:rtp(spec) + return s:path(a:spec.dir . get(a:spec, 'rtp', '')) +endfunction + +if s:is_win + function! s:path(path) + return s:trim(substitute(a:path, '/', '\', 'g')) + endfunction + + function! s:dirpath(path) + return s:path(a:path) . '\' + endfunction + + function! s:is_local_plug(repo) + return a:repo =~? '^[a-z]:\|^[%~]' + endfunction + + " Copied from fzf + function! s:wrap_cmds(cmds) + let use_chcp = executable('sed') + return map([ + \ '@echo off', + \ 'setlocal enabledelayedexpansion'] + \ + (use_chcp ? [ + \ 'for /f "usebackq" %%a in (`chcp ^| sed "s/[^0-9]//gp"`) do set origchcp=%%a', + \ 'chcp 65001 > nul'] : []) + \ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds]) + \ + (use_chcp ? ['chcp !origchcp! > nul'] : []) + \ + ['endlocal'], + \ 'v:val."\r"') + endfunction + + function! s:batchfile(cmd) + let batchfile = tempname().'.bat' + call writefile(s:wrap_cmds(a:cmd), batchfile) + let cmd = plug#shellescape(batchfile, {'shell': &shell, 'script': 1}) + if &shell =~# 'powershell\.exe$' + 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', 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(v:exception) + endtry +endfunction + +function! s:parse_options(arg) + let opts = copy(s:base_spec) + let type = type(a:arg) + if type == s:TYPE.string + let opts.tag = a:arg + elseif type == s:TYPE.dict + call extend(opts, a:arg) + if has_key(opts, 'dir') + let opts.dir = s:dirpath(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(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:%3A@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 /^-/ + 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 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(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 :if b:plug_preview==1pcendifbd + 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: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 && a:swap + set shell=sh shellredir=>%s\ 2>&1 + 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 + 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:system('git rev-parse HEAD', a:spec.dir) + if !v:shell_error && !s:hash_match(sha, s:lines(output)[0]) + let output = s:system( + \ 'git fetch --depth 999999 && git checkout '.s:esc(sha).' --', a:spec.dir) + endif + return output +endfunction + +function! s:finish(pull) + 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 + + let s:clone_opt = get(g:, 'plug_shallow', 1) ? + \ '--depth 1' . (s:git_version_requirement(1, 7, 10) ? ' --no-single-branch' : '') : '' + + if has('win32unix') || has('wsl') + let 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 '.s:esc(tag).' -- 2>&1', spec.dir) + else + let branch = s:esc(get(spec, 'branch', 'master')) + call s:log4(name, 'Merging origin/'.branch) + let out = s:system('git checkout -q '.branch.' -- 2>&1' + \. (has_key(s:update.new, name) ? '' : ('&& git merge --ff-only origin/'.branch.' 2>&1')), spec.dir) + endif + if !v:shell_error && filereadable(spec.dir.'/.gitmodules') && + \ (s:update.force || has_key(s:update.new, name) || s:is_updated(spec.dir)) + call s:log4(name, 'Updating submodules. This may take a while.') + let out .= s:bang('git submodule update --init --recursive'.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:system('rm -rf ' . plug#shellescape(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' ? + \ 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 + let cmd = has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir, 0) : a:cmd + let argv = s:is_win ? ['cmd', '/s', '/c', '"'.cmd.'"'] : ['sh', '-c', cmd] + + if s:nvim + call extend(job, { + \ 'on_stdout': function('s:nvim_cb'), + \ 'on_exit': function('s:nvim_cb'), + \ }) + let jid = jobstart(argv, job) + if jid > 0 + let job.jobid = jid + else + let job.running = 0 + let job.error = 1 + let job.lines = [jid < 0 ? argv[0].' is not executable' : + \ 'Invalid arguments (or job table is full)'] + endif + elseif s:vim8 + let jid = job_start(s:is_win ? join(argv, ' ') : argv, { + \ 'out_cb': function('s:job_cb', ['s:job_out_cb', job]), + \ 'exit_cb': function('s:job_cb', ['s:job_exit_cb', job]), + \ 'out_mode': 'raw' + \}) + if job_status(jid) == 'run' + let job.jobid = jid + else + let job.running = 0 + let job.error = 1 + let job.lines = ['Failed to start job'] + endif + else + let job.lines = s:lines(call('s:system', [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) + for i in range(4, line('$')) + if getline(i) =~# '^[-+x*] '.a:name.':' + for j in range(i + 1, line('$')) + if getline(j) !~ '^ ' + return [i, j - 1] + endif + endfor + return [i, i] + endif + endfor + return [0, 0] +endfunction + +function! s:log(bullet, name, lines) + if s:switch_in() + let [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 fetch_opt = (has_tag && !empty(globpath(spec.dir, '.git/shallow'))) ? '--depth 99999999' : '' + call s:spawn(name, printf('git fetch %s %s 2>&1', fetch_opt, prog), { 'dir': spec.dir }) + else + let s:jobs[name] = { 'running': 0, 'lines': ['Already installed'], 'error': 0 } + endif + else + let s:jobs[name] = { 'running': 0, 'lines': s:lines(error), 'error': 1 } + endif + else + call s:spawn(name, + \ printf('git clone %s %s %s %s 2>&1', + \ has_tag ? '' : s:clone_opt, + \ prog, + \ plug#shellescape(spec.uri, {'script': 0}), + \ plug#shellescape(s:trim(spec.dir), {'script': 0})), { '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 = 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') + 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! plug#shellescape(arg, ...) + 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 shell =~# 'powershell\.exe$' || shell =~# 'pwsh$' + return s:shellesc_ps1(a:arg) + endif + return shellescape(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) + let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd + if s:is_win + 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:lines(s:system('git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url', a:spec.dir)) + let remote = result[-1] + if v:shell_error + let err = join([remote, 'PlugClean required.'], "\n") + elseif !s:compare_git_uri(remote, a:spec.uri) + " 不提示url不匹配错误 + " let err = join(['Invalid URI: '.remote, + " \ 'Expected: '.a:spec.uri, + " \ 'PlugClean required.'], "\n") + elseif a:check_branch && has_key(a:spec, 'commit') + let result = s:lines(s:system('git rev-parse HEAD 2>&1', a:spec.dir)) + let sha = result[-1] + if v:shell_error + 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 branch = result[0] + " Check tag + if has_key(a:spec, 'tag') + let tag = s:system_chomp('git describe --exact-match --tags HEAD 2>&1', a:spec.dir) + if a:spec.tag !=# tag && 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 a:spec.branch !=# branch + let err = printf('Invalid branch: %s (expected: %s). Try PlugUpdate.', + \ branch, a:spec.branch) + endif + if empty(err) + let [ahead, behind] = split(s:lastline(s:system(printf( + \ 'git rev-list --count --left-right HEAD...origin/%s', + \ a:spec.branch), a:spec.dir)), '\t') + if !v:shell_error && ahead + if behind + " Only mention PlugClean if diverged, otherwise it's likely to be + " pushable (and probably not that messed up). + let err = printf( + \ "Diverged from origin/%s (%d commit(s) ahead and %d commit(s) behind!\n" + \ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', a:spec.branch, ahead, behind) + else + let err = printf("Ahead of origin/%s by %d commit(s).\n" + \ .'Cannot update until local changes are pushed.', + \ a:spec.branch, ahead) + endif + endif + endif + endif + else + let err = 'Not found' + endif + return [err, err =~# 'PlugClean'] +endfunction + +function! s:rm_rf(dir) + if isdirectory(a:dir) + call s:system((s:is_win ? 'rmdir /S /Q ' : 'rm -rf ') . plug#shellescape(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(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 + while l1 <= l2 + let line = getline(l1) + if line =~ '^- ' && isdirectory(line[2:]) + execute l1 + redraw! + let answer = force ? 1 : s:ask('Delete '.line[2:].'?', 1) + let force = force || answer > 1 + if answer + call s:rm_rf(line[2:]) + setlocal modifiable + call setline(l1, '~'.line[1:]) + let s:clean_count += 1 + call setline(4, printf('Removed %d directories.', s:clean_count)) + setlocal nomodifiable + endif + endif + let l1 += 1 + endwhile +endfunction + +function! s:upgrade() + echo 'Downloading the latest version of vim-plug' + redraw + let tmp = tempname() + let new = tmp . '/plug.vim' + + try + let out = s:system(printf('git clone --depth 1 %s %s', plug#shellescape(s:plug_src), plug#shellescape(tmp))) + if v:shell_error + return s:err('Error upgrading vim-plug: '. out) + endif + + if readfile(s:me) ==# readfile(new) + echo 'vim-plug is already up-to-date' + return 0 + else + call rename(s:me, s:me . '.old') + call rename(new, s:me) + unlet g:loaded_plug + echo 'vim-plug has been upgraded' + return 1 + endif + finally + silent! call s:rm_rf(tmp) + endtry +endfunction + +function! s:upgrade_specs() + for spec in values(g:plugs) + let spec.frozen = get(spec, 'frozen', 0) + endfor +endfunction + +function! s:status() + call s:prepare() + call append(0, 'Checking plugins') + call append(1, '') + + let ecnt = 0 + let unloaded = 0 + let [cnt, total] = [0, len(g:plugs)] + for [name, spec] in items(g:plugs) + let is_dir = isdirectory(spec.dir) + if has_key(spec, 'uri') + if is_dir + let [err, _] = s:git_validate(spec, 1) + let [valid, msg] = [empty(err), empty(err) ? 'OK' : err] + else + let [valid, msg] = [0, 'Not found. Try PlugInstall.'] + endif + else + if is_dir + let [valid, msg] = [1, 'OK'] + else + let [valid, msg] = [0, 'Not found.'] + endif + endif + let cnt += 1 + let ecnt += !valid + " `s:loaded` entry can be missing if PlugUpgraded + if is_dir && get(s:loaded, name, -1) == 0 + let unloaded = 1 + let msg .= ' (not loaded)' + endif + call s:progress_bar(2, repeat('=', cnt), total) + call append(3, s:format_message(valid ? '-' : 'x', name, msg)) + normal! 2G + redraw + endfor + call setline(1, 'Finished. '.ecnt.' error(s).') + normal! gg + setlocal nomodifiable + if unloaded + echo "Press 'L' on each line to load plugin, or 'U' to update" + nnoremap L :call status_load(line('.')) + xnoremap L :call status_load(line('.')) + end +endfunction + +function! s:extract_name(str, prefix, suffix) + return matchstr(a:str, '^'.a:prefix.' \zs[^:]\+\ze:.*'.a:suffix.'$') +endfunction + +function! s:status_load(lnum) + let line = getline(a:lnum) + let name = s:extract_name(line, '-', '(not loaded)') + if !empty(name) + call plug#load(name) + setlocal modifiable + call setline(a:lnum, substitute(line, ' (not loaded)$', '', '')) + setlocal nomodifiable + endif +endfunction + +function! s:status_update() range + let lines = getline(a:firstline, a:lastline) + let names = filter(map(lines, 's:extract_name(v:val, "[x-]", "")'), '!empty(v:val)') + if !empty(names) + echo + execute 'PlugUpdate' join(names) + endif +endfunction + +function! s:is_preview_window_open() + silent! wincmd P + if &previewwindow + wincmd p + return 1 + endif +endfunction + +function! s:find_name(lnum) + for lnum in reverse(range(1, a:lnum)) + let line = getline(lnum) + if empty(line) + return '' + endif + let name = s:extract_name(line, '-', '') + if !empty(name) + return name + endif + endfor + return '' +endfunction + +function! s:preview_commit() + if b:plug_preview < 0 + let b:plug_preview = !s:is_preview_window_open() + endif + + let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-f]\{7,9}') + if empty(sha) + return + endif + + let name = s:find_name(line('.')) + if empty(name) || !has_key(g:plugs, name) || !isdirectory(g:plugs[name].dir) + return + endif + + if exists('g:plug_pwindow') && !s:is_preview_window_open() + execute g:plug_pwindow + execute 'e' sha + else + execute 'pedit' sha + wincmd P + endif + setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable + let batchfile = '' + try + let [sh, shellcmdflag, shrd] = s:chsh(1) + let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha + if s:is_win + let [batchfile, cmd] = s:batchfile(cmd) + endif + execute 'silent %!' cmd + finally + let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] + if s:is_win && filereadable(batchfile) + call delete(batchfile) + endif + endtry + setlocal nomodifiable + nnoremap q :q + wincmd p +endfunction + +function! s:section(flags) + call search('\(^[x-] \)\@<=[^:]\+:', a:flags) +endfunction + +function! s:format_git_log(line) + let indent = ' ' + let tokens = split(a:line, nr2char(1)) + if len(tokens) != 5 + return indent.substitute(a:line, '\s*$', '', '') + endif + let [graph, sha, refs, subject, date] = tokens + let tag = matchstr(refs, 'tag: [^,)]\+') + let tag = empty(tag) ? ' ' : ' ('.tag.') ' + return printf('%s%s%s%s%s (%s)', indent, graph, sha, tag, subject, date) +endfunction + +function! s:append_ul(lnum, text) + call append(a:lnum, ['', a:text, repeat('-', len(a:text))]) +endfunction + +function! s:diff() + call s:prepare() + call append(0, ['Collecting changes ...', '']) + let cnts = [0, 0] + let bar = '' + let total = filter(copy(g:plugs), 's:is_managed(v:key) && isdirectory(v:val.dir)') + call s:progress_bar(2, bar, len(total)) + for origin in [1, 0] + let plugs = reverse(sort(items(filter(copy(total), (origin ? '' : '!').'(has_key(v:val, "commit") || has_key(v:val, "tag"))')))) + if empty(plugs) + continue + endif + call s:append_ul(2, origin ? 'Pending updates:' : 'Last update:') + for [k, v] in plugs + let range = origin ? '..origin/'.v.branch : 'HEAD@{1}..' + let cmd = 'git log --graph --color=never '.join(map(['--pretty=format:%x01%h%x01%d%x01%s%x01%cr', range], 'plug#shellescape(v:val)')) + if has_key(v, 'rtp') + let cmd .= ' -- '.plug#shellescape(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 + 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 '.s:esc(g:plugs[name].branch).' --', g:plugs[name].dir) + setlocal modifiable + normal! "_dap + setlocal nomodifiable + echo 'Reverted' +endfunction + +function! s:snapshot(force, ...) abort + call s:prepare() + setf vim + call append(0, ['" Generated by vim-plug', + \ '" '.strftime("%c"), + \ '" :source this file in vim to restore the snapshot', + \ '" or execute: vim -S snapshot.vim', + \ '', '', 'PlugUpdate!']) + 1 + let anchor = line('$') - 3 + let names = sort(keys(filter(copy(g:plugs), + \'has_key(v:val, "uri") && !has_key(v:val, "commit") && isdirectory(v:val.dir)'))) + for name in reverse(names) + let sha = s:system_chomp('git rev-parse --short HEAD', 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 = 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, '\\\@= 1 && strlen(a:1) + if a:1 == 'bg' + let histring .= 'guibg=bg ctermbg=bg ' + else + let c = get(s:bwc, a:1) + let histring .= 'guibg=#' . c[0] . ' ctermbg=' . c[1] . ' ' + endif + endif + + if a:0 >= 2 && strlen(a:2) + let histring .= 'gui=' . a:2 . ' cterm=' . a:2 . ' ' + endif + + if a:0 >= 3 && strlen(a:3) + let c = get(s:bwc, a:3) + let histring .= 'guisp=#' . c[0] . ' ' + endif + + " echom histring + + execute histring +endfunction +" }}} +" Configuration Options {{{ + +if exists('g:badwolf_darkgutter') && g:badwolf_darkgutter + let s:gutter = 'blackestgravel' +else + let s:gutter = 'blackgravel' +endif + +if exists('g:badwolf_tabline') + if g:badwolf_tabline == 0 + let s:tabline = 'blackestgravel' + elseif g:badwolf_tabline == 1 + let s:tabline = 'blackgravel' + elseif g:badwolf_tabline == 2 + let s:tabline = 'darkgravel' + elseif g:badwolf_tabline == 3 + let s:tabline = 'deepgravel' + else + let s:tabline = 'blackestgravel' + endif +else + let s:tabline = 'blackgravel' +endif + +" }}} + +" Actual colorscheme ---------------------------------------------------------- +" Vanilla Vim {{{ + +" General/UI {{{ + +call s:HL('Normal', 'plain', 'blackgravel') + +call s:HL('Folded', 'mediumgravel', 'bg', 'none') + +call s:HL('VertSplit', 'lightgravel', 'bg', 'none') + +call s:HL('CursorLine', '', 'darkgravel', 'none') +call s:HL('CursorColumn', '', 'darkgravel') +call s:HL('ColorColumn', '', 'darkgravel') + +call s:HL('TabLine', 'plain', s:tabline, 'none') +call s:HL('TabLineFill', 'plain', s:tabline, 'none') +call s:HL('TabLineSel', 'coal', 'tardis', 'none') + +call s:HL('MatchParen', 'dalespale', 'darkgravel', 'bold') + +call s:HL('NonText', 'deepgravel', 'bg') +call s:HL('SpecialKey', 'deepgravel', 'bg') + +call s:HL('Visual', '', 'deepgravel') +call s:HL('VisualNOS', '', 'deepgravel') + +call s:HL('Search', 'coal', 'dalespale', 'bold') +call s:HL('IncSearch', 'coal', 'tardis', 'bold') + +call s:HL('Underlined', 'fg', '', 'underline') + +call s:HL('StatusLine', 'coal', 'tardis', 'bold') +call s:HL('StatusLineNC', 'snow', 'deepgravel', 'bold') + +call s:HL('Directory', 'dirtyblonde', '', 'bold') + +call s:HL('Title', 'lime') + +call s:HL('ErrorMsg', 'taffy', 'bg', 'bold') +call s:HL('MoreMsg', 'dalespale', '', 'bold') +call s:HL('ModeMsg', 'dirtyblonde', '', 'bold') +call s:HL('Question', 'dirtyblonde', '', 'bold') +call s:HL('WarningMsg', 'dress', '', 'bold') + +" This is a ctags tag, not an HTML one. 'Something you can use c-] on'. +call s:HL('Tag', '', '', 'bold') + +" hi IndentGuides guibg=#373737 +" hi WildMenu guifg=#66D9EF guibg=#000000 + +" }}} +" Gutter {{{ + +call s:HL('LineNr', 'mediumgravel', s:gutter) +call s:HL('SignColumn', '', s:gutter) +call s:HL('FoldColumn', 'mediumgravel', s:gutter) + +" }}} +" Cursor {{{ + +call s:HL('Cursor', 'coal', 'tardis', 'bold') +call s:HL('vCursor', 'coal', 'tardis', 'bold') +call s:HL('iCursor', 'coal', 'tardis', 'none') + +" }}} +" Syntax highlighting {{{ + +" Start with a simple base. +call s:HL('Special', 'plain') + +" Comments are slightly brighter than folds, to make 'headers' easier to see. +call s:HL('Comment', 'gravel') +call s:HL('Todo', 'snow', 'bg', 'bold') +call s:HL('SpecialComment', 'snow', 'bg', 'bold') + +" Strings are a nice, pale straw color. Nothing too fancy. +call s:HL('String', 'dirtyblonde') + +" Control flow stuff is taffy. +call s:HL('Statement', 'taffy', '', 'bold') +call s:HL('Keyword', 'taffy', '', 'bold') +call s:HL('Conditional', 'taffy', '', 'bold') +call s:HL('Operator', 'taffy', '', 'none') +call s:HL('Label', 'taffy', '', 'none') +call s:HL('Repeat', 'taffy', '', 'none') + +" Functions and variable declarations are orange, because plain looks weird. +call s:HL('Identifier', 'orange', '', 'none') +call s:HL('Function', 'orange', '', 'none') + +" Preprocessor stuff is lime, to make it pop. +" +" This includes imports in any given language, because they should usually be +" grouped together at the beginning of a file. If they're in the middle of some +" other code they should stand out, because something tricky is +" probably going on. +call s:HL('PreProc', 'lime', '', 'none') +call s:HL('Macro', 'lime', '', 'none') +call s:HL('Define', 'lime', '', 'none') +call s:HL('PreCondit', 'lime', '', 'bold') + +" Constants of all kinds are colored together. +" I'm not really happy with the color yet... +call s:HL('Constant', 'toffee', '', 'bold') +call s:HL('Character', 'toffee', '', 'bold') +call s:HL('Boolean', 'toffee', '', 'bold') + +call s:HL('Number', 'toffee', '', 'bold') +call s:HL('Float', 'toffee', '', 'bold') + +" Not sure what 'special character in a constant' means, but let's make it pop. +call s:HL('SpecialChar', 'dress', '', 'bold') + +call s:HL('Type', 'dress', '', 'none') +call s:HL('StorageClass', 'taffy', '', 'none') +call s:HL('Structure', 'taffy', '', 'none') +call s:HL('Typedef', 'taffy', '', 'bold') + +" Make try/catch blocks stand out. +call s:HL('Exception', 'lime', '', 'bold') + +" Misc +call s:HL('Error', 'snow', 'taffy', 'bold') +call s:HL('Debug', 'snow', '', 'bold') +call s:HL('Ignore', 'gravel', '', '') + +" }}} +" Completion Menu {{{ + +call s:HL('Pmenu', 'plain', 'deepergravel') +call s:HL('PmenuSel', 'coal', 'tardis', 'bold') +call s:HL('PmenuSbar', '', 'deepergravel') +call s:HL('PmenuThumb', 'brightgravel') + +" }}} +" Diffs {{{ + +call s:HL('DiffDelete', 'coal', 'coal') +call s:HL('DiffAdd', '', 'deepergravel') +call s:HL('DiffChange', '', 'darkgravel') +call s:HL('DiffText', 'snow', 'deepergravel', 'bold') + +" }}} +" Spelling {{{ + +if has("spell") + call s:HL('SpellCap', 'dalespale', 'bg', 'undercurl,bold', 'dalespale') + call s:HL('SpellBad', '', 'bg', 'undercurl', 'dalespale') + call s:HL('SpellLocal', '', '', 'undercurl', 'dalespale') + call s:HL('SpellRare', '', '', 'undercurl', 'dalespale') +endif + +" }}} + +" }}} +" Plugins {{{ + +" CtrlP {{{ + + " the message when no match is found + call s:HL('CtrlPNoEntries', 'snow', 'taffy', 'bold') + + " the matched pattern + call s:HL('CtrlPMatch', 'orange', 'bg', 'none') + + " the line prefix '>' in the match window + call s:HL('CtrlPLinePre', 'deepgravel', 'bg', 'none') + + " the prompt’s base + call s:HL('CtrlPPrtBase', 'deepgravel', 'bg', 'none') + + " the prompt’s text + call s:HL('CtrlPPrtText', 'plain', 'bg', 'none') + + " the prompt’s cursor when moving over the text + call s:HL('CtrlPPrtCursor', 'coal', 'tardis', 'bold') + + " 'prt' or 'win', also for 'regex' + call s:HL('CtrlPMode1', 'coal', 'tardis', 'bold') + + " 'file' or 'path', also for the local working dir + call s:HL('CtrlPMode2', 'coal', 'tardis', 'bold') + + " the scanning status + call s:HL('CtrlPStats', 'coal', 'tardis', 'bold') + + " TODO: CtrlP extensions. + " CtrlPTabExtra : the part of each line that’s not matched against (Comment) + " CtrlPqfLineCol : the line and column numbers in quickfix mode (|s:HL-Search|) + " CtrlPUndoT : the elapsed time in undo mode (|s:HL-Directory|) + " CtrlPUndoBr : the square brackets [] in undo mode (Comment) + " CtrlPUndoNr : the undo number inside [] in undo mode (String) + +" }}} +" EasyMotion {{{ + +call s:HL('EasyMotionTarget', 'tardis', 'bg', 'bold') +call s:HL('EasyMotionShade', 'deepgravel', 'bg') + +" }}} +" Interesting Words {{{ + +" These are only used if you're me or have copied the hNUM mappings +" from my Vimrc. +call s:HL('InterestingWord1', 'coal', 'orange') +call s:HL('InterestingWord2', 'coal', 'lime') +call s:HL('InterestingWord3', 'coal', 'saltwatertaffy') +call s:HL('InterestingWord4', 'coal', 'toffee') +call s:HL('InterestingWord5', 'coal', 'dress') +call s:HL('InterestingWord6', 'coal', 'taffy') + + +" }}} +" Makegreen {{{ + +" hi GreenBar term=reverse ctermfg=white ctermbg=green guifg=coal guibg=#9edf1c +" hi RedBar term=reverse ctermfg=white ctermbg=red guifg=white guibg=#C50048 + +" }}} +" Rainbow Parentheses {{{ + +call s:HL('level16c', 'mediumgravel', '', 'bold') +call s:HL('level15c', 'dalespale', '', '') +call s:HL('level14c', 'dress', '', '') +call s:HL('level13c', 'orange', '', '') +call s:HL('level12c', 'tardis', '', '') +call s:HL('level11c', 'lime', '', '') +call s:HL('level10c', 'toffee', '', '') +call s:HL('level9c', 'saltwatertaffy', '', '') +call s:HL('level8c', 'coffee', '', '') +call s:HL('level7c', 'dalespale', '', '') +call s:HL('level6c', 'dress', '', '') +call s:HL('level5c', 'orange', '', '') +call s:HL('level4c', 'tardis', '', '') +call s:HL('level3c', 'lime', '', '') +call s:HL('level2c', 'toffee', '', '') +call s:HL('level1c', 'saltwatertaffy', '', '') + +" }}} +" ShowMarks {{{ + +call s:HL('ShowMarksHLl', 'tardis', 'blackgravel') +call s:HL('ShowMarksHLu', 'tardis', 'blackgravel') +call s:HL('ShowMarksHLo', 'tardis', 'blackgravel') +call s:HL('ShowMarksHLm', 'tardis', 'blackgravel') + +" }}} + +" }}} +" Filetype-specific {{{ + +" Clojure {{{ + +call s:HL('clojureSpecial', 'taffy', '', '') +call s:HL('clojureDefn', 'taffy', '', '') +call s:HL('clojureDefMacro', 'taffy', '', '') +call s:HL('clojureDefine', 'taffy', '', '') +call s:HL('clojureMacro', 'taffy', '', '') +call s:HL('clojureCond', 'taffy', '', '') + +call s:HL('clojureKeyword', 'orange', '', 'none') + +call s:HL('clojureFunc', 'dress', '', 'none') +call s:HL('clojureRepeat', 'dress', '', 'none') + +call s:HL('clojureParen0', 'lightgravel', '', 'none') + +call s:HL('clojureAnonArg', 'snow', '', 'bold') + +" }}} +" Common Lisp {{{ + +call s:HL('lispFunc', 'lime', '', 'none') +call s:HL('lispVar', 'orange', '', 'bold') +call s:HL('lispEscapeSpecial', 'orange', '', 'none') + +" }}} +" CSS {{{ + +if g:badwolf_css_props_highlight + call s:HL('cssColorProp', 'taffy', '', 'none') + call s:HL('cssBoxProp', 'taffy', '', 'none') + call s:HL('cssTextProp', 'taffy', '', 'none') + call s:HL('cssRenderProp', 'taffy', '', 'none') + call s:HL('cssGeneratedContentProp', 'taffy', '', 'none') +else + call s:HL('cssColorProp', 'fg', '', 'none') + call s:HL('cssBoxProp', 'fg', '', 'none') + call s:HL('cssTextProp', 'fg', '', 'none') + call s:HL('cssRenderProp', 'fg', '', 'none') + call s:HL('cssGeneratedContentProp', 'fg', '', 'none') +end + +call s:HL('cssValueLength', 'toffee', '', 'bold') +call s:HL('cssColor', 'toffee', '', 'bold') +call s:HL('cssBraces', 'lightgravel', '', 'none') +call s:HL('cssIdentifier', 'orange', '', 'bold') +call s:HL('cssClassName', 'orange', '', 'none') + +" }}} +" Diff {{{ + +call s:HL('gitDiff', 'lightgravel', '',) + +call s:HL('diffRemoved', 'dress', '',) +call s:HL('diffAdded', 'lime', '',) +call s:HL('diffFile', 'coal', 'taffy', 'bold') +call s:HL('diffNewFile', 'coal', 'taffy', 'bold') + +call s:HL('diffLine', 'coal', 'orange', 'bold') +call s:HL('diffSubname', 'orange', '', 'none') + +" }}} +" Django Templates {{{ + +call s:HL('djangoArgument', 'dirtyblonde', '',) +call s:HL('djangoTagBlock', 'orange', '') +call s:HL('djangoVarBlock', 'orange', '') +" hi djangoStatement guifg=#ff3853 gui=bold +" hi djangoVarBlock guifg=#f4cf86 + +" }}} +" HTML {{{ + +" Punctuation +call s:HL('htmlTag', 'darkroast', 'bg', 'none') +call s:HL('htmlEndTag', 'darkroast', 'bg', 'none') + +" Tag names +call s:HL('htmlTagName', 'coffee', '', 'bold') +call s:HL('htmlSpecialTagName', 'coffee', '', 'bold') +call s:HL('htmlSpecialChar', 'lime', '', 'none') + +" Attributes +call s:HL('htmlArg', 'coffee', '', 'none') + +" Stuff inside an tag + +if g:badwolf_html_link_underline + call s:HL('htmlLink', 'lightgravel', '', 'underline') +else + call s:HL('htmlLink', 'lightgravel', '', 'none') +endif + +" }}} +" Java {{{ + +call s:HL('javaClassDecl', 'taffy', '', 'bold') +call s:HL('javaScopeDecl', 'taffy', '', 'bold') +call s:HL('javaCommentTitle', 'gravel', '') +call s:HL('javaDocTags', 'snow', '', 'none') +call s:HL('javaDocParam', 'dalespale', '', '') + +" }}} +" LaTeX {{{ + +call s:HL('texStatement', 'tardis', '', 'none') +call s:HL('texMathZoneX', 'orange', '', 'none') +call s:HL('texMathZoneA', 'orange', '', 'none') +call s:HL('texMathZoneB', 'orange', '', 'none') +call s:HL('texMathZoneC', 'orange', '', 'none') +call s:HL('texMathZoneD', 'orange', '', 'none') +call s:HL('texMathZoneE', 'orange', '', 'none') +call s:HL('texMathZoneV', 'orange', '', 'none') +call s:HL('texMathZoneX', 'orange', '', 'none') +call s:HL('texMath', 'orange', '', 'none') +call s:HL('texMathMatcher', 'orange', '', 'none') +call s:HL('texRefLabel', 'dirtyblonde', '', 'none') +call s:HL('texRefZone', 'lime', '', 'none') +call s:HL('texComment', 'darkroast', '', 'none') +call s:HL('texDelimiter', 'orange', '', 'none') +call s:HL('texZone', 'brightgravel', '', 'none') + +augroup badwolf_tex + au! + + au BufRead,BufNewFile *.tex syn region texMathZoneV start="\\(" end="\\)\|%stopzone\>" keepend contains=@texMathZoneGroup + au BufRead,BufNewFile *.tex syn region texMathZoneX start="\$" skip="\\\\\|\\\$" end="\$\|%stopzone\>" keepend contains=@texMathZoneGroup +augroup END + +" }}} +" LessCSS {{{ + +call s:HL('lessVariable', 'lime', '', 'none') + +" }}} +" Lispyscript {{{ + +call s:HL('lispyscriptDefMacro', 'lime', '', '') +call s:HL('lispyscriptRepeat', 'dress', '', 'none') + +" }}} +" REPLs {{{ +" This isn't a specific plugin, but just useful highlight classes for anything +" that might want to use them. + +call s:HL('replPrompt', 'tardis', '', 'bold') + +" }}} +" Mail {{{ + +call s:HL('mailSubject', 'orange', '', 'bold') +call s:HL('mailHeader', 'lightgravel', '', '') +call s:HL('mailHeaderKey', 'lightgravel', '', '') +call s:HL('mailHeaderEmail', 'snow', '', '') +call s:HL('mailURL', 'toffee', '', 'underline') +call s:HL('mailSignature', 'gravel', '', 'none') + +call s:HL('mailQuoted1', 'gravel', '', 'none') +call s:HL('mailQuoted2', 'dress', '', 'none') +call s:HL('mailQuoted3', 'dirtyblonde', '', 'none') +call s:HL('mailQuoted4', 'orange', '', 'none') +call s:HL('mailQuoted5', 'lime', '', 'none') + +" }}} +" Markdown {{{ + +call s:HL('markdownHeadingRule', 'lightgravel', '', 'bold') +call s:HL('markdownHeadingDelimiter', 'lightgravel', '', 'bold') +call s:HL('markdownOrderedListMarker', 'lightgravel', '', 'bold') +call s:HL('markdownListMarker', 'lightgravel', '', 'bold') +call s:HL('markdownItalic', 'snow', '', 'bold') +call s:HL('markdownBold', 'snow', '', 'bold') +call s:HL('markdownH1', 'orange', '', 'bold') +call s:HL('markdownH2', 'lime', '', 'bold') +call s:HL('markdownH3', 'lime', '', 'none') +call s:HL('markdownH4', 'lime', '', 'none') +call s:HL('markdownH5', 'lime', '', 'none') +call s:HL('markdownH6', 'lime', '', 'none') +call s:HL('markdownLinkText', 'toffee', '', 'underline') +call s:HL('markdownIdDeclaration', 'toffee') +call s:HL('markdownAutomaticLink', 'toffee', '', 'bold') +call s:HL('markdownUrl', 'toffee', '', 'bold') +call s:HL('markdownUrldelimiter', 'lightgravel', '', 'bold') +call s:HL('markdownLinkDelimiter', 'lightgravel', '', 'bold') +call s:HL('markdownLinkTextDelimiter', 'lightgravel', '', 'bold') +call s:HL('markdownCodeDelimiter', 'dirtyblonde', '', 'bold') +call s:HL('markdownCode', 'dirtyblonde', '', 'none') +call s:HL('markdownCodeBlock', 'dirtyblonde', '', 'none') + +" }}} +" MySQL {{{ + +call s:HL('mysqlSpecial', 'dress', '', 'bold') + +" }}} +" Python {{{ + +hi def link pythonOperator Operator +call s:HL('pythonBuiltin', 'dress') +call s:HL('pythonBuiltinObj', 'dress') +call s:HL('pythonBuiltinFunc', 'dress') +call s:HL('pythonEscape', 'dress') +call s:HL('pythonException', 'lime', '', 'bold') +call s:HL('pythonExceptions', 'lime', '', 'none') +call s:HL('pythonPrecondit', 'lime', '', 'none') +call s:HL('pythonDecorator', 'taffy', '', 'none') +call s:HL('pythonRun', 'gravel', '', 'bold') +call s:HL('pythonCoding', 'gravel', '', 'bold') + +" }}} +" SLIMV {{{ + +" Rainbow parentheses +call s:HL('hlLevel0', 'gravel') +call s:HL('hlLevel1', 'orange') +call s:HL('hlLevel2', 'saltwatertaffy') +call s:HL('hlLevel3', 'dress') +call s:HL('hlLevel4', 'coffee') +call s:HL('hlLevel5', 'dirtyblonde') +call s:HL('hlLevel6', 'orange') +call s:HL('hlLevel7', 'saltwatertaffy') +call s:HL('hlLevel8', 'dress') +call s:HL('hlLevel9', 'coffee') + +" }}} +" Vim {{{ + +call s:HL('VimCommentTitle', 'lightgravel', '', 'bold') + +call s:HL('VimMapMod', 'dress', '', 'none') +call s:HL('VimMapModKey', 'dress', '', 'none') +call s:HL('VimNotation', 'dress', '', 'none') +call s:HL('VimBracket', 'dress', '', 'none') + +" }}} + +" }}} + diff --git a/colors/dream.vim b/colors/dream.vim deleted file mode 100644 index e38e1289..00000000 --- a/colors/dream.vim +++ /dev/null @@ -1,367 +0,0 @@ -" File: dream.vim -" Maintainer: Crusoe Xia (crusoexia) -" URL: https://github.com/crusoexia/vim-dream -" License: MIT -" -" The code is learnt from hybrid. -" -" Configuration: -" -" * Enable italic: -" -" let g:dream_italic = 1 - -" Initialisation -" -------------- - -if !has("gui_running") && &t_Co < 256 - finish -endif - -if ! exists("g:dream_italic") - let g:dream_italic = 0 -endif - -set background=dark -hi clear - -if exists("syntax_on") - syntax reset -endif - -let colors_name = "dream" - -" Palettes -" -------- - -if has("gui_running") - let s:vmode = "gui" - let s:background = "#2A2B30" - let s:foreground = "#EAECEB" - let s:window = "#3E4E41" - let s:line = "#3C3C41" - let s:lineNr = "#6C6D7A" - let s:darkcolumn = "#2A2C2A" - let s:selection = "#494C51" - let s:comment = "#8D969F" - let s:error = "#5F0000" - - let s:red = "#DD5676" - let s:orangered = "#DB8C7E" - let s:orange = "#D0A12D" - let s:green = "#A8E6B7" - let s:darkgreen = "#C7C582" - let s:grassgreen = "#C2D23A" - let s:purple = "#BC71C0" - - let s:addfg = "#d7ffaf" - let s:addbg = "#5f875f" - let s:delbg = "#f75f5f" - let s:changefg = "#d7d7ff" - let s:changebg = "#5f5f87" -else - let s:vmode = "cterm" - let s:background = "235" - let s:foreground = "251" - let s:window = "234" - let s:line = "236" - let s:lineNr = "239" - let s:darkcolumn = "234" - let s:selection = "237" - let s:comment = "243" - let s:error = "52" - - let s:red = "197" - let s:orangered = "167" - let s:orange = "130" - let s:green = "157" - let s:darkgreen = "143" - let s:grassgreen = "106" - let s:purple = "98" - - let s:addfg = "193" - let s:addbg = "65" - let s:delbg = "167" - let s:changefg = "189" - let s:changebg = "60" -endif - -" Formatting Options -" ------------------ - -let s:none = "NONE" -let s:t_none = "NONE" -let s:n = "NONE" -let s:c = ",undercurl" -let s:r = ",reverse" -let s:s = ",standout" -let s:b = ",bold" -let s:u = ",underline" -let s:i = ",italic" - -" Highlighting Primitives -" ----------------------- - -exe "let s:bg_none = ' ".s:vmode."bg=".s:none ."'" -exe "let s:bg_foreground = ' ".s:vmode."bg=".s:foreground."'" -exe "let s:bg_background = ' ".s:vmode."bg=".s:background."'" -exe "let s:bg_selection = ' ".s:vmode."bg=".s:selection ."'" -exe "let s:bg_line = ' ".s:vmode."bg=".s:line ."'" -exe "let s:bg_lineNr = ' ".s:vmode."bg=".s:lineNr ."'" -exe "let s:bg_comment = ' ".s:vmode."bg=".s:comment ."'" -exe "let s:bg_red = ' ".s:vmode."bg=".s:red ."'" -exe "let s:bg_orangered = ' ".s:vmode."bg=".s:orangered ."'" -exe "let s:bg_orange = ' ".s:vmode."bg=".s:orange ."'" -exe "let s:bg_green = ' ".s:vmode."bg=".s:green ."'" -exe "let s:bg_grassgreen = ' ".s:vmode."bg=".s:grassgreen."'" -exe "let s:bg_darkgreen = ' ".s:vmode."bg=".s:darkgreen ."'" -exe "let s:bg_purple = ' ".s:vmode."bg=".s:purple ."'" -exe "let s:bg_window = ' ".s:vmode."bg=".s:window ."'" -exe "let s:bg_darkcolumn = ' ".s:vmode."bg=".s:darkcolumn."'" -exe "let s:bg_addbg = ' ".s:vmode."bg=".s:addbg ."'" -exe "let s:bg_addfg = ' ".s:vmode."bg=".s:addfg ."'" -exe "let s:bg_delbg = ' ".s:vmode."bg=".s:delbg ."'" -exe "let s:bg_changebg = ' ".s:vmode."bg=".s:changebg ."'" -exe "let s:bg_changefg = ' ".s:vmode."bg=".s:changefg ."'" -exe "let s:bg_error = ' ".s:vmode."bg=".s:error ."'" - -exe "let s:fg_none = ' ".s:vmode."fg=".s:none ."'" -exe "let s:fg_foreground = ' ".s:vmode."fg=".s:foreground."'" -exe "let s:fg_background = ' ".s:vmode."fg=".s:background."'" -exe "let s:fg_selection = ' ".s:vmode."fg=".s:selection ."'" -exe "let s:fg_line = ' ".s:vmode."fg=".s:line ."'" -exe "let s:fg_lineNr = ' ".s:vmode."fg=".s:lineNr ."'" -exe "let s:fg_comment = ' ".s:vmode."fg=".s:comment ."'" -exe "let s:fg_red = ' ".s:vmode."fg=".s:red ."'" -exe "let s:fg_orangered = ' ".s:vmode."fg=".s:orangered ."'" -exe "let s:fg_orange = ' ".s:vmode."fg=".s:orange ."'" -exe "let s:fg_green = ' ".s:vmode."fg=".s:green ."'" -exe "let s:fg_grassgreen = ' ".s:vmode."fg=".s:grassgreen."'" -exe "let s:fg_darkgreen = ' ".s:vmode."fg=".s:darkgreen ."'" -exe "let s:fg_purple = ' ".s:vmode."fg=".s:purple ."'" -exe "let s:fg_window = ' ".s:vmode."fg=".s:window ."'" -exe "let s:fg_darkcolumn = ' ".s:vmode."fg=".s:darkcolumn."'" -exe "let s:fg_addbg = ' ".s:vmode."fg=".s:addbg ."'" -exe "let s:fg_addfg = ' ".s:vmode."fg=".s:addfg ."'" -exe "let s:fg_delbg = ' ".s:vmode."fg=".s:delbg ."'" -exe "let s:fg_changebg = ' ".s:vmode."fg=".s:changebg ."'" -exe "let s:fg_changefg = ' ".s:vmode."fg=".s:changefg ."'" -exe "let s:fg_error = ' ".s:vmode."fg=".s:error ."'" - -exe "let s:fmt_none = ' ".s:vmode."=NONE". " term=NONE" ."'" -exe "let s:fmt_bold = ' ".s:vmode."=NONE".s:b. " term=NONE".s:b ."'" -exe "let s:fmt_bldi = ' ".s:vmode."=NONE".s:b.s:i. " term=NONE".s:b.s:i."'" -exe "let s:fmt_undr = ' ".s:vmode."=NONE".s:u. " term=NONE".s:u ."'" -exe "let s:fmt_undb = ' ".s:vmode."=NONE".s:u.s:b. " term=NONE".s:u.s:b."'" -exe "let s:fmt_undi = ' ".s:vmode."=NONE".s:u.s:i. " term=NONE".s:u.s:i."'" -exe "let s:fmt_curl = ' ".s:vmode."=NONE".s:c. " term=NONE".s:c ."'" -exe "let s:fmt_ital = ' ".s:vmode."=NONE".s:i. " term=NONE".s:i ."'" -exe "let s:fmt_stnd = ' ".s:vmode."=NONE".s:s. " term=NONE".s:s ."'" -exe "let s:fmt_revr = ' ".s:vmode."=NONE".s:r. " term=NONE".s:r ."'" -exe "let s:fmt_revb = ' ".s:vmode."=NONE".s:r.s:b. " term=NONE".s:r.s:b."'" - -" Highlighting -" ------------ - -" editor -exe "hi! Normal" .s:fg_foreground .s:bg_background .s:fmt_none -exe "hi! ColorColumn" .s:fg_none .s:bg_line .s:fmt_none -exe "hi! CursorColumn" .s:fg_none .s:bg_line .s:fmt_none -exe "hi! CursorLine" .s:fg_none .s:bg_line .s:fmt_none -exe "hi! CursorLineNr" .s:fg_grassgreen .s:bg_none .s:fmt_bold -exe "hi! LineNr" .s:fg_lineNr .s:bg_none .s:fmt_none -exe "hi! SignColumn" .s:fg_none .s:bg_darkcolumn .s:fmt_none -exe "hi! VertSplit" .s:fg_green .s:bg_none .s:fmt_none -exe "hi! NonText" .s:fg_selection .s:bg_none .s:fmt_none -exe "hi! StatusLine" .s:fg_comment .s:bg_background .s:fmt_revr -exe "hi! StatusLineNC" .s:fg_window .s:bg_comment .s:fmt_revr -exe "hi! TabLine" .s:fg_foreground .s:bg_darkcolumn .s:fmt_revr -exe "hi! Visual" .s:fg_none .s:bg_selection .s:fmt_none -exe "hi! Search" .s:fg_background .s:bg_grassgreen .s:fmt_none -exe "hi! MatchParen" .s:fg_background .s:bg_orange .s:fmt_none -exe "hi! Question" .s:fg_grassgreen .s:bg_none .s:fmt_none -exe "hi! ModeMsg" .s:fg_grassgreen .s:bg_none .s:fmt_none -exe "hi! MoreMsg" .s:fg_grassgreen .s:bg_none .s:fmt_none -exe "hi! ErrorMsg" .s:fg_background .s:bg_red .s:fmt_stnd -exe "hi! WarningMsg" .s:fg_red .s:bg_none .s:fmt_none - -" misc -exe "hi! SpecialKey" .s:fg_selection .s:bg_none .s:fmt_none -exe "hi! Title" .s:fg_orangered .s:bg_none .s:fmt_none -exe "hi! Directory" .s:fg_green .s:bg_none .s:fmt_bold - -" diff -exe "hi! DiffAdd" .s:fg_addfg .s:bg_addbg .s:fmt_none -exe "hi! DiffDelete" .s:fg_background .s:bg_delbg .s:fmt_none -exe "hi! DiffChange" .s:fg_changefg .s:bg_changebg .s:fmt_none -exe "hi! DiffText" .s:fg_background .s:bg_green .s:fmt_none - -" fold -exe "hi! Folded" .s:fg_comment .s:bg_darkcolumn .s:fmt_none -exe "hi! FoldColumn" .s:fg_none .s:bg_darkcolumn .s:fmt_none -" Incsearch" - -" popup menu -exe "hi! Pmenu" .s:fg_foreground .s:bg_selection .s:fmt_none -exe "hi! PmenuSel" .s:fg_foreground .s:bg_selection .s:fmt_revr -" PmenuSbar" -" PmenuThumb" - -" Generic Syntax Highlighting -" --------------------------- - -if g:dream_italic == 1 - exe "hi! Constant" .s:fg_purple .s:bg_none .s:fmt_ital -else - exe "hi! Constant" .s:fg_purple .s:bg_none .s:fmt_none -endif -exe "hi! Number" .s:fg_purple .s:bg_none .s:fmt_none -exe "hi! Float" .s:fg_purple .s:bg_none .s:fmt_none -exe "hi! Boolean" .s:fg_purple .s:bg_none .s:fmt_none -exe "hi! String" .s:fg_grassgreen .s:bg_none .s:fmt_none -exe "hi! Character" .s:fg_grassgreen .s:bg_none .s:fmt_none - -exe "hi! Identifier" .s:fg_orangered .s:bg_none .s:fmt_none -exe "hi! Function" .s:fg_orangered .s:bg_none .s:fmt_none - -exe "hi! Type" .s:fg_green .s:bg_none .s:fmt_none -" Structure" -" StorageClass" -" Typedef" - -exe "hi! Statement" .s:fg_red .s:bg_none .s:fmt_none -exe "hi! Operator" .s:fg_red .s:bg_none .s:fmt_none -exe "hi! Label" .s:fg_orange .s:bg_none .s:fmt_none -exe "hi! Conditional" .s:fg_red .s:bg_none .s:fmt_none -" Repeat" -" Keyword" -" Exception" - -exe "hi! PreProc" .s:fg_darkgreen .s:bg_none .s:fmt_bold -" Include" -" Define" -" Macro" -" PreCondit" - -exe "hi! Special" .s:fg_green .s:bg_none .s:fmt_none -" SpecialKey -" SpecialChar" -" Tag" -" Delimiter" -" SpecialComment" -" Debug" - -exe "hi! Underlined" .s:fg_orangered .s:bg_none .s:fmt_none -exe "hi! Ignore" .s:fg_none .s:bg_none .s:fmt_none -exe "hi! Error" .s:fg_red .s:bg_error .s:fmt_undr - -exe "hi! SpellBad" .s:fg_red .s:bg_error .s:fmt_undr -exe "hi! SpellCap" .s:fg_orange .s:bg_darkcolumn .s:fmt_undb - -if g:dream_italic == 1 - exe "hi! Todo" .s:fg_orange .s:bg_none .s:fmt_bldi - exe "hi! Comment" .s:fg_comment .s:bg_none .s:fmt_ital -else - exe "hi! Todo" .s:fg_orange .s:bg_none .s:fmt_bold - exe "hi! Comment" .s:fg_comment .s:bg_none .s:fmt_none -endif - -" NerdTree -" -------- - -exe "hi! NERDTreeOpenable" .s:fg_red .s:bg_none .s:fmt_none -exe "hi! NERDTreeClosable" .s:fg_red .s:bg_none .s:fmt_none -exe "hi! NERDTreeHelp" .s:fg_grassgreen .s:bg_none .s:fmt_none -exe "hi! NERDTreeBookmarksHeader" .s:fg_red .s:bg_none .s:fmt_none -exe "hi! NERDTreeBookmarksLeader" .s:fg_red .s:bg_none .s:fmt_none -exe "hi! NERDTreeBookmarkName" .s:fg_darkgreen .s:bg_none .s:fmt_none -exe "hi! NERDTreeCWD" .s:fg_red .s:bg_none .s:fmt_none -exe "hi! NERDTreeDirSlash" .s:fg_orangered .s:bg_none .s:fmt_none - -" Syntastic -" --------- - -hi! link SyntasticErrorSign Error -exe "hi! SyntasticWarningSign" .s:fg_orange .s:bg_darkcolumn .s:fmt_none - -" Language highlight -" ------------------ - -" Vim command -exe "hi! vimCommand" .s:fg_red .s:bg_none .s:fmt_none - -" Javascript -exe "hi! jsFuncName" .s:fg_orangered .s:bg_none .s:fmt_none -exe "hi! jsThis" .s:fg_green .s:bg_none .s:fmt_none -exe "hi! jsFuncCall" .s:fg_none .s:bg_none .s:fmt_none - -if g:dream_italic == 1 - exe "hi! jsFuncArgs" .s:fg_orange .s:bg_none .s:fmt_ital -else - exe "hi! jsFuncArgs" .s:fg_orange .s:bg_none .s:fmt_none -endif - -" Html -exe "hi! htmlTag" .s:fg_foreground .s:bg_none .s:fmt_none -exe "hi! htmlEndTag" .s:fg_foreground .s:bg_none .s:fmt_none -exe "hi! htmlTagName" .s:fg_red .s:bg_none .s:fmt_none -exe "hi! htmlArg" .s:fg_orangered .s:bg_none .s:fmt_none -exe "hi! htmlSpecialChar" .s:fg_purple .s:bg_none .s:fmt_none - -" Xml -hi! link xmlTag htmlTag -hi! link xmlEndTag htmlEndTag -hi! link xmlTagName htmlTagName -hi! link xmlAttrib htmlArg - -" CSS -exe "hi! cssFunctionName" .s:fg_green .s:bg_none .s:fmt_none -exe "hi! cssColor" .s:fg_purple .s:bg_none .s:fmt_none -exe "hi! cssPseudoClassId" .s:fg_purple .s:bg_none .s:fmt_none -exe "hi! cssClassName" .s:fg_orangered .s:bg_none .s:fmt_none -exe "hi! cssValueLength" .s:fg_purple .s:bg_none .s:fmt_none -exe "hi! cssCommonAttr" .s:fg_red .s:bg_none .s:fmt_none -exe "hi! cssBraces" .s:fg_none .s:bg_none .s:fmt_none - -if g:dream_italic == 1 - exe "hi! cssURL" .s:fg_orange .s:bg_none .s:fmt_undi -else - exe "hi! cssURL" .s:fg_orange .s:bg_none .s:fmt_undr -endif - -" ruby -exe "hi! rubyInterpolationDelimiter" .s:fg_none .s:bg_none .s:fmt_none -exe "hi! rubyInstanceVariable" .s:fg_none .s:bg_none .s:fmt_none -exe "hi! rubyGlobalVariable" .s:fg_none .s:bg_none .s:fmt_none -exe "hi! rubyClassVariable" .s:fg_none .s:bg_none .s:fmt_none -exe "hi! rubyPseudoVariable" .s:fg_none .s:bg_none .s:fmt_none -exe "hi! rubyOperator" .s:fg_red .s:bg_none .s:fmt_none -exe "hi! rubyFunction" .s:fg_orangered .s:bg_none .s:fmt_none -exe "hi! rubyInclude" .s:fg_orangered .s:bg_none .s:fmt_none -exe "hi! rubyStringDelimiter" .s:fg_grassgreen .s:bg_none .s:fmt_none -exe "hi! rubyRegexp" .s:fg_grassgreen .s:bg_none .s:fmt_none -exe "hi! rubyRegexpDelimiter" .s:fg_grassgreen .s:bg_none .s:fmt_none -exe "hi! rubySymbol" .s:fg_purple .s:bg_none .s:fmt_none -exe "hi! rubyEscape" .s:fg_purple .s:bg_none .s:fmt_none -exe "hi! rubyControl" .s:fg_green .s:bg_none .s:fmt_none -exe "hi! rubyClass" .s:fg_green .s:bg_none .s:fmt_none -exe "hi! rubyDefine" .s:fg_green .s:bg_none .s:fmt_none -exe "hi! rubyException" .s:fg_green .s:bg_none .s:fmt_none -exe "hi! rubyRailsARAssociationMethod" .s:fg_orange .s:bg_none .s:fmt_none -exe "hi! rubyRailsARMethod" .s:fg_orange .s:bg_none .s:fmt_none -exe "hi! rubyRailsRenderMethod" .s:fg_orange .s:bg_none .s:fmt_none -exe "hi! rubyRailsMethod" .s:fg_orange .s:bg_none .s:fmt_none - -if g:dream_italic == 1 - exe "hi! rubyBlockParameter" .s:fg_orange .s:bg_none .s:fmt_ital - exe "hi! rubyConstant" .s:fg_orange .s:bg_none .s:fmt_ital - exe "hi! rubyIdentifier" .s:fg_orange .s:bg_none .s:fmt_ital -else - exe "hi! rubyBlockParameter" .s:fg_orange .s:bg_none .s:fmt_none - exe "hi! rubyConstant" .s:fg_orange .s:bg_none .s:fmt_none - exe "hi! rubyIdentifier" .s:fg_orange .s:bg_none .s:fmt_none -endif - -" eruby -exe "hi! erubyDelimiter" .s:fg_none .s:bg_none .s:fmt_none -exe "hi! erubyRailsMethod" .s:fg_green .s:bg_none .s:fmt_none diff --git a/colors/gruvbox.vim b/colors/gruvbox.vim new file mode 100644 index 00000000..a0c2c0ba --- /dev/null +++ b/colors/gruvbox.vim @@ -0,0 +1,1393 @@ +" ----------------------------------------------------------------------------- +" File: gruvbox.vim +" Description: Retro groove color scheme for Vim +" Author: morhetz +" Source: https://github.com/morhetz/gruvbox +" Last Modified: 12 Aug 2017 +" ----------------------------------------------------------------------------- + +" Supporting code ------------------------------------------------------------- +" Initialisation: {{{ + +if version > 580 + hi clear + if exists("syntax_on") + syntax reset + endif +endif + +let g:colors_name='gruvbox' + +if !(has('termguicolors') && &termguicolors) && !has('gui_running') && &t_Co != 256 + finish +endif + +" }}} +" Global Settings: {{{ + +if !exists('g:gruvbox_bold') + let g:gruvbox_bold=1 +endif +if !exists('g:gruvbox_italic') + if has('gui_running') || $TERM_ITALICS == 'true' + let g:gruvbox_italic=1 + else + let g:gruvbox_italic=0 + endif +endif +if !exists('g:gruvbox_undercurl') + let g:gruvbox_undercurl=1 +endif +if !exists('g:gruvbox_underline') + let g:gruvbox_underline=1 +endif +if !exists('g:gruvbox_inverse') + let g:gruvbox_inverse=1 +endif + +if !exists('g:gruvbox_guisp_fallback') || index(['fg', 'bg'], g:gruvbox_guisp_fallback) == -1 + let g:gruvbox_guisp_fallback='NONE' +endif + +if !exists('g:gruvbox_improved_strings') + let g:gruvbox_improved_strings=0 +endif + +if !exists('g:gruvbox_improved_warnings') + let g:gruvbox_improved_warnings=0 +endif + +if !exists('g:gruvbox_termcolors') + let g:gruvbox_termcolors=256 +endif + +if !exists('g:gruvbox_invert_indent_guides') + let g:gruvbox_invert_indent_guides=0 +endif + +if exists('g:gruvbox_contrast') + echo 'g:gruvbox_contrast is deprecated; use g:gruvbox_contrast_light and g:gruvbox_contrast_dark instead' +endif + +if !exists('g:gruvbox_contrast_dark') + let g:gruvbox_contrast_dark='medium' +endif + +if !exists('g:gruvbox_contrast_light') + let g:gruvbox_contrast_light='medium' +endif + +let s:is_dark=(&background == 'dark') + +" }}} +" Palette: {{{ + +" setup palette dictionary +let s:gb = {} + +" fill it with absolute colors +let s:gb.dark0_hard = ['#1d2021', 234] " 29-32-33 +let s:gb.dark0 = ['#282828', 235] " 40-40-40 +let s:gb.dark0_soft = ['#32302f', 236] " 50-48-47 +let s:gb.dark1 = ['#3c3836', 237] " 60-56-54 +let s:gb.dark2 = ['#504945', 239] " 80-73-69 +let s:gb.dark3 = ['#665c54', 241] " 102-92-84 +let s:gb.dark4 = ['#7c6f64', 243] " 124-111-100 +let s:gb.dark4_256 = ['#7c6f64', 243] " 124-111-100 + +let s:gb.gray_245 = ['#928374', 245] " 146-131-116 +let s:gb.gray_244 = ['#928374', 244] " 146-131-116 + +let s:gb.light0_hard = ['#f9f5d7', 230] " 249-245-215 +let s:gb.light0 = ['#fbf1c7', 229] " 253-244-193 +let s:gb.light0_soft = ['#f2e5bc', 228] " 242-229-188 +let s:gb.light1 = ['#ebdbb2', 223] " 235-219-178 +let s:gb.light2 = ['#d5c4a1', 250] " 213-196-161 +let s:gb.light3 = ['#bdae93', 248] " 189-174-147 +let s:gb.light4 = ['#a89984', 246] " 168-153-132 +let s:gb.light4_256 = ['#a89984', 246] " 168-153-132 + +let s:gb.bright_red = ['#fb4934', 167] " 251-73-52 +let s:gb.bright_green = ['#b8bb26', 142] " 184-187-38 +let s:gb.bright_yellow = ['#fabd2f', 214] " 250-189-47 +let s:gb.bright_blue = ['#83a598', 109] " 131-165-152 +let s:gb.bright_purple = ['#d3869b', 175] " 211-134-155 +let s:gb.bright_aqua = ['#8ec07c', 108] " 142-192-124 +let s:gb.bright_orange = ['#fe8019', 208] " 254-128-25 + +let s:gb.neutral_red = ['#cc241d', 124] " 204-36-29 +let s:gb.neutral_green = ['#98971a', 106] " 152-151-26 +let s:gb.neutral_yellow = ['#d79921', 172] " 215-153-33 +let s:gb.neutral_blue = ['#458588', 66] " 69-133-136 +let s:gb.neutral_purple = ['#b16286', 132] " 177-98-134 +let s:gb.neutral_aqua = ['#689d6a', 72] " 104-157-106 +let s:gb.neutral_orange = ['#d65d0e', 166] " 214-93-14 + +let s:gb.faded_red = ['#9d0006', 88] " 157-0-6 +let s:gb.faded_green = ['#79740e', 100] " 121-116-14 +let s:gb.faded_yellow = ['#b57614', 136] " 181-118-20 +let s:gb.faded_blue = ['#076678', 24] " 7-102-120 +let s:gb.faded_purple = ['#8f3f71', 96] " 143-63-113 +let s:gb.faded_aqua = ['#427b58', 66] " 66-123-88 +let s:gb.faded_orange = ['#af3a03', 130] " 175-58-3 + +" }}} +" Setup Emphasis: {{{ + +let s:bold = 'bold,' +if g:gruvbox_bold == 0 + let s:bold = '' +endif + +let s:italic = 'italic,' +if g:gruvbox_italic == 0 + let s:italic = '' +endif + +let s:underline = 'underline,' +if g:gruvbox_underline == 0 + let s:underline = '' +endif + +let s:undercurl = 'undercurl,' +if g:gruvbox_undercurl == 0 + let s:undercurl = '' +endif + +let s:inverse = 'inverse,' +if g:gruvbox_inverse == 0 + let s:inverse = '' +endif + +" }}} +" Setup Colors: {{{ + +let s:vim_bg = ['bg', 'bg'] +let s:vim_fg = ['fg', 'fg'] +let s:none = ['NONE', 'NONE'] + +" determine relative colors +if s:is_dark + let s:bg0 = s:gb.dark0 + if g:gruvbox_contrast_dark == 'soft' + let s:bg0 = s:gb.dark0_soft + elseif g:gruvbox_contrast_dark == 'hard' + let s:bg0 = s:gb.dark0_hard + endif + + let s:bg1 = s:gb.dark1 + let s:bg2 = s:gb.dark2 + let s:bg3 = s:gb.dark3 + let s:bg4 = s:gb.dark4 + + let s:gray = s:gb.gray_245 + + let s:fg0 = s:gb.light0 + let s:fg1 = s:gb.light1 + let s:fg2 = s:gb.light2 + let s:fg3 = s:gb.light3 + let s:fg4 = s:gb.light4 + + let s:fg4_256 = s:gb.light4_256 + + let s:red = s:gb.bright_red + let s:green = s:gb.bright_green + let s:yellow = s:gb.bright_yellow + let s:blue = s:gb.bright_blue + let s:purple = s:gb.bright_purple + let s:aqua = s:gb.bright_aqua + let s:orange = s:gb.bright_orange +else + let s:bg0 = s:gb.light0 + if g:gruvbox_contrast_light == 'soft' + let s:bg0 = s:gb.light0_soft + elseif g:gruvbox_contrast_light == 'hard' + let s:bg0 = s:gb.light0_hard + endif + + let s:bg1 = s:gb.light1 + let s:bg2 = s:gb.light2 + let s:bg3 = s:gb.light3 + let s:bg4 = s:gb.light4 + + let s:gray = s:gb.gray_244 + + let s:fg0 = s:gb.dark0 + let s:fg1 = s:gb.dark1 + let s:fg2 = s:gb.dark2 + let s:fg3 = s:gb.dark3 + let s:fg4 = s:gb.dark4 + + let s:fg4_256 = s:gb.dark4_256 + + let s:red = s:gb.faded_red + let s:green = s:gb.faded_green + let s:yellow = s:gb.faded_yellow + let s:blue = s:gb.faded_blue + let s:purple = s:gb.faded_purple + let s:aqua = s:gb.faded_aqua + let s:orange = s:gb.faded_orange +endif + +" reset to 16 colors fallback +if g:gruvbox_termcolors == 16 + let s:bg0[1] = 0 + let s:fg4[1] = 7 + let s:gray[1] = 8 + let s:red[1] = 9 + let s:green[1] = 10 + let s:yellow[1] = 11 + let s:blue[1] = 12 + let s:purple[1] = 13 + let s:aqua[1] = 14 + let s:fg1[1] = 15 +endif + +" save current relative colors back to palette dictionary +let s:gb.bg0 = s:bg0 +let s:gb.bg1 = s:bg1 +let s:gb.bg2 = s:bg2 +let s:gb.bg3 = s:bg3 +let s:gb.bg4 = s:bg4 + +let s:gb.gray = s:gray + +let s:gb.fg0 = s:fg0 +let s:gb.fg1 = s:fg1 +let s:gb.fg2 = s:fg2 +let s:gb.fg3 = s:fg3 +let s:gb.fg4 = s:fg4 + +let s:gb.fg4_256 = s:fg4_256 + +let s:gb.red = s:red +let s:gb.green = s:green +let s:gb.yellow = s:yellow +let s:gb.blue = s:blue +let s:gb.purple = s:purple +let s:gb.aqua = s:aqua +let s:gb.orange = s:orange + +" }}} +" Setup Terminal Colors For Neovim: {{{ + +if has('nvim') + let g:terminal_color_0 = s:bg0[0] + let g:terminal_color_8 = s:gray[0] + + let g:terminal_color_1 = s:gb.neutral_red[0] + let g:terminal_color_9 = s:red[0] + + let g:terminal_color_2 = s:gb.neutral_green[0] + let g:terminal_color_10 = s:green[0] + + let g:terminal_color_3 = s:gb.neutral_yellow[0] + let g:terminal_color_11 = s:yellow[0] + + let g:terminal_color_4 = s:gb.neutral_blue[0] + let g:terminal_color_12 = s:blue[0] + + let g:terminal_color_5 = s:gb.neutral_purple[0] + let g:terminal_color_13 = s:purple[0] + + let g:terminal_color_6 = s:gb.neutral_aqua[0] + let g:terminal_color_14 = s:aqua[0] + + let g:terminal_color_7 = s:fg4[0] + let g:terminal_color_15 = s:fg1[0] +endif + +" }}} +" Overload Setting: {{{ + +let s:hls_cursor = s:orange +if exists('g:gruvbox_hls_cursor') + let s:hls_cursor = get(s:gb, g:gruvbox_hls_cursor) +endif + +let s:number_column = s:none +if exists('g:gruvbox_number_column') + let s:number_column = get(s:gb, g:gruvbox_number_column) +endif + +let s:sign_column = s:bg1 + +if exists('g:gitgutter_override_sign_column_highlight') && + \ g:gitgutter_override_sign_column_highlight == 1 + let s:sign_column = s:number_column +else + let g:gitgutter_override_sign_column_highlight = 0 + + if exists('g:gruvbox_sign_column') + let s:sign_column = get(s:gb, g:gruvbox_sign_column) + endif +endif + +let s:color_column = s:bg1 +if exists('g:gruvbox_color_column') + let s:color_column = get(s:gb, g:gruvbox_color_column) +endif + +let s:vert_split = s:bg0 +if exists('g:gruvbox_vert_split') + let s:vert_split = get(s:gb, g:gruvbox_vert_split) +endif + +let s:invert_signs = '' +if exists('g:gruvbox_invert_signs') + if g:gruvbox_invert_signs == 1 + let s:invert_signs = s:inverse + endif +endif + +let s:invert_selection = s:inverse +if exists('g:gruvbox_invert_selection') + if g:gruvbox_invert_selection == 0 + let s:invert_selection = '' + endif +endif + +let s:invert_tabline = '' +if exists('g:gruvbox_invert_tabline') + if g:gruvbox_invert_tabline == 1 + let s:invert_tabline = s:inverse + endif +endif + +let s:italicize_comments = s:italic +if exists('g:gruvbox_italicize_comments') + if g:gruvbox_italicize_comments == 0 + let s:italicize_comments = '' + endif +endif + +let s:italicize_strings = '' +if exists('g:gruvbox_italicize_strings') + if g:gruvbox_italicize_strings == 1 + let s:italicize_strings = s:italic + endif +endif + +" }}} +" Highlighting Function: {{{ + +function! s:HL(group, fg, ...) + " Arguments: group, guifg, guibg, gui, guisp + + " foreground + let fg = a:fg + + " background + if a:0 >= 1 + let bg = a:1 + else + let bg = s:none + endif + + " emphasis + if a:0 >= 2 && strlen(a:2) + let emstr = a:2 + else + let emstr = 'NONE,' + endif + + " special fallback + if a:0 >= 3 + if g:gruvbox_guisp_fallback != 'NONE' + let fg = a:3 + endif + + " bg fallback mode should invert higlighting + if g:gruvbox_guisp_fallback == 'bg' + let emstr .= 'inverse,' + endif + endif + + let histring = [ 'hi', a:group, + \ 'guifg=' . fg[0], 'ctermfg=' . fg[1], + \ 'guibg=' . bg[0], 'ctermbg=' . bg[1], + \ 'gui=' . emstr[:-2], 'cterm=' . emstr[:-2] + \ ] + + " special + if a:0 >= 3 + call add(histring, 'guisp=' . a:3[0]) + endif + + execute join(histring, ' ') +endfunction + +" }}} +" Gruvbox Hi Groups: {{{ + +" memoize common hi groups +call s:HL('GruvboxFg0', s:fg0) +call s:HL('GruvboxFg1', s:fg1) +call s:HL('GruvboxFg2', s:fg2) +call s:HL('GruvboxFg3', s:fg3) +call s:HL('GruvboxFg4', s:fg4) +call s:HL('GruvboxGray', s:gray) +call s:HL('GruvboxBg0', s:bg0) +call s:HL('GruvboxBg1', s:bg1) +call s:HL('GruvboxBg2', s:bg2) +call s:HL('GruvboxBg3', s:bg3) +call s:HL('GruvboxBg4', s:bg4) + +call s:HL('GruvboxRed', s:red) +call s:HL('GruvboxRedBold', s:red, s:none, s:bold) +call s:HL('GruvboxGreen', s:green) +call s:HL('GruvboxGreenBold', s:green, s:none, s:bold) +call s:HL('GruvboxYellow', s:yellow) +call s:HL('GruvboxYellowBold', s:yellow, s:none, s:bold) +call s:HL('GruvboxBlue', s:blue) +call s:HL('GruvboxBlueBold', s:blue, s:none, s:bold) +call s:HL('GruvboxPurple', s:purple) +call s:HL('GruvboxPurpleBold', s:purple, s:none, s:bold) +call s:HL('GruvboxAqua', s:aqua) +call s:HL('GruvboxAquaBold', s:aqua, s:none, s:bold) +call s:HL('GruvboxOrange', s:orange) +call s:HL('GruvboxOrangeBold', s:orange, s:none, s:bold) + +call s:HL('GruvboxRedSign', s:red, s:sign_column, s:invert_signs) +call s:HL('GruvboxGreenSign', s:green, s:sign_column, s:invert_signs) +call s:HL('GruvboxYellowSign', s:yellow, s:sign_column, s:invert_signs) +call s:HL('GruvboxBlueSign', s:blue, s:sign_column, s:invert_signs) +call s:HL('GruvboxPurpleSign', s:purple, s:sign_column, s:invert_signs) +call s:HL('GruvboxAquaSign', s:aqua, s:sign_column, s:invert_signs) + +" }}} + +" Vanilla colorscheme --------------------------------------------------------- +" General UI: {{{ + +" Normal text +call s:HL('Normal', s:fg1, s:bg0) + +" Correct background (see issue #7): +" --- Problem with changing between dark and light on 256 color terminal +" --- https://github.com/morhetz/gruvbox/issues/7 +if s:is_dark + set background=dark +else + set background=light +endif + +if version >= 700 + " Screen line that the cursor is + call s:HL('CursorLine', s:none, s:bg1) + " Screen column that the cursor is + hi! link CursorColumn CursorLine + + " Tab pages line filler + call s:HL('TabLineFill', s:bg4, s:bg1, s:invert_tabline) + " Active tab page label + call s:HL('TabLineSel', s:green, s:bg1, s:invert_tabline) + " Not active tab page label + hi! link TabLine TabLineFill + + " Match paired bracket under the cursor + call s:HL('MatchParen', s:none, s:bg3, s:bold) +endif + +if version >= 703 + " Highlighted screen columns + call s:HL('ColorColumn', s:none, s:color_column) + + " Concealed element: \lambda → λ + call s:HL('Conceal', s:blue, s:none) + + " Line number of CursorLine + call s:HL('CursorLineNr', s:yellow, s:bg1) +endif + +hi! link NonText GruvboxBg2 +hi! link SpecialKey GruvboxBg2 + +call s:HL('Visual', s:none, s:bg3, s:invert_selection) +hi! link VisualNOS Visual + +call s:HL('Search', s:yellow, s:bg0, s:inverse) +call s:HL('IncSearch', s:hls_cursor, s:bg0, s:inverse) + +call s:HL('Underlined', s:blue, s:none, s:underline) + +call s:HL('StatusLine', s:bg2, s:fg1, s:inverse) +call s:HL('StatusLineNC', s:bg1, s:fg4, s:inverse) + +" The column separating vertically split windows +call s:HL('VertSplit', s:bg3, s:vert_split) + +" Current match in wildmenu completion +call s:HL('WildMenu', s:blue, s:bg2, s:bold) + +" Directory names, special names in listing +hi! link Directory GruvboxGreenBold + +" Titles for output from :set all, :autocmd, etc. +hi! link Title GruvboxGreenBold + +" Error messages on the command line +call s:HL('ErrorMsg', s:bg0, s:red, s:bold) +" More prompt: -- More -- +hi! link MoreMsg GruvboxYellowBold +" Current mode message: -- INSERT -- +hi! link ModeMsg GruvboxYellowBold +" 'Press enter' prompt and yes/no questions +hi! link Question GruvboxOrangeBold +" Warning messages +hi! link WarningMsg GruvboxRedBold + +" }}} +" Gutter: {{{ + +" Line number for :number and :# commands +call s:HL('LineNr', s:bg4, s:number_column) + +" Column where signs are displayed +call s:HL('SignColumn', s:none, s:sign_column) + +" Line used for closed folds +call s:HL('Folded', s:gray, s:bg1, s:italic) +" Column where folds are displayed +call s:HL('FoldColumn', s:gray, s:bg1) + +" }}} +" Cursor: {{{ + +" Character under cursor +call s:HL('Cursor', s:none, s:none, s:inverse) +" Visual mode cursor, selection +hi! link vCursor Cursor +" Input moder cursor +hi! link iCursor Cursor +" Language mapping cursor +hi! link lCursor Cursor + +" }}} +" Syntax Highlighting: {{{ + +if g:gruvbox_improved_strings == 0 + hi! link Special GruvboxOrange +else + call s:HL('Special', s:orange, s:bg1, s:italicize_strings) +endif + +call s:HL('Comment', s:gray, s:none, s:italicize_comments) +call s:HL('Todo', s:vim_fg, s:vim_bg, s:bold . s:italic) +call s:HL('Error', s:red, s:vim_bg, s:bold . s:inverse) + +" Generic statement +hi! link Statement GruvboxRed +" if, then, else, endif, swicth, etc. +hi! link Conditional GruvboxRed +" for, do, while, etc. +hi! link Repeat GruvboxRed +" case, default, etc. +hi! link Label GruvboxRed +" try, catch, throw +hi! link Exception GruvboxRed +" sizeof, "+", "*", etc. +hi! link Operator Normal +" Any other keyword +hi! link Keyword GruvboxRed + +" Variable name +hi! link Identifier GruvboxBlue +" Function name +hi! link Function GruvboxGreenBold + +" Generic preprocessor +hi! link PreProc GruvboxAqua +" Preprocessor #include +hi! link Include GruvboxAqua +" Preprocessor #define +hi! link Define GruvboxAqua +" Same as Define +hi! link Macro GruvboxAqua +" Preprocessor #if, #else, #endif, etc. +hi! link PreCondit GruvboxAqua + +" Generic constant +hi! link Constant GruvboxPurple +" Character constant: 'c', '/n' +hi! link Character GruvboxPurple +" String constant: "this is a string" +if g:gruvbox_improved_strings == 0 + call s:HL('String', s:green, s:none, s:italicize_strings) +else + call s:HL('String', s:fg1, s:bg1, s:italicize_strings) +endif +" Boolean constant: TRUE, false +hi! link Boolean GruvboxPurple +" Number constant: 234, 0xff +hi! link Number GruvboxPurple +" Floating point constant: 2.3e10 +hi! link Float GruvboxPurple + +" Generic type +hi! link Type GruvboxYellow +" static, register, volatile, etc +hi! link StorageClass GruvboxOrange +" struct, union, enum, etc. +hi! link Structure GruvboxAqua +" typedef +hi! link Typedef GruvboxYellow + +" }}} +" Completion Menu: {{{ + +if version >= 700 + " Popup menu: normal item + call s:HL('Pmenu', s:fg1, s:bg2) + " Popup menu: selected item + call s:HL('PmenuSel', s:bg2, s:blue, s:bold) + " Popup menu: scrollbar + call s:HL('PmenuSbar', s:none, s:bg2) + " Popup menu: scrollbar thumb + call s:HL('PmenuThumb', s:none, s:bg4) +endif + +" }}} +" Diffs: {{{ + +call s:HL('DiffDelete', s:red, s:bg0, s:inverse) +call s:HL('DiffAdd', s:green, s:bg0, s:inverse) +"call s:HL('DiffChange', s:bg0, s:blue) +"call s:HL('DiffText', s:bg0, s:yellow) + +" Alternative setting +call s:HL('DiffChange', s:aqua, s:bg0, s:inverse) +call s:HL('DiffText', s:yellow, s:bg0, s:inverse) + +" }}} +" Spelling: {{{ + +if has("spell") + " Not capitalised word, or compile warnings + if g:gruvbox_improved_warnings == 0 + call s:HL('SpellCap', s:none, s:none, s:undercurl, s:red) + else + call s:HL('SpellCap', s:green, s:none, s:bold . s:italic) + endif + " Not recognized word + call s:HL('SpellBad', s:none, s:none, s:undercurl, s:blue) + " Wrong spelling for selected region + call s:HL('SpellLocal', s:none, s:none, s:undercurl, s:aqua) + " Rare word + call s:HL('SpellRare', s:none, s:none, s:undercurl, s:purple) +endif + +" }}} + +" Plugin specific ------------------------------------------------------------- +" EasyMotion: {{{ + +hi! link EasyMotionTarget Search +hi! link EasyMotionShade Comment + +" }}} +" Sneak: {{{ + +hi! link Sneak Search +hi! link SneakLabel Search + +" }}} +" Indent Guides: {{{ + +if !exists('g:indent_guides_auto_colors') + let g:indent_guides_auto_colors = 0 +endif + +if g:indent_guides_auto_colors == 0 + if g:gruvbox_invert_indent_guides == 0 + call s:HL('IndentGuidesOdd', s:vim_bg, s:bg2) + call s:HL('IndentGuidesEven', s:vim_bg, s:bg1) + else + call s:HL('IndentGuidesOdd', s:vim_bg, s:bg2, s:inverse) + call s:HL('IndentGuidesEven', s:vim_bg, s:bg3, s:inverse) + endif +endif + +" }}} +" IndentLine: {{{ + +if !exists('g:indentLine_color_term') + let g:indentLine_color_term = s:bg2[1] +endif +if !exists('g:indentLine_color_gui') + let g:indentLine_color_gui = s:bg2[0] +endif + +" }}} +" Rainbow Parentheses: {{{ + +if !exists('g:rbpt_colorpairs') + let g:rbpt_colorpairs = + \ [ + \ ['blue', '#458588'], ['magenta', '#b16286'], + \ ['red', '#cc241d'], ['166', '#d65d0e'] + \ ] +endif + +let g:rainbow_guifgs = [ '#d65d0e', '#cc241d', '#b16286', '#458588' ] +let g:rainbow_ctermfgs = [ '166', 'red', 'magenta', 'blue' ] + +if !exists('g:rainbow_conf') + let g:rainbow_conf = {} +endif +if !has_key(g:rainbow_conf, 'guifgs') + let g:rainbow_conf['guifgs'] = g:rainbow_guifgs +endif +if !has_key(g:rainbow_conf, 'ctermfgs') + let g:rainbow_conf['ctermfgs'] = g:rainbow_ctermfgs +endif + +let g:niji_dark_colours = g:rbpt_colorpairs +let g:niji_light_colours = g:rbpt_colorpairs + +"}}} +" GitGutter: {{{ + +hi! link GitGutterAdd GruvboxGreenSign +hi! link GitGutterChange GruvboxAquaSign +hi! link GitGutterDelete GruvboxRedSign +hi! link GitGutterChangeDelete GruvboxAquaSign + +" }}} +" GitCommit: "{{{ + +hi! link gitcommitSelectedFile GruvboxGreen +hi! link gitcommitDiscardedFile GruvboxRed + +" }}} +" Signify: {{{ + +hi! link SignifySignAdd GruvboxGreenSign +hi! link SignifySignChange GruvboxAquaSign +hi! link SignifySignDelete GruvboxRedSign + +" }}} +" Syntastic: {{{ + +call s:HL('SyntasticError', s:none, s:none, s:undercurl, s:red) +call s:HL('SyntasticWarning', s:none, s:none, s:undercurl, s:yellow) + +hi! link SyntasticErrorSign GruvboxRedSign +hi! link SyntasticWarningSign GruvboxYellowSign + +" }}} +" Signature: {{{ +hi! link SignatureMarkText GruvboxBlueSign +hi! link SignatureMarkerText GruvboxPurpleSign + +" }}} +" ShowMarks: {{{ + +hi! link ShowMarksHLl GruvboxBlueSign +hi! link ShowMarksHLu GruvboxBlueSign +hi! link ShowMarksHLo GruvboxBlueSign +hi! link ShowMarksHLm GruvboxBlueSign + +" }}} +" CtrlP: {{{ + +hi! link CtrlPMatch GruvboxYellow +hi! link CtrlPNoEntries GruvboxRed +hi! link CtrlPPrtBase GruvboxBg2 +hi! link CtrlPPrtCursor GruvboxBlue +hi! link CtrlPLinePre GruvboxBg2 + +call s:HL('CtrlPMode1', s:blue, s:bg2, s:bold) +call s:HL('CtrlPMode2', s:bg0, s:blue, s:bold) +call s:HL('CtrlPStats', s:fg4, s:bg2, s:bold) + +" }}} +" Startify: {{{ + +hi! link StartifyBracket GruvboxFg3 +hi! link StartifyFile GruvboxFg1 +hi! link StartifyNumber GruvboxBlue +hi! link StartifyPath GruvboxGray +hi! link StartifySlash GruvboxGray +hi! link StartifySection GruvboxYellow +hi! link StartifySpecial GruvboxBg2 +hi! link StartifyHeader GruvboxOrange +hi! link StartifyFooter GruvboxBg2 + +" }}} +" Vimshell: {{{ + +let g:vimshell_escape_colors = [ + \ s:bg4[0], s:red[0], s:green[0], s:yellow[0], + \ s:blue[0], s:purple[0], s:aqua[0], s:fg4[0], + \ s:bg0[0], s:red[0], s:green[0], s:orange[0], + \ s:blue[0], s:purple[0], s:aqua[0], s:fg0[0] + \ ] + +" }}} +" BufTabLine: {{{ + +call s:HL('BufTabLineCurrent', s:bg0, s:fg4) +call s:HL('BufTabLineActive', s:fg4, s:bg2) +call s:HL('BufTabLineHidden', s:bg4, s:bg1) +call s:HL('BufTabLineFill', s:bg0, s:bg0) + +" }}} +" Asynchronous Lint Engine: {{{ + +call s:HL('ALEError', s:none, s:none, s:undercurl, s:red) +call s:HL('ALEWarning', s:none, s:none, s:undercurl, s:yellow) +call s:HL('ALEInfo', s:none, s:none, s:undercurl, s:blue) + +hi! link ALEErrorSign GruvboxRedSign +hi! link ALEWarningSign GruvboxYellowSign +hi! link ALEInfoSign GruvboxBlueSign + +" }}} +" Dirvish: {{{ + +hi! link DirvishPathTail GruvboxAqua +hi! link DirvishArg GruvboxYellow + +" }}} +" Netrw: {{{ + +hi! link netrwDir GruvboxAqua +hi! link netrwClassify GruvboxAqua +hi! link netrwLink GruvboxGray +hi! link netrwSymLink GruvboxFg1 +hi! link netrwExe GruvboxYellow +hi! link netrwComment GruvboxGray +hi! link netrwList GruvboxBlue +hi! link netrwHelpCmd GruvboxAqua +hi! link netrwCmdSep GruvboxFg3 +hi! link netrwVersion GruvboxGreen + +" }}} +" NERDTree: {{{ + +hi! link NERDTreeDir GruvboxAqua +hi! link NERDTreeDirSlash GruvboxAqua + +hi! link NERDTreeOpenable GruvboxOrange +hi! link NERDTreeClosable GruvboxOrange + +hi! link NERDTreeFile GruvboxFg1 +hi! link NERDTreeExecFile GruvboxYellow + +hi! link NERDTreeUp GruvboxGray +hi! link NERDTreeCWD GruvboxGreen +hi! link NERDTreeHelp GruvboxFg1 + +hi! link NERDTreeToggleOn GruvboxGreen +hi! link NERDTreeToggleOff GruvboxRed + +" }}} +" Vim Multiple Cursors: {{{ + +call s:HL('multiple_cursors_cursor', s:none, s:none, s:inverse) +call s:HL('multiple_cursors_visual', s:none, s:bg2) + +" }}} + +" Filetype specific ----------------------------------------------------------- +" Diff: {{{ + +hi! link diffAdded GruvboxGreen +hi! link diffRemoved GruvboxRed +hi! link diffChanged GruvboxAqua + +hi! link diffFile GruvboxOrange +hi! link diffNewFile GruvboxYellow + +hi! link diffLine GruvboxBlue + +" }}} +" Html: {{{ + +hi! link htmlTag GruvboxBlue +hi! link htmlEndTag GruvboxBlue + +hi! link htmlTagName GruvboxAquaBold +hi! link htmlArg GruvboxAqua + +hi! link htmlScriptTag GruvboxPurple +hi! link htmlTagN GruvboxFg1 +hi! link htmlSpecialTagName GruvboxAquaBold + +call s:HL('htmlLink', s:fg4, s:none, s:underline) + +hi! link htmlSpecialChar GruvboxOrange + +call s:HL('htmlBold', s:vim_fg, s:vim_bg, s:bold) +call s:HL('htmlBoldUnderline', s:vim_fg, s:vim_bg, s:bold . s:underline) +call s:HL('htmlBoldItalic', s:vim_fg, s:vim_bg, s:bold . s:italic) +call s:HL('htmlBoldUnderlineItalic', s:vim_fg, s:vim_bg, s:bold . s:underline . s:italic) + +call s:HL('htmlUnderline', s:vim_fg, s:vim_bg, s:underline) +call s:HL('htmlUnderlineItalic', s:vim_fg, s:vim_bg, s:underline . s:italic) +call s:HL('htmlItalic', s:vim_fg, s:vim_bg, s:italic) + +" }}} +" Xml: {{{ + +hi! link xmlTag GruvboxBlue +hi! link xmlEndTag GruvboxBlue +hi! link xmlTagName GruvboxBlue +hi! link xmlEqual GruvboxBlue +hi! link docbkKeyword GruvboxAquaBold + +hi! link xmlDocTypeDecl GruvboxGray +hi! link xmlDocTypeKeyword GruvboxPurple +hi! link xmlCdataStart GruvboxGray +hi! link xmlCdataCdata GruvboxPurple +hi! link dtdFunction GruvboxGray +hi! link dtdTagName GruvboxPurple + +hi! link xmlAttrib GruvboxAqua +hi! link xmlProcessingDelim GruvboxGray +hi! link dtdParamEntityPunct GruvboxGray +hi! link dtdParamEntityDPunct GruvboxGray +hi! link xmlAttribPunct GruvboxGray + +hi! link xmlEntity GruvboxOrange +hi! link xmlEntityPunct GruvboxOrange +" }}} +" Vim: {{{ + +call s:HL('vimCommentTitle', s:fg4_256, s:none, s:bold . s:italicize_comments) + +hi! link vimNotation GruvboxOrange +hi! link vimBracket GruvboxOrange +hi! link vimMapModKey GruvboxOrange +hi! link vimFuncSID GruvboxFg3 +hi! link vimSetSep GruvboxFg3 +hi! link vimSep GruvboxFg3 +hi! link vimContinue GruvboxFg3 + +" }}} +" Clojure: {{{ + +hi! link clojureKeyword GruvboxBlue +hi! link clojureCond GruvboxOrange +hi! link clojureSpecial GruvboxOrange +hi! link clojureDefine GruvboxOrange + +hi! link clojureFunc GruvboxYellow +hi! link clojureRepeat GruvboxYellow +hi! link clojureCharacter GruvboxAqua +hi! link clojureStringEscape GruvboxAqua +hi! link clojureException GruvboxRed + +hi! link clojureRegexp GruvboxAqua +hi! link clojureRegexpEscape GruvboxAqua +call s:HL('clojureRegexpCharClass', s:fg3, s:none, s:bold) +hi! link clojureRegexpMod clojureRegexpCharClass +hi! link clojureRegexpQuantifier clojureRegexpCharClass + +hi! link clojureParen GruvboxFg3 +hi! link clojureAnonArg GruvboxYellow +hi! link clojureVariable GruvboxBlue +hi! link clojureMacro GruvboxOrange + +hi! link clojureMeta GruvboxYellow +hi! link clojureDeref GruvboxYellow +hi! link clojureQuote GruvboxYellow +hi! link clojureUnquote GruvboxYellow + +" }}} +" C: {{{ + +hi! link cOperator GruvboxPurple +hi! link cStructure GruvboxOrange + +" }}} +" Python: {{{ + +hi! link pythonBuiltin GruvboxOrange +hi! link pythonBuiltinObj GruvboxOrange +hi! link pythonBuiltinFunc GruvboxOrange +hi! link pythonFunction GruvboxAqua +hi! link pythonDecorator GruvboxRed +hi! link pythonInclude GruvboxBlue +hi! link pythonImport GruvboxBlue +hi! link pythonRun GruvboxBlue +hi! link pythonCoding GruvboxBlue +hi! link pythonOperator GruvboxRed +hi! link pythonException GruvboxRed +hi! link pythonExceptions GruvboxPurple +hi! link pythonBoolean GruvboxPurple +hi! link pythonDot GruvboxFg3 +hi! link pythonConditional GruvboxRed +hi! link pythonRepeat GruvboxRed +hi! link pythonDottedName GruvboxGreenBold + +" }}} +" CSS: {{{ + +hi! link cssBraces GruvboxBlue +hi! link cssFunctionName GruvboxYellow +hi! link cssIdentifier GruvboxOrange +hi! link cssClassName GruvboxGreen +hi! link cssColor GruvboxBlue +hi! link cssSelectorOp GruvboxBlue +hi! link cssSelectorOp2 GruvboxBlue +hi! link cssImportant GruvboxGreen +hi! link cssVendor GruvboxFg1 + +hi! link cssTextProp GruvboxAqua +hi! link cssAnimationProp GruvboxAqua +hi! link cssUIProp GruvboxYellow +hi! link cssTransformProp GruvboxAqua +hi! link cssTransitionProp GruvboxAqua +hi! link cssPrintProp GruvboxAqua +hi! link cssPositioningProp GruvboxYellow +hi! link cssBoxProp GruvboxAqua +hi! link cssFontDescriptorProp GruvboxAqua +hi! link cssFlexibleBoxProp GruvboxAqua +hi! link cssBorderOutlineProp GruvboxAqua +hi! link cssBackgroundProp GruvboxAqua +hi! link cssMarginProp GruvboxAqua +hi! link cssListProp GruvboxAqua +hi! link cssTableProp GruvboxAqua +hi! link cssFontProp GruvboxAqua +hi! link cssPaddingProp GruvboxAqua +hi! link cssDimensionProp GruvboxAqua +hi! link cssRenderProp GruvboxAqua +hi! link cssColorProp GruvboxAqua +hi! link cssGeneratedContentProp GruvboxAqua + +" }}} +" JavaScript: {{{ + +hi! link javaScriptBraces GruvboxFg1 +hi! link javaScriptFunction GruvboxAqua +hi! link javaScriptIdentifier GruvboxRed +hi! link javaScriptMember GruvboxBlue +hi! link javaScriptNumber GruvboxPurple +hi! link javaScriptNull GruvboxPurple +hi! link javaScriptParens GruvboxFg3 + +" }}} +" YAJS: {{{ + +hi! link javascriptImport GruvboxAqua +hi! link javascriptExport GruvboxAqua +hi! link javascriptClassKeyword GruvboxAqua +hi! link javascriptClassExtends GruvboxAqua +hi! link javascriptDefault GruvboxAqua + +hi! link javascriptClassName GruvboxYellow +hi! link javascriptClassSuperName GruvboxYellow +hi! link javascriptGlobal GruvboxYellow + +hi! link javascriptEndColons GruvboxFg1 +hi! link javascriptFuncArg GruvboxFg1 +hi! link javascriptGlobalMethod GruvboxFg1 +hi! link javascriptNodeGlobal GruvboxFg1 +hi! link javascriptBOMWindowProp GruvboxFg1 +hi! link javascriptArrayMethod GruvboxFg1 +hi! link javascriptArrayStaticMethod GruvboxFg1 +hi! link javascriptCacheMethod GruvboxFg1 +hi! link javascriptDateMethod GruvboxFg1 +hi! link javascriptMathStaticMethod GruvboxFg1 + +" hi! link javascriptProp GruvboxFg1 +hi! link javascriptURLUtilsProp GruvboxFg1 +hi! link javascriptBOMNavigatorProp GruvboxFg1 +hi! link javascriptDOMDocMethod GruvboxFg1 +hi! link javascriptDOMDocProp GruvboxFg1 +hi! link javascriptBOMLocationMethod GruvboxFg1 +hi! link javascriptBOMWindowMethod GruvboxFg1 +hi! link javascriptStringMethod GruvboxFg1 + +hi! link javascriptVariable GruvboxOrange +" hi! link javascriptVariable GruvboxRed +" hi! link javascriptIdentifier GruvboxOrange +" hi! link javascriptClassSuper GruvboxOrange +hi! link javascriptIdentifier GruvboxOrange +hi! link javascriptClassSuper GruvboxOrange + +" hi! link javascriptFuncKeyword GruvboxOrange +" hi! link javascriptAsyncFunc GruvboxOrange +hi! link javascriptFuncKeyword GruvboxAqua +hi! link javascriptAsyncFunc GruvboxAqua +hi! link javascriptClassStatic GruvboxOrange + +hi! link javascriptOperator GruvboxRed +hi! link javascriptForOperator GruvboxRed +hi! link javascriptYield GruvboxRed +hi! link javascriptExceptions GruvboxRed +hi! link javascriptMessage GruvboxRed + +hi! link javascriptTemplateSB GruvboxAqua +hi! link javascriptTemplateSubstitution GruvboxFg1 + +" hi! link javascriptLabel GruvboxBlue +" hi! link javascriptObjectLabel GruvboxBlue +" hi! link javascriptPropertyName GruvboxBlue +hi! link javascriptLabel GruvboxFg1 +hi! link javascriptObjectLabel GruvboxFg1 +hi! link javascriptPropertyName GruvboxFg1 + +hi! link javascriptLogicSymbols GruvboxFg1 +hi! link javascriptArrowFunc GruvboxYellow + +hi! link javascriptDocParamName GruvboxFg4 +hi! link javascriptDocTags GruvboxFg4 +hi! link javascriptDocNotation GruvboxFg4 +hi! link javascriptDocParamType GruvboxFg4 +hi! link javascriptDocNamedParamType GruvboxFg4 + +hi! link javascriptBrackets GruvboxFg1 +hi! link javascriptDOMElemAttrs GruvboxFg1 +hi! link javascriptDOMEventMethod GruvboxFg1 +hi! link javascriptDOMNodeMethod GruvboxFg1 +hi! link javascriptDOMStorageMethod GruvboxFg1 +hi! link javascriptHeadersMethod GruvboxFg1 + +hi! link javascriptAsyncFuncKeyword GruvboxRed +hi! link javascriptAwaitFuncKeyword GruvboxRed + +" }}} +" PanglossJS: {{{ + +hi! link jsClassKeyword GruvboxAqua +hi! link jsExtendsKeyword GruvboxAqua +hi! link jsExportDefault GruvboxAqua +hi! link jsTemplateBraces GruvboxAqua +hi! link jsGlobalNodeObjects GruvboxFg1 +hi! link jsGlobalObjects GruvboxFg1 +hi! link jsFunction GruvboxAqua +hi! link jsFuncParens GruvboxFg3 +hi! link jsParens GruvboxFg3 +hi! link jsNull GruvboxPurple +hi! link jsUndefined GruvboxPurple +hi! link jsClassDefinition GruvboxYellow + +" }}} +" TypeScript: {{{ + +hi! link typeScriptReserved GruvboxAqua +hi! link typeScriptLabel GruvboxAqua +hi! link typeScriptFuncKeyword GruvboxAqua +hi! link typeScriptIdentifier GruvboxOrange +hi! link typeScriptBraces GruvboxFg1 +hi! link typeScriptEndColons GruvboxFg1 +hi! link typeScriptDOMObjects GruvboxFg1 +hi! link typeScriptAjaxMethods GruvboxFg1 +hi! link typeScriptLogicSymbols GruvboxFg1 +hi! link typeScriptDocSeeTag Comment +hi! link typeScriptDocParam Comment +hi! link typeScriptDocTags vimCommentTitle +hi! link typeScriptGlobalObjects GruvboxFg1 +hi! link typeScriptParens GruvboxFg3 +hi! link typeScriptOpSymbols GruvboxFg3 +hi! link typeScriptHtmlElemProperties GruvboxFg1 +hi! link typeScriptNull GruvboxPurple +hi! link typeScriptInterpolationDelimiter GruvboxAqua + +" }}} +" PureScript: {{{ + +hi! link purescriptModuleKeyword GruvboxAqua +hi! link purescriptModuleName GruvboxFg1 +hi! link purescriptWhere GruvboxAqua +hi! link purescriptDelimiter GruvboxFg4 +hi! link purescriptType GruvboxFg1 +hi! link purescriptImportKeyword GruvboxAqua +hi! link purescriptHidingKeyword GruvboxAqua +hi! link purescriptAsKeyword GruvboxAqua +hi! link purescriptStructure GruvboxAqua +hi! link purescriptOperator GruvboxBlue + +hi! link purescriptTypeVar GruvboxFg1 +hi! link purescriptConstructor GruvboxFg1 +hi! link purescriptFunction GruvboxFg1 +hi! link purescriptConditional GruvboxOrange +hi! link purescriptBacktick GruvboxOrange + +" }}} +" CoffeeScript: {{{ + +hi! link coffeeExtendedOp GruvboxFg3 +hi! link coffeeSpecialOp GruvboxFg3 +hi! link coffeeCurly GruvboxOrange +hi! link coffeeParen GruvboxFg3 +hi! link coffeeBracket GruvboxOrange + +" }}} +" Ruby: {{{ + +hi! link rubyStringDelimiter GruvboxGreen +hi! link rubyInterpolationDelimiter GruvboxAqua + +" }}} +" ObjectiveC: {{{ + +hi! link objcTypeModifier GruvboxRed +hi! link objcDirective GruvboxBlue + +" }}} +" Go: {{{ + +hi! link goDirective GruvboxAqua +hi! link goConstants GruvboxPurple +hi! link goDeclaration GruvboxRed +hi! link goDeclType GruvboxBlue +hi! link goBuiltins GruvboxOrange + +" }}} +" Lua: {{{ + +hi! link luaIn GruvboxRed +hi! link luaFunction GruvboxAqua +hi! link luaTable GruvboxOrange + +" }}} +" MoonScript: {{{ + +hi! link moonSpecialOp GruvboxFg3 +hi! link moonExtendedOp GruvboxFg3 +hi! link moonFunction GruvboxFg3 +hi! link moonObject GruvboxYellow + +" }}} +" Java: {{{ + +hi! link javaAnnotation GruvboxBlue +hi! link javaDocTags GruvboxAqua +hi! link javaCommentTitle vimCommentTitle +hi! link javaParen GruvboxFg3 +hi! link javaParen1 GruvboxFg3 +hi! link javaParen2 GruvboxFg3 +hi! link javaParen3 GruvboxFg3 +hi! link javaParen4 GruvboxFg3 +hi! link javaParen5 GruvboxFg3 +hi! link javaOperator GruvboxOrange + +hi! link javaVarArg GruvboxGreen + +" }}} +" Elixir: {{{ + +hi! link elixirDocString Comment + +hi! link elixirStringDelimiter GruvboxGreen +hi! link elixirInterpolationDelimiter GruvboxAqua + +hi! link elixirModuleDeclaration GruvboxYellow + +" }}} +" Scala: {{{ + +" NB: scala vim syntax file is kinda horrible +hi! link scalaNameDefinition GruvboxFg1 +hi! link scalaCaseFollowing GruvboxFg1 +hi! link scalaCapitalWord GruvboxFg1 +hi! link scalaTypeExtension GruvboxFg1 + +hi! link scalaKeyword GruvboxRed +hi! link scalaKeywordModifier GruvboxRed + +hi! link scalaSpecial GruvboxAqua +hi! link scalaOperator GruvboxFg1 + +hi! link scalaTypeDeclaration GruvboxYellow +hi! link scalaTypeTypePostDeclaration GruvboxYellow + +hi! link scalaInstanceDeclaration GruvboxFg1 +hi! link scalaInterpolation GruvboxAqua + +" }}} +" Markdown: {{{ + +call s:HL('markdownItalic', s:fg3, s:none, s:italic) + +hi! link markdownH1 GruvboxGreenBold +hi! link markdownH2 GruvboxGreenBold +hi! link markdownH3 GruvboxYellowBold +hi! link markdownH4 GruvboxYellowBold +hi! link markdownH5 GruvboxYellow +hi! link markdownH6 GruvboxYellow + +hi! link markdownCode GruvboxAqua +hi! link markdownCodeBlock GruvboxAqua +hi! link markdownCodeDelimiter GruvboxAqua + +hi! link markdownBlockquote GruvboxGray +hi! link markdownListMarker GruvboxGray +hi! link markdownOrderedListMarker GruvboxGray +hi! link markdownRule GruvboxGray +hi! link markdownHeadingRule GruvboxGray + +hi! link markdownUrlDelimiter GruvboxFg3 +hi! link markdownLinkDelimiter GruvboxFg3 +hi! link markdownLinkTextDelimiter GruvboxFg3 + +hi! link markdownHeadingDelimiter GruvboxOrange +hi! link markdownUrl GruvboxPurple +hi! link markdownUrlTitleDelimiter GruvboxGreen + +call s:HL('markdownLinkText', s:gray, s:none, s:underline) +hi! link markdownIdDeclaration markdownLinkText + +" }}} +" Haskell: {{{ + +" hi! link haskellType GruvboxYellow +" hi! link haskellOperators GruvboxOrange +" hi! link haskellConditional GruvboxAqua +" hi! link haskellLet GruvboxOrange +" +hi! link haskellType GruvboxFg1 +hi! link haskellIdentifier GruvboxFg1 +hi! link haskellSeparator GruvboxFg1 +hi! link haskellDelimiter GruvboxFg4 +hi! link haskellOperators GruvboxBlue +" +hi! link haskellBacktick GruvboxOrange +hi! link haskellStatement GruvboxOrange +hi! link haskellConditional GruvboxOrange + +hi! link haskellLet GruvboxAqua +hi! link haskellDefault GruvboxAqua +hi! link haskellWhere GruvboxAqua +hi! link haskellBottom GruvboxAqua +hi! link haskellBlockKeywords GruvboxAqua +hi! link haskellImportKeywords GruvboxAqua +hi! link haskellDeclKeyword GruvboxAqua +hi! link haskellDeriving GruvboxAqua +hi! link haskellAssocType GruvboxAqua + +hi! link haskellNumber GruvboxPurple +hi! link haskellPragma GruvboxPurple + +hi! link haskellString GruvboxGreen +hi! link haskellChar GruvboxGreen + +" }}} +" Json: {{{ + +hi! link jsonKeyword GruvboxGreen +hi! link jsonQuote GruvboxGreen +hi! link jsonBraces GruvboxFg1 +hi! link jsonString GruvboxFg1 + +" }}} + + +" Functions ------------------------------------------------------------------- +" Search Highlighting Cursor {{{ + +function! GruvboxHlsShowCursor() + call s:HL('Cursor', s:bg0, s:hls_cursor) +endfunction + +function! GruvboxHlsHideCursor() + call s:HL('Cursor', s:none, s:none, s:inverse) +endfunction + +" }}} + +" vim: set sw=2 ts=2 sts=2 et tw=80 ft=vim fdm=marker: diff --git a/colors/seoul256.vim b/colors/seoul256.vim new file mode 100644 index 00000000..b6c80546 --- /dev/null +++ b/colors/seoul256.vim @@ -0,0 +1,439 @@ +" " _____ _ ___ ___ ___ " +" " | __|___ ___ _ _| |_ | _| _| " +" " |__ | -_| . | | | | _|_ | . | " +" " |_____|___|___|___|_|___|___|___|.vim " +" +" " Low-contrast dark Vim color scheme using Seoul Colors " +" +" File: seoul256.vim +" URL: github.com/junegunn/seoul256.vim +" Author: Junegunn Choi (junegunn.c@gmail.com) +" License: MIT +" +" 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('s:rgb_map') + if get(g:, 'seoul256_srgb', 0) + let s:rgb_map = + \{ 16: '#000000', 17: '#00005f', 18: '#000087', + \ 19: '#0000af', 20: '#0000d7', 21: '#0000ff', + \ 22: '#005f00', 23: '#005f5f', 24: '#005f87', + \ 25: '#005faf', 26: '#005fd7', 27: '#005fff', + \ 28: '#008700', 29: '#00875f', 30: '#008787', + \ 31: '#0087af', 32: '#0087d7', 33: '#0087ff', + \ 34: '#00af00', 35: '#00af5f', 36: '#00af87', + \ 37: '#00afaf', 38: '#00afd7', 39: '#00afff', + \ 40: '#00d700', 41: '#00d75f', 42: '#00d787', + \ 43: '#00d7af', 44: '#00d7d7', 45: '#00d7ff', + \ 46: '#00ff00', 47: '#00ff5f', 48: '#00ff87', + \ 49: '#00ffaf', 50: '#00ffd7', 51: '#00ffff', + \ 52: '#5f0000', 53: '#5f005f', 54: '#5f0087', + \ 55: '#5f00af', 56: '#5f00d7', 57: '#5f00ff', + \ 58: '#5f5f00', 59: '#5f5f5f', 60: '#5f5f87', + \ 61: '#5f5faf', 62: '#5f5fd7', 63: '#5f5fff', + \ 64: '#5f8700', 65: '#5f875f', 66: '#5f8787', + \ 67: '#5f87af', 68: '#5f87d7', 69: '#5f87ff', + \ 70: '#5faf00', 71: '#5faf5f', 72: '#5faf87', + \ 73: '#5fafaf', 74: '#5fafd7', 75: '#5fafff', + \ 76: '#5fd700', 77: '#5fd75f', 78: '#5fd787', + \ 79: '#5fd7af', 80: '#5fd7d7', 81: '#5fd7ff', + \ 82: '#5fff00', 83: '#5fff5f', 84: '#5fff87', + \ 85: '#5fffaf', 86: '#5fffd7', 87: '#5fffff', + \ 88: '#870000', 89: '#87005f', 90: '#870087', + \ 91: '#8700af', 92: '#8700d7', 93: '#8700ff', + \ 94: '#875f00', 95: '#875f5f', 96: '#875f87', + \ 97: '#875faf', 98: '#875fd7', 99: '#875fff', + \ 100: '#878700', 101: '#87875f', 102: '#878787', + \ 103: '#8787af', 104: '#8787d7', 105: '#8787ff', + \ 106: '#87af00', 107: '#87af5f', 108: '#87af87', + \ 109: '#87afaf', 110: '#87afd7', 111: '#87afff', + \ 112: '#87d700', 113: '#87d75f', 114: '#87d787', + \ 115: '#87d7af', 116: '#87d7d7', 117: '#87d7ff', + \ 118: '#87ff00', 119: '#87ff5f', 120: '#87ff87', + \ 121: '#87ffaf', 122: '#87ffd7', 123: '#87ffff', + \ 124: '#af0000', 125: '#af005f', 126: '#af0087', + \ 127: '#af00af', 128: '#af00d7', 129: '#af00ff', + \ 130: '#af5f00', 131: '#af5f5f', 132: '#af5f87', + \ 133: '#af5faf', 134: '#af5fd7', 135: '#af5fff', + \ 136: '#af8700', 137: '#af875f', 138: '#af8787', + \ 139: '#af87af', 140: '#af87d7', 141: '#af87ff', + \ 142: '#afaf00', 143: '#afaf5f', 144: '#afaf87', + \ 145: '#afafaf', 146: '#afafd7', 147: '#afafff', + \ 148: '#afd700', 149: '#afd75f', 150: '#afd787', + \ 151: '#afd7af', 152: '#afd7d7', 153: '#afd7ff', + \ 154: '#afff00', 155: '#afff5f', 156: '#afff87', + \ 157: '#afffaf', 158: '#afffd7', 159: '#afffff', + \ 160: '#d70000', 161: '#d7005f', 162: '#d70087', + \ 163: '#d700af', 164: '#d700d7', 165: '#d700ff', + \ 166: '#d75f00', 167: '#d75f5f', 168: '#d75f87', + \ 169: '#d75faf', 170: '#d75fd7', 171: '#d75fff', + \ 172: '#d78700', 173: '#d7875f', 174: '#d78787', + \ 175: '#d787af', 176: '#d787d7', 177: '#d787ff', + \ 178: '#d7af00', 179: '#d7af5f', 180: '#d7af87', + \ 181: '#d7afaf', 182: '#d7afd7', 183: '#d7afff', + \ 184: '#d7d700', 185: '#d7d75f', 186: '#d7d787', + \ 187: '#d7d7af', 188: '#d7d7d7', 189: '#d7d7ff', + \ 190: '#d7ff00', 191: '#d7ff5f', 192: '#d7ff87', + \ 193: '#d7ffaf', 194: '#d7ffd7', 195: '#d7ffff', + \ 196: '#ff0000', 197: '#ff005f', 198: '#ff0087', + \ 199: '#ff00af', 200: '#ff00d7', 201: '#ff00ff', + \ 202: '#ff5f00', 203: '#ff5f5f', 204: '#ff5f87', + \ 205: '#ff5faf', 206: '#ff5fd7', 207: '#ff5fff', + \ 208: '#ff8700', 209: '#ff875f', 210: '#ff8787', + \ 211: '#ff87af', 212: '#ff87d7', 213: '#ff87ff', + \ 214: '#ffaf00', 215: '#ffaf5f', 216: '#ffaf87', + \ 217: '#ffafaf', 218: '#ffafd7', 219: '#ffafff', + \ 220: '#ffd700', 221: '#ffd75f', 222: '#ffd787', + \ 223: '#ffd7af', 224: '#ffd7d7', 225: '#ffd7ff', + \ 226: '#ffff00', 227: '#ffff5f', 228: '#ffff87', + \ 229: '#ffffaf', 230: '#ffffd7', 231: '#ffffff', + \ 232: '#080808', 233: '#121212', 234: '#1c1c1c', + \ 235: '#262626', 236: '#303030', 237: '#3a3a3a', + \ 238: '#444444', 239: '#4e4e4e', 240: '#585858', + \ 241: '#626262', 242: '#6c6c6c', 243: '#767676', + \ 244: '#808080', 245: '#8a8a8a', 246: '#949494', + \ 247: '#9e9e9e', 248: '#a8a8a8', 249: '#b2b2b2', + \ 250: '#bcbcbc', 251: '#c6c6c6', 252: '#d0d0d0', + \ 253: '#dadada', 254: '#e4e4e4', 255: '#eeeeee' } + else + let s:rgb_map = + \{ 22: '#006F00', 23: '#007173', 24: '#007299', 25: '#0074BE', 30: '#009799', + \ 31: '#0099BD', 38: '#00BDDF', 52: '#730B00', 58: '#727100', 59: '#727272', + \ 65: '#719872', 66: '#719899', 67: '#7299BC', 68: '#719CDF', 73: '#6FBCBD', + \ 74: '#70BDDF', 88: '#9B1300', 89: '#9B1D72', 94: '#9A7200', 95: '#9A7372', + \ 96: '#9A7599', 101: '#999872', 103: '#999ABD', 108: '#98BC99', 109: '#98BCBD', + \ 110: '#98BEDE', 116: '#97DDDF', 125: '#BF2172', 131: '#BE7572', 137: '#BE9873', + \ 143: '#BDBB72', 144: '#BDBC98', 145: '#BDBDBD', 151: '#BCDDBD', 152: '#BCDEDE', + \ 153: '#BCE0FF', 161: '#E12672', 168: '#E17899', 173: '#E19972', 174: '#E09B99', + \ 179: '#DFBC72', 181: '#E0BEBC', 184: '#DEDC00', 186: '#DEDD99', 187: '#DFDEBD', + \ 189: '#DFDFFF', 216: '#FFBD98', 217: '#FFBFBD', 218: '#FFC0DE', 220: '#FFDD00', + \ 222: '#FFDE99', 224: '#FFDFDF', 230: '#FFFFDF', 231: '#FFFFFF', 232: '#060606', + \ 233: '#171717', 234: '#252525', 235: '#333233', 236: '#3F3F3F', 237: '#4B4B4B', + \ 238: '#565656', 239: '#616161', 240: '#6B6B6B', 241: '#757575', 249: '#BFBFBF', + \ 250: '#C8C8C8', 251: '#D1D0D1', 252: '#D9D9D9', 253: '#E1E1E1', 254: '#E9E9E9', + \ 255: '#F1F1F1' } + endif +endif + +let s:background = &background +let s:colors_name = get(g:, 'colors_name', '') + +silent! unlet s:style s:seoul256_background + +" 1. If g:seoul256_background is found +if exists('g:seoul256_background') + let s:seoul256_background = g:seoul256_background + if s:seoul256_background >= 233 && s:seoul256_background <= 239 + let s:style = 'dark' + elseif s:seoul256_background >= 252 && s:seoul256_background <= 256 + let s:style = 'light' + else + unlet s:seoul256_background + endif +endif + +if !exists('s:style') + " 2. If g:colors_name is NOT 'seoul256' -> dark version + if s:colors_name != 'seoul256' + let s:style = 'dark' + " 3. Follow &background setting + else + let s:style = &background + endif +endif +let s:style_idx = s:style == 'light' + +" Background colors +if s:style == 'dark' + let s:dark_bg = get(s:, 'seoul256_background', 237) + let s:light_bg = 253 +else + let s:dark_bg = 237 + let s:light_bg = get(s:, 'seoul256_background', 253) +endif +let s:dark_bg_2 = s:dark_bg > 233 ? s:dark_bg - 2 : 16 +let s:light_bg_1 = min([s:light_bg + 1, 256]) +let s:light_bg_2 = min([s:light_bg + 2, 256]) + +" Foreground colors +let s:dark_fg = 252 +let s:light_fg = 239 + +function! s:hi(item, fg, bg) + let fg = a:fg[s:style_idx] > 255 ? 231 : a:fg[s:style_idx] + let bg = a:bg[s:style_idx] > 255 ? 231 : a:bg[s:style_idx] + + if !empty(fg) + execute printf("highlight %s ctermfg=%s guifg=%s", a:item, fg, get(s:rgb_map, fg, 'NONE')) + endif + if !empty(bg) + execute printf("highlight %s ctermbg=%s guibg=%s", a:item, bg, get(s:rgb_map, bg, 'NONE')) + endif +endfunction + +let s:gui = has('gui_running') +if !s:gui + set t_Co=256 +end + +silent! unlet g:colors_name +hi clear +if exists("syntax_on") + syntax reset +endif + +call s:hi('Normal', [s:dark_fg, s:light_fg], [s:dark_bg, s:light_bg]) + +call s:hi('LineNr', [101, 101], [s:dark_bg + 1, s:light_bg - 2]) +call s:hi('Visual', ['', ''], [23, 152]) +call s:hi('VisualNOS', ['', ''], [23, 152]) + +call s:hi('Comment', [65, 65], ['', '']) +call s:hi('Number', [222, 95], ['', '']) +call s:hi('Float', [222, 95], ['', '']) +call s:hi('Boolean', [103, 168], ['', '']) +call s:hi('String', [109, 30], ['', '']) +call s:hi('Constant', [73, 23], ['', '']) +call s:hi('Character', [174, 168], ['', '']) +call s:hi('Delimiter', [137, 94], ['', '']) +call s:hi('StringDelimiter', [137, 94], ['', '']) +call s:hi('Statement', [108, 66], ['', '']) +" case, default, etc. +" hi Label ctermfg= + +" if else end +call s:hi('Conditional', [110, 31], ['', '']) + +" while end +call s:hi('Repeat', [68, 67], ['', '']) +call s:hi('Todo', [161, 125], [s:dark_bg_2, s:light_bg_2]) +call s:hi('Function', [187, 58], ['', '']) + +" Macros +call s:hi('Define', [173, 131], ['', '']) +call s:hi('Macro', [173, 131], ['', '']) +call s:hi('Include', [173, 131], ['', '']) +call s:hi('PreCondit', [173, 131], ['', '']) + + +" #! +call s:hi('PreProc', [143, 58], ['', '']) + +" @abc +call s:hi('Identifier', [217, 96], ['', '']) + +" AAA Abc +call s:hi('Type', [179, 94], ['', '']) + +" + - * / << +call s:hi('Operator', [186, 131], ['', '']) + +" super yield +call s:hi('Keyword', [168, 168], ['', '']) + +" raise +call s:hi('Exception', [161, 161], ['', '']) +" +" hi StorageClass ctermfg= +call s:hi('Structure', [116, 23], ['', '']) +" hi Typedef ctermfg= + +call s:hi('Error', [s:dark_fg, s:light_bg_1], [52, 174]) +call s:hi('ErrorMsg', [s:dark_fg, s:light_bg_1], [52, 168]) +call s:hi('Underlined', [181, 168], ['', '']) + +" set textwidth=80 +" set colorcolumn=+1 +call s:hi('ColorColumn', ['', ''], [s:dark_bg - 1, s:light_bg - 2]) + +" GVIM only +" hi Cursor ctermfg= +" hi CursorIM ctermfg= + +" set cursorline cursorcolumn +call s:hi('CursorLine', ['', ''], [s:dark_bg - 1, s:light_bg - 1]) +call s:hi('CursorLineNr', [131, 131], [s:dark_bg - 1, s:light_bg - 1]) +call s:hi('CursorColumn', ['', ''], [s:dark_bg - 1, s:light_bg - 1]) + +call s:hi('Directory', [187, 95], ['', '']) + +call s:hi('DiffAdd', ['NONE', 'NONE'], [22, 151]) +call s:hi('DiffDelete', ['NONE', 'NONE'], [95, 181]) +call s:hi('DiffChange', ['NONE', 'NONE'], [s:dark_bg + 3, 189]) +call s:hi('DiffText', ['NONE', 'NONE'], [52, 224]) + +call s:hi('VertSplit', [s:dark_bg_2, s:light_bg - 3], [s:dark_bg_2, s:light_bg - 3]) +call s:hi('Folded', [101, 101], [s:dark_bg + 1, s:light_bg - 2]) + +" set foldcolumn=1 +call s:hi('FoldColumn', [144, 94], [s:dark_bg + 1, s:light_bg - 2]) + +call s:hi('MatchParen', ['', ''], [s:dark_bg + 3, s:light_bg - 3]) + +" -- INSERT -- +call s:hi('ModeMsg', [173, 173], ['', '']) + +" let &showbreak = '> ' +call s:hi('NonText', [59, 145], ['', '']) + +call s:hi('MoreMsg', [173, 173], ['', '']) + +" Popup menu +call s:hi('Pmenu', [s:dark_bg + 1, 238], [224, 224]) +call s:hi('PmenuSel', [s:dark_fg, s:dark_fg], [89, 89]) +call s:hi('PmenuSbar', ['', ''], [65, 65]) +call s:hi('PmenuThumb', ['', ''], [23, 23]) + +call s:hi('Search', [s:dark_fg, 255], [24, 74]) +call s:hi('IncSearch', [220, 220], [s:dark_bg + 1, 238]) + +" String delimiter, interpolation +call s:hi('Special', [216, 173], ['', '']) +" hi SpecialChar ctermfg= +" hi SpecialComment ctermfg= +" hi Tag ctermfg= +" hi Debug ctermfg= + +" :map, listchars +call s:hi('SpecialKey', [59, 145], ['', '']) + +if !s:gui + " Red / Blue / Cyan / Magenta + if s:style_idx == 0 + hi SpellBad ctermbg=NONE cterm=underline ctermfg=168 + hi SpellCap ctermbg=NONE cterm=underline ctermfg=110 + hi SpellLocal ctermbg=NONE cterm=underline ctermfg=153 + hi SpellRare ctermbg=NONE cterm=underline ctermfg=218 + else + hi SpellBad ctermbg=NONE cterm=underline ctermfg=125 + hi SpellCap ctermbg=NONE cterm=underline ctermfg=25 + hi SpellLocal ctermbg=NONE cterm=underline ctermfg=31 + hi SpellRare ctermbg=NONE cterm=underline ctermfg=96 + endif +else + if s:style_idx == 0 + execute 'hi SpellBad gui=undercurl guisp=' . s:rgb_map[168] + execute 'hi SpellCap gui=undercurl guisp=' . s:rgb_map[110] + execute 'hi SpellLocal gui=undercurl guisp=' . s:rgb_map[153] + execute 'hi SpellRare gui=undercurl guisp=' . s:rgb_map[218] + else + execute 'hi SpellBad gui=undercurl guisp=' . s:rgb_map[125] + execute 'hi SpellCap gui=undercurl guisp=' . s:rgb_map[25] + execute 'hi SpellLocal gui=undercurl guisp=' . s:rgb_map[31] + execute 'hi SpellRare gui=undercurl guisp=' . s:rgb_map[96] + endif +endif + +" +call s:hi('StatusLine', [95, 95], [187, 187]) +call s:hi('StatusLineNC', [s:dark_bg + 2, s:light_bg - 2], [187, 238]) +call s:hi('StatusLineTerm', [95, 95], [187, 187]) +call s:hi('StatusLineTermNC', [s:dark_bg + 2, s:light_bg - 2], [187, 238]) +hi StatusLineTerm cterm=bold,reverse gui=bold,reverse +hi StatusLineTermNC cterm=bold,reverse gui=bold,reverse +call s:hi('TabLineFill', [s:dark_bg + 2, s:light_bg - 2], ['', '']) +call s:hi('TabLineSel', [187, 187], [23, 66]) +call s:hi('TabLine', [s:dark_bg + 12, s:light_bg - 12], [s:dark_bg + 4, s:light_bg - 4]) +call s:hi('WildMenu', [95, 95], [184, 184]) + +" :set all +call s:hi('Title', [181, 88], ['', '']) + +" TODO +call s:hi('Question', [179, 88], ['', '']) + +" Search hit bottom +call s:hi('WarningMsg', [179, 88], ['', '']) + +" Sign column +call s:hi('SignColumn', [173, 173], [s:dark_bg, s:light_bg]) + +" Diff +call s:hi('diffAdded', [108, 65], ['', '']) +call s:hi('diffRemoved', [174, 131], ['', '']) +hi link diffLine Constant + +call s:hi('Conceal', [s:dark_fg + 2, s:light_fg - 2], [s:dark_bg - 1, s:light_bg + 2]) +call s:hi('Ignore', [s:dark_bg + 3, s:light_bg - 3], [s:dark_bg, s:light_bg]) + +""""""""""""""""""""""""""""""""""""""""""""""""" +" Plugins +""""""""""""""""""""""""""""""""""""""""""""""""" + +" vim-indent-guides +" ----------------- +let g:indent_guides_auto_colors = 0 +call s:hi('IndentGuidesOdd', ['', ''], [s:dark_bg - 1, s:light_bg + 1]) +call s:hi('IndentGuidesEven', ['', ''], [s:dark_bg + 1, s:light_bg - 1]) + +" vim-gitgutter +" ------------- +call s:hi('GitGutterAdd', [108, 65], [s:dark_bg + 1, s:light_bg - 2]) +call s:hi('GitGutterChange', [68, 68], [s:dark_bg + 1, s:light_bg - 2]) +call s:hi('GitGutterDelete', [161, 161], [s:dark_bg + 1, s:light_bg - 2]) +call s:hi('GitGutterChangeDelete', [168, 168], [s:dark_bg + 1, s:light_bg - 2]) + +" ale +" --- +call s:hi('ALEErrorSign', [161, 161], [s:dark_bg, s:light_bg]) +call s:hi('ALEWarningSign', [174, 131], [s:dark_bg, s:light_bg]) + +" vim-signify +" ----------- +call s:hi('SignifySignAdd', [108, 65], [s:dark_bg + 1, s:light_bg - 2]) +call s:hi('SignifySignChange', [68, 68], [s:dark_bg + 1, s:light_bg - 2]) +call s:hi('SignifySignDelete', [161, 161], [s:dark_bg + 1, s:light_bg - 2]) + + +" http://vim.wikia.com/wiki/Highlight_unwanted_spaces +" ---------------------------------------------------^^^^^ +call s:hi('ExtraWhitespace', ['', ''], [s:dark_bg - 1, s:light_bg - 2]) + +" vim-ruby +" -------- +" " rubySymbol +let ruby_operators = 1 +call s:hi('rubyClass', [31, 31], ['', '']) +" call s:hi('rubyInstanceVariable', [189, 189], ['', '']) +call s:hi('rubyRegexp', [186, 101], ['', '']) +call s:hi('rubyRegexpDelimiter', [168, 168], ['', '']) +call s:hi('rubyArrayDelimiter', [67, 38], ['', '']) +call s:hi('rubyBlockParameterList', [186, 94], ['', '']) +call s:hi('rubyCurlyBlockDelimiter', [144, 101], ['', '']) + +" ARGV $stdout +call s:hi('rubyPredefinedIdentifier', [230, 52], ['', '']) +" hi rubyRegexpSpecial + +hi CursorLine cterm=NONE +hi CursorLineNr cterm=NONE + +let g:seoul256_current_fg = [s:dark_fg, s:light_fg][s:style_idx] +let g:seoul256_current_bg = [s:dark_bg, s:light_bg][s:style_idx] +let g:colors_name = 'seoul256' +if s:colors_name != g:colors_name || s:background == s:style + let &background = s:style +else + let &background = s:background +endif diff --git a/colors/tender.vim b/colors/tender.vim deleted file mode 100644 index f37cf0a4..00000000 --- a/colors/tender.vim +++ /dev/null @@ -1,157 +0,0 @@ -" -" tender v0.3.4 -" A tender color scheme for vim and its plugins -" author: Jacobo Tabernero http://jacoborus.codes -" license: MIT -" background: dark -" -" This file was generated by Estilo -" https://github.com/jacoborus/estilo - -let g:colors_name="tender" -hi clear -if exists("syntax_on") - syntax reset -endif -if has("gui_running") - set background=dark -endif - -hi ColorColumn guifg=NONE ctermfg=NONE guibg=#323232 ctermbg=236 gui=NONE cterm=NONE -hi link CursorColumn CursorLine -hi CursorLine guifg=NONE ctermfg=NONE guibg=#323232 ctermbg=236 gui=NONE cterm=NONE -hi CursorLineNr guifg=#66afce ctermfg=74 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi Directory guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi DiffAdd guifg=#eeeeee ctermfg=255 guibg=#818f21 ctermbg=100 gui=NONE cterm=NONE -hi DiffChange guifg=#eeeeee ctermfg=255 guibg=#66afce ctermbg=74 gui=NONE cterm=NONE -hi DiffDelete guifg=#282828 ctermfg=235 guibg=#f43753 ctermbg=203 gui=NONE cterm=NONE -hi DiffText guifg=#66afce ctermfg=74 guibg=#eeeeee ctermbg=255 gui=bold cterm=bold -hi ErrorMsg guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=reverse cterm=reverse -hi VertSplit guifg=#282828 ctermfg=235 guibg=#282828 ctermbg=235 gui=NONE cterm=NONE -hi Folded guifg=#666666 ctermfg=242 guibg=#1d1d1d ctermbg=234 gui=NONE cterm=NONE -hi FoldColumn guifg=#666666 ctermfg=242 guibg=#1d1d1d ctermbg=234 gui=NONE cterm=NONE -hi IncSearch guifg=#282828 ctermfg=235 guibg=#e9edb2 ctermbg=193 gui=NONE cterm=NONE -hi LineNr guifg=#444444 ctermfg=238 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi MatchParen guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=bold cterm=bold -hi NonText guifg=#444444 ctermfg=238 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi Normal guifg=#eeeeee ctermfg=255 guibg=#282828 ctermbg=235 gui=NONE cterm=NONE -hi PMenu guifg=#282828 ctermfg=235 guibg=#66afce ctermbg=74 gui=NONE cterm=NONE -hi PMenuSel guifg=#282828 ctermfg=235 guibg=#b8c468 ctermbg=149 gui=NONE cterm=NONE -hi PmenuSbar guifg=#d1b580 ctermfg=180 guibg=#d1b580 ctermbg=180 gui=NONE cterm=NONE -hi PmenuThumb guifg=#f9b943 ctermfg=215 guibg=#f9b943 ctermbg=215 gui=NONE cterm=NONE -hi Question guifg=#b8c468 ctermfg=149 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi Search guifg=#e9edb2 ctermfg=193 guibg=NONE ctermbg=NONE gui=underline cterm=underline -hi SpecialKey guifg=#66afce ctermfg=74 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi SpellBad guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi SpellLocal guifg=#d1b580 ctermfg=180 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi SpellCap guifg=#f9b943 ctermfg=215 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi SpellRare guifg=#66afce ctermfg=74 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi StatusLine guifg=#282828 ctermfg=235 guibg=#66afce ctermbg=74 gui=bold cterm=bold -hi StatusLineNC guifg=#282828 ctermfg=235 guibg=#666666 ctermbg=242 gui=bold cterm=bold -hi TabLine guifg=#999999 ctermfg=246 guibg=#444444 ctermbg=238 gui=NONE cterm=NONE -hi TabLineFill guifg=NONE ctermfg=NONE guibg=#444444 ctermbg=238 gui=NONE cterm=NONE -hi TabLineSel guifg=#b8c468 ctermfg=149 guibg=NONE ctermbg=NONE gui=bold cterm=bold -hi Title guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=bold cterm=bold -hi Visual guifg=NONE ctermfg=NONE guibg=#0b0b0b ctermbg=232 gui=NONE cterm=NONE -hi WarningMsg guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi WildMenu guifg=#282828 ctermfg=235 guibg=#b8c468 ctermbg=149 gui=bold cterm=bold -hi Comment guifg=#666666 ctermfg=242 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi Constant guifg=#f9b943 ctermfg=215 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi String guifg=#d1b580 ctermfg=180 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi Character guifg=#f9b943 ctermfg=215 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi Boolean guifg=#f9b943 ctermfg=215 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi Number guifg=#f9b943 ctermfg=215 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi Float guifg=#f9b943 ctermfg=215 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi Identifier guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi Function guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi Statement guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi Conditional guifg=#b8c468 ctermfg=149 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi Operator guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi Exception guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi PreProc guifg=#b8c468 ctermfg=149 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi Type guifg=#66afce ctermfg=74 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi Special guifg=#66afce ctermfg=74 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi Error guifg=#eeeeee ctermfg=255 guibg=#f43753 ctermbg=203 gui=NONE cterm=NONE -hi Todo guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=bold cterm=bold -hi cssVendor guifg=#818f21 ctermfg=100 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi cssTagName guifg=#b8c468 ctermfg=149 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi cssAttrComma guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi cssBackgroundProp guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi cssBorderProp guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi cssBoxProp guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi cssDimensionProp guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi cssFontProp guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi cssTextProp guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi cssValueLength guifg=#eeeeee ctermfg=255 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi cssValueInteger guifg=#eeeeee ctermfg=255 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi cssValueNumber guifg=#eeeeee ctermfg=255 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi cssIdentifier guifg=#66afce ctermfg=74 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi cssIncludeKeyword guifg=#f9b943 ctermfg=215 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi cssImportant guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi cssClassName guifg=#b8c468 ctermfg=149 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi cssClassNameDot guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi cssProp guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi cssAttr guifg=#eeeeee ctermfg=255 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi cssUnitDecorators guifg=#eeeeee ctermfg=255 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi cssNoise guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi gitcommitBranch guifg=#66afce ctermfg=74 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi gitcommitDiscardedType guifg=#c12038 ctermfg=125 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi gitcommitSelectedType guifg=#818f21 ctermfg=100 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi gitcommitHeader guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi gitcommitUntrackedFile guifg=#c12038 ctermfg=125 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi gitcommitDiscardedFile guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi gitcommitSelectedFile guifg=#b8c468 ctermfg=149 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi helpHeadline guifg=#66afce ctermfg=74 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi helpNote guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi javaScriptOperator guifg=#b8c468 ctermfg=149 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi javaScriptBraces guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi jsonEscape guifg=#66afce ctermfg=74 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi jsonNumber guifg=#f9b943 ctermfg=215 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi jsonBraces guifg=#eeeeee ctermfg=255 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi jsonBoolean guifg=#f9b943 ctermfg=215 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi jsonKeywordMatch guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi jsonQuote guifg=#eeeeee ctermfg=255 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi jsonNoise guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi markdownH1 guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi markdownHeadingRule guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi markdownHeadingDelimiter guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi markdownListMarker guifg=#f9b943 ctermfg=215 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi markdownBlockquote guifg=#f9b943 ctermfg=215 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi markdownRule guifg=#b8c468 ctermfg=149 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi markdownLinkText guifg=#b8c468 ctermfg=149 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi markdownLinkTextDelimiter guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi markdownLinkDelimiter guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi markdownIdDeclaration guifg=#818f21 ctermfg=100 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi markdownAutomaticLink guifg=#66afce ctermfg=74 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi markdownUrl guifg=#66afce ctermfg=74 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi markdownUrlTitle guifg=#d1b580 ctermfg=180 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi markdownUrlDelimiter guifg=#f9b943 ctermfg=215 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi markdownUrlTitleDelimiter guifg=#9b7425 ctermfg=3 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi markdownCodeDelimiter guifg=#66afce ctermfg=74 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi markdownCode guifg=#d1b580 ctermfg=180 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi markdownEscape guifg=#66afce ctermfg=74 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi markdownError guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi vimCommentTitle guifg=#818f21 ctermfg=100 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi vimError guifg=#eeeeee ctermfg=255 guibg=#f43753 ctermbg=203 gui=NONE cterm=NONE -hi yamlFlowString guifg=#d1b580 ctermfg=180 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi yamlFlowStringDelimiter guifg=#f9b943 ctermfg=215 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi yamlKeyValueDelimiter guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi FugitiveblameHash guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi FugitiveblameUncommitted guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi FugitiveblameTime guifg=#b8c468 ctermfg=149 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi FugitiveblameNotCommittedYet guifg=#d1b580 ctermfg=180 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi NERDTreeHelp guifg=#c9c9c9 ctermfg=251 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi NERDTreeHelpKey guifg=#b8c468 ctermfg=149 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi NERDTreeHelpCommand guifg=#f9b943 ctermfg=215 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi NERDTreeHelpTitle guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi NERDTreeUp guifg=#b8c468 ctermfg=149 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi NERDTreeCWD guifg=#66afce ctermfg=74 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi NERDTreeOpenable guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi NERDTreeClosable guifg=#f9b943 ctermfg=215 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi GitGutterAdd guifg=#b8c468 ctermfg=149 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi GitGutterChange guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi GitGutterDelete guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi GitGutterChangeDelete guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi javaScriptOpSymbols guifg=#f43753 ctermfg=203 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi javaScriptParens guifg=#abd9ec ctermfg=153 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE -hi javaScriptFuncArg guifg=#f9b943 ctermfg=215 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE diff --git a/fonts/DejaVu.ttf b/fonts/DejaVu.ttf new file mode 100644 index 00000000..ade1ab67 Binary files /dev/null and b/fonts/DejaVu.ttf differ diff --git a/fonts/Droid Sans Mono Nerd Font Complete.otf b/fonts/Droid Sans Mono Nerd Font Complete.otf index d733c3d0..4836335d 100644 Binary files a/fonts/Droid Sans Mono Nerd Font Complete.otf and b/fonts/Droid Sans Mono Nerd Font Complete.otf differ diff --git a/help.md b/help.md index 049ae943..1d123efa 100644 --- a/help.md +++ b/help.md @@ -1,51 +1,60 @@ ## 插件相关 -| 快捷键 | 说明 | -| ------- | ----- | -| `,` | Leader Key | -| `n` | 打开/关闭代码资源管理器 | -| `t` | 打开/关闭函数列表 | -| `a` | .h .cpp 文件切换 | -| `u` | 转到函数声明 | -| `U` | 转到函数实现 | -| `u` | 转到变量声明 | -| `o` | 打开include文件 | -| `y` | 拷贝函数声明 | -| `p` | 生成函数实现 | -| `w` | 单词跳转 | -| `f` | 搜索~目录下的文件 | -| `F` | 搜索当前目录下的文本 | -| `g` | 显示git仓库提交记录 | -| `G` | 显示当前文件提交记录 | -| `gg` | 显示当前文件在某个commit下的完整内容 | -| `ff` | 语法错误自动修复(FixIt) | -| `` | 切换到上一个buffer | -| `` | 切换到下一个buffer | -| `d` | 删除当前buffer | -| `D` | 删除当前buffer外的所有buffer | -| `vim` | 运行vim编辑器时,默认启动开始页面 | -| `` | 显示语法错误提示窗口 | -| `` | 启用markdown实时预览 | -| `` | 关闭markdown实时预览 | -| `` | 显示上一主题 | -| `` | 显示下一主题 | -| `l` | 按竖线对齐 | -| `=` | 按等号对齐 | -| `Ya` | 复制行文本到字母a | -| `Da` | 剪切行文本到字母a | -| `Ca` | 改写行文本到字母a | -| `rr` | 替换文本 | -| `r` | 全局替换,目前只支持单个文件 | -| `gcc` | 注释代码 | -| `gcap` | 注释段落 | -| `vif` | 选中函数内容 | -| `dif` | 删除函数内容 | -| `cif` | 改写函数内容 | -| `vaf` | 选中函数内容(包括函数名 花括号) | -| `daf` | 删除函数内容(包括函数名 花括号) | -| `caf` | 改写函数内容(包括函数名 花括号) | -| `fa` | 查找字母a,然后再按f键查找下一个 | -| `` | Emoji:dog:补全 | +| 快捷键 | 说明 | +| ------- | ----- | +| `,` | Leader Key | +| `n` | 打开/关闭代码资源管理器 | +| `t` | 打开/关闭函数列表 | +| `a` | .h .cpp 文件切换 | +| `u` | 转到函数声明 | +| `U` | 转到函数实现 | +| `u` | 转到变量声明 | +| `o` | 打开include文件 | +| `y` | 拷贝函数声明 | +| `p` | 生成函数实现 | +| `w` | 单词跳转 | +| `f` | 搜索当前目录下的文件 | +| `F` | 搜索当前目录下的文本 | +| `g` | 显示git仓库提交记录 | +| `G` | 显示当前文件提交记录 | +| `gg` | 显示当前文件在某个commit下的完整内容 | +| `ff` | 语法错误自动修复(FixIt) | +| `` | 切换到上一个buffer | +| `` | 切换到下一个buffer | +| `d` | 删除当前buffer | +| `D` | 删除当前buffer外的所有buffer | +| `vim` | 运行vim编辑器时,默认启动开始页面 | +| `` | 显示语法错误提示窗口 | +| `` | 显示上一主题 | +| `` | 显示下一主题 | +| `l` | 按竖线对齐 | +| `=` | 按等号对齐 | +| `Ya` | 复制行文本到字母a | +| `Da` | 剪切行文本到字母a | +| `Ca` | 改写行文本到字母a | +| `rr` | 替换文本 | +| `r` | 全局替换,目前只支持单个文件 | +| `rev` | 翻转当前光标下的单词或使用V模式选择的文本 | +| `gcc` | 注释代码 | +| `gcap` | 注释段落 | +| `vif` | 选中函数内容 | +| `dif` | 删除函数内容 | +| `cif` | 改写函数内容 | +| `vaf` | 选中函数内容(包括函数名 花括号) | +| `daf` | 删除函数内容(包括函数名 花括号) | +| `caf` | 改写函数内容(包括函数名 花括号) | +| `fa` | 查找字母a,然后再按f键查找下一个 | +| `e` | 快速编辑~/.vimrc文件 | +| `s` | 重新加载~/.vimrc文件 | +| `vp` | 快速编辑~/.vimrc.custom.plugins文件 | +| `vc` | 快速编辑~/.vimrc.custom.config文件 | +| `h` | 打开vimplus帮助文档 | +| `H` | 打开当前光标所在单词的vim帮助文档 | +| `t` | 生成try-catch代码块 | +| `y` | 复制当前选中到系统剪切板 | +| `i` | 安装插件 | +| `u` | 更新插件 | +| `c` | 删除插件 | ## 插入模式 @@ -210,6 +219,7 @@ | `Y` | 复制当前行,同 yy | | `yt,` | 复制到逗号 | | `yiw` | 复制当前单词 | +| `"+y` | 复制当前选中到系统剪切板 | | `3yy` | 复制光标下三行内容 | | `v0` | 选中当前位置到行首 | | `v$` | 选中当前位置到行末 | @@ -322,14 +332,8 @@ ## 其他 -| 快捷键 | 说明 | -| ------- | ----- | -| `vim -u NONE -N` | 开启vim时不加载vimrc文件 | -| `vimdiff file1 file2` | 显示文件差异 | -| `e` | 快速编辑vimrc文件 | -| `s` | 重新加载vimrc文件 | -| `h` | 打开vimplus帮助文档 | -| `H` | 打开当前光标所在单词的vim帮助文档 | -| `i` | 安装插件 | -| `u` | 更新插件 | -| `c` | 删除插件 | +| 快捷键 | 说明 | +| ------- | ----- | +| `vim -u NONE -N` | 开启vim时不加载vimrc文件 | +| `vimdiff file1 file2` | 显示文件差异 | +| `vim -R filename` | 以只读方式打开(阅读模式) | diff --git a/install.sh b/install.sh index c0bd5600..eb202560 100755 --- a/install.sh +++ b/install.sh @@ -1,10 +1,4 @@ -#!/bin/bash - -# 获取平台类型,mac还是linux平台 -function get_platform_type() -{ - echo $(uname) -} +#!/usr/bin/env bash # 获取linux发行版名称 function get_linux_distro() @@ -13,58 +7,194 @@ function get_linux_distro() echo "Ubuntu" elif grep -Eq "Deepin" /etc/*-release; then echo "Deepin" + elif grep -Eq "Raspbian" /etc/*-release; then + echo "Raspbian" + elif grep -Eq "uos" /etc/*-release; then + echo "UOS" elif grep -Eq "LinuxMint" /etc/*-release; then echo "LinuxMint" elif grep -Eq "elementary" /etc/*-release; then echo "elementaryOS" elif grep -Eq "Debian" /etc/*-release; then echo "Debian" + elif grep -Eq "Kali" /etc/*-release; then + echo "Kali" + elif grep -Eq "Parrot" /etc/*-release; then + echo "Parrot" elif grep -Eq "CentOS" /etc/*-release; then echo "CentOS" + elif grep -Eq "fedora" /etc/*-release; then + echo "fedora" elif grep -Eq "openSUSE" /etc/*-release; then echo "openSUSE" elif grep -Eq "Arch Linux" /etc/*-release; then echo "ArchLinux" elif grep -Eq "ManjaroLinux" /etc/*-release; then echo "ManjaroLinux" + elif grep -Eq "Gentoo" /etc/*-release; then + echo "Gentoo" + elif grep -Eq "alpine" /etc/*-release; then + echo "Alpine" else - echo "Unknow" + echo "Unknown" + fi +} + +# 获取日期 +function get_datetime() +{ + time=$(date "+%Y%m%d%H%M%S") + echo $time +} + +# 判断文件是否存在 +function is_exist_file() +{ + filename=$1 + if [ -f $filename ]; then + echo 1 + else + echo 0 + fi +} + +# 判断目录是否存在 +function is_exist_dir() +{ + dir=$1 + if [ -d $dir ]; then + echo 1 + else + echo 0 + fi +} + +#备份原有的.vimrc文件 +function backup_vimrc_file() +{ + old_vimrc=$HOME"/.vimrc" + is_exist=$(is_exist_file $old_vimrc) + if [ $is_exist == 1 ]; then + time=$(get_datetime) + backup_vimrc=$old_vimrc"_bak_"$time + read -p "Find "$old_vimrc" already exists,backup "$old_vimrc" to "$backup_vimrc"? [Y/N] " ch + if [[ $ch == "Y" ]] || [[ $ch == "y" ]]; then + cp $old_vimrc $backup_vimrc + fi + fi +} + +#备份原有的.vimrc.custom.plugins文件 +function backup_vimrc_custom_plugins_file() +{ + old_vimrc_plugins=$HOME"/.vimrc.custom.plugins" + is_exist=$(is_exist_file $old_vimrc_plugins) + if [ $is_exist == 1 ]; then + time=$(get_datetime) + backup_vimrc_plugins=$old_vimrc_plugins"_bak_"$time + read -p "Find "$old_vimrc_plugins" already exists,backup "$old_vimrc_plugins" to "$backup_vimrc_plugins"? [Y/N] " ch + if [[ $ch == "Y" ]] || [[ $ch == "y" ]]; then + cp $old_vimrc_plugins $backup_vimrc_plugins + fi + fi +} + +#备份原有的.vimrc.custom.config文件 +function backup_vimrc_custom_config_file() +{ + old_vimrc_config=$HOME"/.vimrc.custom.config" + is_exist=$(is_exist_file $old_vimrc_config) + if [ $is_exist == 1 ]; then + time=$(get_datetime) + backup_vimrc_config=$old_vimrc_config"_bak_"$time + read -p "Find "$old_vimrc_config" already exists,backup "$old_vimrc_config" to "$backup_vimrc_config"? [Y/N] " ch + if [[ $ch == "Y" ]] || [[ $ch == "y" ]]; then + cp $old_vimrc_config $backup_vimrc_config + fi fi } -# 判断是否是ubuntu14.04LTS版本 -function is_ubuntu1404() +#备份原有的.vim目录 +function backup_vim_dir() +{ + old_vim=$HOME"/.vim" + is_exist=$(is_exist_dir $old_vim) + if [ $is_exist == 1 ]; then + time=$(get_datetime) + backup_vim=$old_vim"_bak_"$time + read -p "Find "$old_vim" already exists,backup "$old_vim" to "$backup_vim"? [Y/N] " ch + if [[ $ch == "Y" ]] || [[ $ch == "y" ]]; then + cp -R $old_vim $backup_vim + fi + fi +} + +# 备份原有的.vimrc和.vim +function backup_vimrc_and_vim() +{ + backup_vimrc_file + backup_vimrc_custom_plugins_file + backup_vimrc_custom_config_file + backup_vim_dir +} + +# 获取ubuntu版本 +function get_ubuntu_version() +{ + line=$(cat /etc/lsb-release | grep "DISTRIB_RELEASE") + arr=(${line//=/ }) + version=(${arr[1]//./ }) + + echo ${version[0]} +} + +# 获取alpine版本 +function get_alpine_version() +{ + version=$(cat /etc/os-release | grep 'VERSION_ID' | awk -F '=' '{print $2}') + + echo $version +} + +# 获取centos版本 +function get_centos_version() { - version=$(cat /etc/lsb-release | grep "DISTRIB_RELEASE") - if [ ${version} == "DISTRIB_RELEASE=14.04" ]; then + version=`cat /etc/redhat-release | awk '{print $4}' | awk -F . '{printf "%s",$1}'` + echo $version +} + +# 判断是否是macos10.14版本 +function is_macos1014() +{ + product_version=$(sw_vers | grep ProductVersion) + if [[ $product_version =~ "10.14" ]]; then echo 1 else echo 0 fi } +# 在alpine上直装vim8.2 +# function compile_vim_on_alpine() +# { +# apk --upgrade add vim +# cd - +# } + # 在ubuntu上源代码安装vim function compile_vim_on_ubuntu() { - sudo apt-get remove -y vim vim-runtime gvim - sudo apt-get remove -y vim-tiny vim-common vim-gui-common vim-nox - sudo rm -rf /usr/bin/vim* - sudo rm -rf /usr/local/bin/vim* - sudo rm -rf /usr/share/vim/vim* - sudo rm -rf /usr/local/share/vim/vim* - rm -rf ~/vim81 - sudo apt-get install -y libncurses5-dev libncurses5 libgnome2-dev libgnomeui-dev \ libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \ libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev python3-dev ruby-dev lua5.1 lua5.1-dev - git clone https://gitee.com/chxuan/vim81.git ~/vim81 - cd ~/vim81 + rm -rf ~/vim82 + git clone https://gitee.com/chxuan/vim82.git ~/vim82 + cd ~/vim82 ./configure --with-features=huge \ --enable-multibyte \ --enable-rubyinterp \ --enable-pythoninterp \ - --with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu \ --enable-perlinterp \ --enable-luainterp \ --enable-gui=gtk2 \ @@ -78,23 +208,37 @@ function compile_vim_on_ubuntu() # 在debian上源代码安装vim function compile_vim_on_debian() { - sudo apt-get remove -y vim vim-runtime gvim - sudo apt-get remove -y vim-tiny vim-common vim-gui-common vim-nox - sudo rm -rf /usr/bin/vim* - sudo rm -rf /usr/local/bin/vim* - sudo rm -rf /usr/share/vim/vim* - sudo rm -rf /usr/local/share/vim/vim* - rm -rf ~/vim81 - sudo apt-get install -y libncurses5-dev libncurses5 libgtk2.0-dev libatk1.0-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev python3-dev ruby-dev lua5.1 lua5.1-dev - git clone https://gitee.com/chxuan/vim81.git ~/vim81 - cd ~/vim81 + rm -rf ~/vim82 + git clone https://gitee.com/chxuan/vim82.git ~/vim82 + cd ~/vim82 + ./configure --with-features=huge \ + --enable-multibyte \ + --enable-rubyinterp \ + --enable-pythoninterp \ + --enable-perlinterp \ + --enable-luainterp \ + --enable-gui=gtk2 \ + --enable-cscope \ + --prefix=/usr + make + sudo make install + cd - +} + +# 在parrot上源代码安装vim +function compile_vim_on_parrot() +{ + sudo apt-get install -y libncurses5-dev libncurses5 libgtk2.0-dev libatk1.0-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev python3-dev ruby-dev lua5.1 vim + + rm -rf ~/vim82 + git clone https://gitee.com/chxuan/vim82.git ~/vim82 + cd ~/vim82 ./configure --with-features=huge \ --enable-multibyte \ --enable-rubyinterp \ --enable-pythoninterp \ - --with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu \ --enable-perlinterp \ --enable-luainterp \ --enable-gui=gtk2 \ @@ -108,13 +252,6 @@ function compile_vim_on_debian() # 在centos上源代码安装vim function compile_vim_on_centos() { - sudo rm -rf /usr/bin/vi - sudo rm -rf /usr/bin/vim* - sudo rm -rf /usr/local/bin/vim* - sudo rm -rf /usr/share/vim/vim* - sudo rm -rf /usr/local/share/vim/vim* - rm -rf ~/vim81 - sudo yum install -y ruby ruby-devel lua lua-devel luajit \ luajit-devel ctags git python python-devel \ python34 python34-devel tcl-devel \ @@ -122,14 +259,14 @@ function compile_vim_on_centos() perl-ExtUtils-XSpp perl-ExtUtils-CBuilder \ perl-ExtUtils-Embed libX11-devel ncurses-devel - git clone https://gitee.com/chxuan/vim81.git ~/vim81 - cd ~/vim81 + rm -rf ~/vim82 + git clone https://gitee.com/chxuan/vim82.git ~/vim82 + cd ~/vim82 ./configure --with-features=huge \ --enable-multibyte \ --with-tlib=tinfo \ --enable-rubyinterp=yes \ --enable-pythoninterp=yes \ - --with-python-config-dir=/lib64/python2.7/config \ --enable-perlinterp=yes \ --enable-luainterp=yes \ --enable-gui=gtk2 \ @@ -140,54 +277,150 @@ function compile_vim_on_centos() cd - } -# 安装mac平台必要软件 +# 安装mac平台必备软件 function install_prepare_software_on_mac() { - brew install vim gcc cmake ctags-exuberant curl ack + xcode-select --install + + brew install vim gcc cmake ctags-exuberant ack + + macos1014=$(is_macos1014) + if [ $macos1014 == 1 ]; then + open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg + fi +} + +# 安装FreeBSD必备软件 +function install_prepare_software_on_freebsd() +{ + sudo pkg install -y vim ctags automake gcc cmake p5-ack python git fontconfig +} + +# 安装android平台必备软件 +function install_prepare_software_on_android() +{ + pkg update + pkg install -y git vim-python cmake python2 python ctags ack-grep ncurses-utils +} + +# 安装alpine必备软件 需要更换源 +function install_prepare_software_on_alpine() +{ + sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories + + version=$(get_alpine_version) + + apk update + + apk add python3 python3-dev ruby ruby-dev lua lua-dev luajit luajit-dev ctags tcl tcl-dev perl perl-dev libx11 libx11-dev ncurses ncurses-dev g++ gcc make automake cmake fontconfig fontconfig-dev nerd-fonts gcompat clang clang-dev vim } -# 安装ubuntu必要软件 +# 安装ubuntu必备软件 function install_prepare_software_on_ubuntu() { sudo apt-get update - ubuntu1404=`is_ubuntu1404` - if [ ${ubuntu1404} == 1 ]; then + version=$(get_ubuntu_version) + if [ $version -eq 14 ];then sudo apt-get install -y cmake3 else sudo apt-get install -y cmake fi - sudo apt-get install -y exuberant-ctags build-essential python python-dev python3-dev fontconfig curl libfile-next-perl ack-grep git + sudo apt-get install -y build-essential python python-dev python3-dev fontconfig libfile-next-perl ack-grep git + sudo apt-get install -y universal-ctags || sudo apt-get install -y exuberant-ctags + + if [ $version -ge 18 ];then + sudo apt-get install -y vim + else + compile_vim_on_ubuntu + fi +} + +# 安装ubuntu系必备软件 +function install_prepare_software_on_ubuntu_like() +{ + sudo apt-get update + sudo apt-get install -y cmake build-essential python python-dev python3-dev fontconfig libfile-next-perl ack-grep git + sudo apt-get install -y universal-ctags || sudo apt-get install -y exuberant-ctags compile_vim_on_ubuntu } -# 安装debian必要软件 +# 安装debian必备软件 function install_prepare_software_on_debian() { sudo apt-get update - sudo apt-get install -y cmake exuberant-ctags build-essential python python-dev python3-dev fontconfig curl libfile-next-perl ack git + sudo apt-get install -y cmake build-essential python python-dev python3-dev fontconfig libfile-next-perl ack git + sudo apt-get install -y universal-ctags || sudo apt-get install -y exuberant-ctags compile_vim_on_debian } -# 安装centos必要软件 +# 安装parrot必备软件 +function install_prepare_software_on_parrot() +{ + sudo apt-get update + sudo apt-get install -y cmake exuberant-ctags build-essential python python-dev python3-dev fontconfig libfile-next-perl ack git + compile_vim_on_parrot +} + +# 安装centos必备软件 function install_prepare_software_on_centos() { - sudo yum install -y ctags automake gcc gcc-c++ kernel-devel cmake python-devel python3-devel curl fontconfig ack git - compile_vim_on_centos + version=$(get_centos_version) + if [ $version -ge 8 ];then + sudo dnf install -y epel-release + sudo dnf install -y vim ctags automake gcc gcc-c++ kernel-devel make cmake python2 python2-devel python3-devel fontconfig ack git + else + sudo yum install -y ctags automake gcc gcc-c++ kernel-devel cmake python-devel python3-devel fontconfig ack git + compile_vim_on_centos + fi +} + +# 安装fedora必备软件 +function install_prepare_software_on_fedora() +{ + sudo dnf install -y vim ctags automake gcc gcc-c++ kernel-devel cmake python-devel python3-devel fontconfig ack git } -# 安装archlinux必要软件 +# 安装archlinux必备软件 function install_prepare_software_on_archlinux() { - sudo pacman -S --noconfirm vim ctags automake gcc cmake python3 python2 curl ack git fontconfig + sudo pacman -S --noconfirm vim ctags automake gcc cmake python3 python2 ack git fontconfig sudo ln -s /usr/lib/libtinfo.so.6 /usr/lib/libtinfo.so.5 } -# 安装opensuse必要软件 +# 安装gentoo必备软件 +function install_prepare_software_on_gentoo() +{ + install_software_on_gentoo app-editors/vim dev-util/ctags sys-devel/automake sys-devel/gcc dev-util/cmake sys-apps/ack dev-vcs/git media-libs/fontconfig + su - -c "ln -s /usr/lib/libtinfo.so.6 /usr/lib/libtinfo.so.5" -s /bin/bash +} + +function install_software_on_gentoo() +{ + pkgs=$* + pkg_need_install="" + for pkg in ${pkgs} + do + if qlist -I | grep -Eq $pkg; then + echo "$pkg is already installed." + else + pkg_need_install="$pkg_need_install $pkg" + fi + done + + if sudo -l | grep -Eq "emerge"; then + sudo emerge -v $pkg_need_install + else + echo "Need Root password:" + su - -c "emerge -v $pkg_need_install" -s /bin/bash + fi +} + +# 安装opensuse必备软件 function install_prepare_software_on_opensuse() { - sudo zypper install -y vim ctags gcc gcc-c++ cmake python-devel python3-devel curl ack fontconfig git ncurses5-devel + sudo zypper install -y vim ctags gcc gcc-c++ cmake python-devel python3-devel ack fontconfig git ncurses5-devel } # 拷贝文件 @@ -196,8 +429,11 @@ function copy_files() rm -rf ~/.vimrc ln -s ${PWD}/.vimrc ~ - rm -rf ~/.vimrc.local - cp ${PWD}/.vimrc.local ~ + rm -rf ~/.vimrc.custom.plugins + cp ${PWD}/.vimrc.custom.plugins ~ + + rm -rf ~/.vimrc.custom.config + cp ${PWD}/.vimrc.custom.config ~ rm -rf ~/.ycm_extra_conf.py ln -s ${PWD}/.ycm_extra_conf.py ~ @@ -208,6 +444,9 @@ function copy_files() rm -rf ~/.vim/ftplugin ln -s ${PWD}/ftplugin ~/.vim + + rm -rf ~/.vim/autoload + ln -s ${PWD}/autoload ~/.vim } # 安装mac平台字体 @@ -217,20 +456,26 @@ function install_fonts_on_mac() cp ./fonts/Droid\ Sans\ Mono\ Nerd\ Font\ Complete.otf ~/Library/Fonts } -# 安装linux平台字体 -function install_fonts_on_linux() +# 安装android平台字体 +function install_fonts_on_android() { - mkdir ~/.fonts - rm -rf ~/.fonts/Droid\ Sans\ Mono\ Nerd\ Font\ Complete.otf - cp ./fonts/Droid\ Sans\ Mono\ Nerd\ Font\ Complete.otf ~/.fonts + rm -rf ~/.termux/font.ttf + mkdir ~/.termux + cp ./fonts/DejaVu.ttf ~/.termux/font.ttf - fc-cache -vf ~/.fonts + # 刷新style + REL="am broadcast --user 0 -a com.termux.app.reload_style com.termux" + $REL > /dev/null } -# 下载插件管理软件vim-plug -function download_vim_plug() +# 安装linux平台字体 +function install_fonts_on_linux() { - curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + mkdir -p ~/.local/share/fonts + rm -rf ~/.local/share/fonts/Droid\ Sans\ Mono\ Nerd\ Font\ Complete.otf + cp ./fonts/Droid\ Sans\ Mono\ Nerd\ Font\ Complete.otf ~/.local/share/fonts + + fc-cache -vf ~/.local/share/fonts } # 安装vim插件 @@ -239,44 +484,71 @@ function install_vim_plugin() vim -c "PlugInstall" -c "q" -c "q" } -# 在linux上安装ycm插件 -function install_ycm_on_linux() +# 安装ycm插件 +function install_ycm() { - git clone https://gitee.com/chxuan/YouCompleteMe_linux_with_clang.git ~/.vim/plugged/YouCompleteMe + git clone https://gitee.com/chxuan/YouCompleteMe-clang.git ~/.vim/plugged/YouCompleteMe cd ~/.vim/plugged/YouCompleteMe - ./install.py --clang-completer + distro=`get_linux_distro` + read -p "Please choose to compile ycm with python2 or python3, if there is a problem with the current selection, please choose another one. [2/3] " version + if [[ $version == "2" ]]; then + echo "Compile ycm with python2." + # alpine 忽略 --clang-completer 并将 let g:ycm_clangd_binary_path 注入 .vimrc + { + if [ ${distro} == "Alpine" ]; then + echo "##########################################" + echo "Apline Build, need without GLIBC." + echo "##########################################" + sed -i "273ilet g:ycm_clangd_binary_path='/usr/bin/clang'" ~/.vimrc + python2.7 ./install.py + return + fi + } || { + python2.7 ./install.py --clang-completer + } || { + echo "##########################################" + echo "Build error, trying rebuild without Clang." + echo "##########################################" + python2.7 ./install.py + } + else + echo "Compile ycm with python3." + { + # alpine 跳过该步骤 + if [ ${distro} == "Alpine" ]; then + echo "##########################################" + echo "Apline Build, need without GLIBC." + echo "##########################################" + sed -i "273ilet g:ycm_clangd_binary_path='/usr/bin/clang'" ~/.vimrc + python3 ./install.py + return + fi + } || { + python3 ./install.py --clang-completer + } || { + echo "##########################################" + echo "Build error, trying rebuild without Clang." + echo "##########################################" + python3 ./install.py + } + fi } -# macos编译ycm, 原始方法 -function compile_ycm_on_mac_legacy() +# 在android上安装ycm插件 +function install_ycm_on_android() { - cd ~/.vim/plugged/YouCompleteMe - ./install.py --clang-completer --system-libclang -} + git clone https://gitee.com/chxuan/YouCompleteMe-clang.git ~/.vim/plugged/YouCompleteMe -# macos编译ycm, Mojave上的方法 -function compile_ycm_on_mac_mojave() -{ - echo "Installing macOS_10.14 sdk headers..." - xcode-select --install - open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg cd ~/.vim/plugged/YouCompleteMe - ./install.py --clang-completer -} - -# 在MacOS上安装ycm插件 -function install_ycm_on_mac() -{ - git clone https://gitee.com/chxuan/YouCompleteMe.git ~/.vim/plugged/YouCompleteMe - product_version=$(sw_vers | grep ProductVersion) - version=${product_version#*:} - main_version=${version%.*} - if [ ${main_version} == "10.14" ]; then - compile_ycm_on_mac_mojave + read -p "Please choose to compile ycm with python2 or python3, if there is a problem with the current selection, please choose another one. [2/3] " version + if [[ $version == "2" ]]; then + echo "Compile ycm with python2." + python2.7 ./install.py --clang-completer --system-libclang else - compile_ycm_on_mac_legacy + echo "Compile ycm with python3." + python3 ./install.py --clang-completer --system-libclang fi } @@ -303,11 +575,31 @@ function print_logo() # 在mac平台安装vimplus function install_vimplus_on_mac() { + backup_vimrc_and_vim install_prepare_software_on_mac copy_files install_fonts_on_mac - install_ycm_on_mac - download_vim_plug + install_ycm + install_vim_plugin + print_logo +} + +# 在FreeBSD上安装vimplus +function install_vimplus_on_freebsd() +{ + backup_vimrc_and_vim + install_prepare_software_on_freebsd + begin_install_vimplus +} + +# 在android平台安装vimplus +function install_vimplus_on_android() +{ + backup_vimrc_and_vim + install_prepare_software_on_android + copy_files + install_fonts_on_android + install_ycm_on_android install_vim_plugin print_logo } @@ -317,8 +609,7 @@ function begin_install_vimplus() { copy_files install_fonts_on_linux - install_ycm_on_linux - download_vim_plug + install_ycm install_vim_plugin print_logo } @@ -326,38 +617,86 @@ function begin_install_vimplus() # 在ubuntu上安装vimplus function install_vimplus_on_ubuntu() { + backup_vimrc_and_vim install_prepare_software_on_ubuntu begin_install_vimplus } +# 在ubuntu系上安装vimplus +function install_vimplus_on_ubuntu_like() +{ + backup_vimrc_and_vim + install_prepare_software_on_ubuntu_like + begin_install_vimplus +} + # 在debian上安装vimplus function install_vimplus_on_debian() { + backup_vimrc_and_vim install_prepare_software_on_debian begin_install_vimplus } +# 在parrot上安装vimplus +function install_vimplus_on_parrot() +{ + backup_vimrc_and_vim + install_prepare_software_on_parrot + begin_install_vimplus +} + # 在centos上安装vimplus function install_vimplus_on_centos() { + backup_vimrc_and_vim install_prepare_software_on_centos begin_install_vimplus } +# 在fedora上安装vimplus +function install_vimplus_on_fedora() +{ + backup_vimrc_and_vim + install_prepare_software_on_fedora + begin_install_vimplus +} + # 在archlinux上安装vimplus function install_vimplus_on_archlinux() { + backup_vimrc_and_vim install_prepare_software_on_archlinux begin_install_vimplus } +# 在Gentoo上安装vimplus +function install_vimplus_on_gentoo() +{ + backup_vimrc_and_vim + install_prepare_software_on_gentoo + begin_install_vimplus +} + # 在opensuse上安装vimplus function install_vimplus_on_opensuse() { + backup_vimrc_and_vim install_prepare_software_on_opensuse begin_install_vimplus } +# 在alpine上安装vimplus +function install_vimplus_on_alpine() +{ + backup_vimrc_and_vim + install_prepare_software_on_alpine + begin_install_vimplus + + # 单独安装 ycm + +} + # 在linux平上台安装vimplus function install_vimplus_on_linux() { @@ -367,21 +706,35 @@ function install_vimplus_on_linux() if [ ${distro} == "Ubuntu" ]; then install_vimplus_on_ubuntu elif [ ${distro} == "Deepin" ]; then - install_vimplus_on_ubuntu + install_vimplus_on_ubuntu_like elif [ ${distro} == "LinuxMint" ]; then - install_vimplus_on_ubuntu + install_vimplus_on_ubuntu_like elif [ ${distro} == "elementaryOS" ]; then - install_vimplus_on_ubuntu + install_vimplus_on_ubuntu_like elif [ ${distro} == "Debian" ]; then install_vimplus_on_debian + elif [ ${distro} == "Raspbian" ]; then + install_vimplus_on_debian + elif [ ${distro} == "UOS" ]; then + install_vimplus_on_debian + elif [ ${distro} == "Kali" ]; then + install_vimplus_on_debian + elif [ ${distro} == "Parrot" ]; then + install_vimplus_on_parrot elif [ ${distro} == "CentOS" ]; then install_vimplus_on_centos + elif [ ${distro} == "fedora" ]; then + install_vimplus_on_fedora elif [ ${distro} == "openSUSE" ]; then install_vimplus_on_opensuse elif [ ${distro} == "ArchLinux" ]; then install_vimplus_on_archlinux elif [ ${distro} == "ManjaroLinux" ]; then install_vimplus_on_archlinux + elif [ ${distro} == "Gentoo" ]; then + install_vimplus_on_gentoo + elif [ ${distro} == "Alpine" ]; then + install_vimplus_on_alpine else echo "Not support linux distro: "${distro} fi @@ -399,13 +752,21 @@ function main() { begin=`get_now_timestamp` - type=`get_platform_type` + type=$(uname) echo "Platform type: "${type} - if [ ${type} == "Darwin" ]; then + if [ ${type} == "Darwin" ]; then install_vimplus_on_mac + elif [ ${type} == "FreeBSD" ]; then + install_vimplus_on_freebsd elif [ ${type} == "Linux" ]; then - install_vimplus_on_linux + tp=$(uname -a) + if [[ $tp =~ "Android" ]]; then + echo "Android" + install_vimplus_on_android + else + install_vimplus_on_linux + fi else echo "Not support platform type: "${type} fi diff --git a/install_to_user.sh b/install_to_user.sh new file mode 100755 index 00000000..6e3d35b2 --- /dev/null +++ b/install_to_user.sh @@ -0,0 +1,286 @@ +#!/bin/bash + +# 获取平台类型,mac还是linux平台 +function get_platform_type() +{ + echo $(uname) +} + +# 在linux上获取当前用户 +function get_current_username_on_linux() +{ + current_path=$PWD + array=(${current_path//// }) + + if [ ${array[0]} == "root" ]; then + echo ${array[0]} + else + echo ${array[1]} + fi +} + +# 在linux上判断用户是否存在 +function is_valid_user_on_linux() +{ + desc_username=$1 + usernames=$(ls /home/) + array=(${usernames// / }) + + is_found=0 + for username in ${array[@]} + do + if [ $username == $desc_username ]; then + is_found=1 + break + fi + done + + if [ $desc_username == "root" ]; then + is_found=1 + fi + + echo $is_found +} + +# 获取日期 +function get_datetime() +{ + time=$(date "+%Y%m%d%H%M%S") + echo $time +} + +# 判断文件是否存在 +function is_exist_file() +{ + filename=$1 + if [ -f $filename ]; then + echo 1 + else + echo 0 + fi +} + +# 判断目录是否存在 +function is_exist_dir() +{ + dir=$1 + if [ -d $dir ]; then + echo 1 + else + echo 0 + fi +} + +#备份原有的.vimrc文件 +function backup_vimrc_file() +{ + user=$1 + home_path=$2 + old_vimrc=$home_path".vimrc" + is_exist=$(is_exist_file $old_vimrc) + if [ $is_exist == 1 ]; then + time=$(get_datetime) + backup_vimrc=$old_vimrc"_bak_"$time + read -p "Find "$old_vimrc" already exists,backup "$old_vimrc" to "$backup_vimrc"? [Y/N] " ch + if [[ $ch == "Y" ]] || [[ $ch == "y" ]]; then + cp $old_vimrc $backup_vimrc + chown $user":"$user $backup_vimrc + fi + fi +} + +#备份原有的.vimrc.custom.plugins文件 +function backup_vimrc_custom_plugins_file() +{ + user=$1 + home_path=$2 + old_vimrc_plugins=$home_path".vimrc.custom.plugins" + is_exist=$(is_exist_file $old_vimrc_plugins) + if [ $is_exist == 1 ]; then + time=$(get_datetime) + backup_vimrc_plugins=$old_vimrc_plugins"_bak_"$time + read -p "Find "$old_vimrc_plugins" already exists,backup "$old_vimrc_plugins" to "$backup_vimrc_plugins"? [Y/N] " ch + if [[ $ch == "Y" ]] || [[ $ch == "y" ]]; then + cp $old_vimrc_plugins $backup_vimrc_plugins + chown $user":"$user $backup_vimrc_plugins + fi + fi +} + +#备份原有的.vimrc.custom.config文件 +function backup_vimrc_custom_config_file() +{ + user=$1 + home_path=$2 + old_vimrc_config=$home_path".vimrc.custom.config" + is_exist=$(is_exist_file $old_vimrc_config) + if [ $is_exist == 1 ]; then + time=$(get_datetime) + backup_vimrc_config=$old_vimrc_config"_bak_"$time + read -p "Find "$old_vimrc_config" already exists,backup "$old_vimrc_config" to "$backup_vimrc_config"? [Y/N] " ch + if [[ $ch == "Y" ]] || [[ $ch == "y" ]]; then + cp $old_vimrc_config $backup_vimrc_config + chown $user":"$user $backup_vimrc_config + fi + fi +} + +#备份原有的.vim目录 +function backup_vim_dir() +{ + user=$1 + home_path=$2 + old_vim=$home_path".vim" + is_exist=$(is_exist_dir $old_vim) + if [ $is_exist == 1 ]; then + time=$(get_datetime) + backup_vim=$old_vim"_bak_"$time + read -p "Find "$old_vim" already exists,backup "$old_vim" to "$backup_vim"? [Y/N] " ch + if [[ $ch == "Y" ]] || [[ $ch == "y" ]]; then + cp -R $old_vim $backup_vim + chown -R $user":"$user $backup_vim + fi + fi +} + +# 备份原有的.vimrc和.vim +function backup_vimrc_and_vim() +{ + backup_vimrc_file $1 $2 + backup_vimrc_custom_plugins_file $1 $2 + backup_vimrc_custom_config_file $1 $2 + backup_vim_dir $1 $2 +} + +# 打印logo +function print_logo() +{ + color="$(tput setaf 6)" + normal="$(tput sgr0)" + printf "${color}" + echo ' __ __ ' + echo '__ __/_/___ ___ ____ / /_ _______ ' + echo '\ \ / / / __ `__ \/ __ \/ / / / / ___/ ' + echo ' \ V / / / / / / / /_/ / / /_/ (__ ) ' + echo ' \_/_/_/ /_/ /_/ ,___/_/\____/____/ ' + echo ' /_/ ...is now installed!' + echo '' + echo '' + echo 'Just enjoy it!' + echo 'p.s. Follow me at https://github.com/chxuan.' + echo '' + printf "${normal}" +} + +# 获得home路径 +function get_home_path() +{ + username=$1 + if [ $username == "root" ]; then + echo "/root/" + else + echo "/home/"$username"/" + fi +} + +# 在linux上将vimplus安装到指定用户 +function install_to_user_on_linux() +{ + src_username=`get_current_username_on_linux` + desc_username=$1 + + # 判断是否是有效用户 + is_found=$(is_valid_user_on_linux $desc_username) + if [ $is_found != 1 ]; then + echo "Invalid username "$desc_username + return + fi + + # 判断是否是当前用户 + if [ $src_username == $desc_username ]; then + echo "Can not install vimplus to "$desc_username + return + fi + + src_home_path=$(get_home_path $src_username) + desc_home_path=$(get_home_path $desc_username) + + echo "Current home path:"$src_home_path + echo "Installing vimplus to "$desc_home_path + + backup_vimrc_and_vim $desc_username $desc_home_path + + # 拷贝.vim目录 + src_vim_path=$src_home_path".vim/" + desc_vim_path=$desc_home_path".vim/" + + rm -rf $desc_vim_path + mkdir $desc_vim_path + + cp -R $src_vim_path"autoload/" $desc_vim_path + cp -R $src_vim_path"plugged/" $desc_vim_path + + chown -R $desc_username":"$desc_username $desc_vim_path + + # 拷贝.vimplus目录 + src_vimplus_path=$src_home_path".vimplus/" + desc_vimplus_path=$desc_home_path".vimplus/" + + rm -rf $desc_vimplus_path + cp -R $src_vimplus_path $desc_home_path + chown -R $desc_username":"$desc_username $desc_vimplus_path + + rm -rf $desc_home_path".vimrc.custom.plugins" + cp $desc_vimplus_path".vimrc.custom.plugins" $desc_home_path + chown $desc_username":"$desc_username $desc_home_path".vimrc.custom.plugins" + + rm -rf $desc_home_path".vimrc.custom.config" + cp $desc_vimplus_path".vimrc.custom.config" $desc_home_path + chown $desc_username":"$desc_username $desc_home_path".vimrc.custom.config" + + # 创建软链接 + rm -rf $desc_home_path".vimrc" + ln -s $desc_vimplus_path".vimrc" $desc_home_path + chown -R $desc_username":"$desc_username $desc_home_path".vimrc" + + rm -rf $desc_home_path".ycm_extra_conf.py" + ln -s $desc_vimplus_path".ycm_extra_conf.py" $desc_home_path + chown -R $desc_username":"$desc_username $desc_home_path".ycm_extra_conf.py" + + ln -s $desc_vimplus_path"colors" $desc_vim_path + chown -R $desc_username":"$desc_username $desc_vim_path"colors" + + ln -s $desc_vimplus_path"ftplugin" $desc_vim_path + chown -R $desc_username":"$desc_username $desc_vim_path"ftplugin" + + ln -s $desc_vimplus_path"autoload" $desc_vim_path + chown -R $desc_username":"$desc_username $desc_vim_path"autoload" + + # 安装字体 + mkdir -p $desc_home_path".local/share/fonts/" + rm -rf $desc_home_path".local/share/fonts/Droid Sans Mono Nerd Font Complete.otf" + cp $desc_vimplus_path"fonts/Droid Sans Mono Nerd Font Complete.otf" $desc_home_path".local/share/fonts/" + chown -R $desc_username":"$desc_username $desc_home_path".local/" + fc-cache -vf $desc_home_path".local/share/fonts/" +} + +# 脚本启动点 +if [ $# -lt 1 ]; then + echo "Please input username!" + exit 1 +fi + +type=`get_platform_type` +echo "Platform type: "${type} + +if [ ${type} == "Linux" ]; then + for username in $@ + do + install_to_user_on_linux $username + done + + print_logo +else + echo "Not support platform type: "${type} +fi + diff --git a/screenshots/main.png b/screenshots/main.png index 8632369f..c1bf5a42 100644 Binary files a/screenshots/main.png and b/screenshots/main.png differ diff --git a/uninstall.sh b/uninstall.sh index e0081bdb..b6f554c3 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -1,6 +1,8 @@ #!/bin/bash -sudo rm -rf ~/.vim +rm -rf ~/.vim +rm -rf ~/.vimrc +rm -rf ~/.ycm_extra_conf.py echo "Done!" diff --git a/update.sh b/update.sh new file mode 100755 index 00000000..309abbc0 --- /dev/null +++ b/update.sh @@ -0,0 +1,166 @@ +#!/bin/bash + +# 判断文件是否存在 +function is_exist_file() +{ + filename=$1 + if [ -f $filename ]; then + echo 1 + else + echo 0 + fi +} + +# 更新mac平台字体 +function update_fonts_on_mac() +{ + rm -rf ~/Library/Fonts/Droid\ Sans\ Mono\ Nerd\ Font\ Complete.otf + cp ./fonts/Droid\ Sans\ Mono\ Nerd\ Font\ Complete.otf ~/Library/Fonts +} + +# 更新android平台字体 +function update_fonts_on_android() +{ + rm -rf ~/.termux/font.ttf + mkdir ~/.termux + cp ./fonts/DejaVu.ttf ~/.termux/font.ttf + + # 刷新style + REL="am broadcast --user 0 -a com.termux.app.reload_style com.termux" + $REL > /dev/null +} + +# 更新linux平台字体 +function update_fonts_on_linux() +{ + mkdir -p ~/.local/share/fonts + rm -rf ~/.local/share/fonts/Droid\ Sans\ Mono\ Nerd\ Font\ Complete.otf + cp ./fonts/Droid\ Sans\ Mono\ Nerd\ Font\ Complete.otf ~/.local/share/fonts + + fc-cache -vf ~/.local/share/fonts +} + +# 更新vim插件 +function update_vim_plugin() +{ + vim -c "PlugUpdate" -c "q" -c "q" +} + +# 拷贝文件 +function copy_files() +{ + rm -rf ~/.vimrc + ln -s ${PWD}/.vimrc ~ + + vimrc_plugins=$HOME"/.vimrc.custom.plugins" + is_exist=$(is_exist_file $vimrc_plugins) + if [ $is_exist != 1 ]; then + cp ${PWD}/.vimrc.custom.plugins ~ + fi + + vimrc_config=$HOME"/.vimrc.custom.config" + is_exist=$(is_exist_file $vimrc_config) + if [ $is_exist != 1 ]; then + cp ${PWD}/.vimrc.custom.config ~ + fi + + rm -rf ~/.ycm_extra_conf.py + ln -s ${PWD}/.ycm_extra_conf.py ~ + + rm -rf ~/.vim/colors + ln -s ${PWD}/colors ~/.vim + + rm -rf ~/.vim/ftplugin + ln -s ${PWD}/ftplugin ~/.vim + + rm -rf ~/.vim/autoload + ln -s ${PWD}/autoload ~/.vim +} + +# 打印logo +function print_logo() +{ + color="$(tput setaf 6)" + normal="$(tput sgr0)" + printf "${color}" + echo ' __ __ ' + echo '__ __/_/___ ___ ____ / /_ _______ ' + echo '\ \ / / / __ `__ \/ __ \/ / / / / ___/ ' + echo ' \ V / / / / / / / /_/ / / /_/ (__ ) ' + echo ' \_/_/_/ /_/ /_/ ,___/_/\____/____/ ' + echo ' /_/ ...is now updated!' + echo '' + echo '' + echo 'Just enjoy it!' + echo 'p.s. Follow me at https://github.com/chxuan.' + echo '' + printf "${normal}" +} + +# 在mac更新vimplus +function update_vimplus_on_mac() +{ + git pull origin master + copy_files + update_fonts_on_mac + update_vim_plugin + print_logo +} + +# 在linux更新vimplus +function update_vimplus_on_linux() +{ + git pull origin master + copy_files + update_fonts_on_linux + update_vim_plugin + print_logo +} + +# 在android更新vimplus +function update_vimplus_on_android() +{ + git pull origin master + copy_files + update_fonts_on_android + update_vim_plugin + print_logo +} + +# 获取当前时间戳 +function get_now_timestamp() +{ + cur_sec_and_ns=`date '+%s-%N'` + echo ${cur_sec_and_ns%-*} +} + +# main函数 +function main() +{ + begin=`get_now_timestamp` + + type=$(uname) + echo "Platform type: "${type} + + if [ ${type} == "Darwin" ]; then + update_vimplus_on_mac + elif [ ${type} == "Linux" ]; then + tp=$(uname -a) + if [[ $tp =~ "Android" ]]; then + echo "Android" + update_vimplus_on_android + else + update_vimplus_on_linux + fi + else + echo "Not support platform type: "${type} + fi + + end=`get_now_timestamp` + second=`expr ${end} - ${begin}` + min=`expr ${second} / 60` + echo "It takes "${min}" minutes." +} + +# 调用main函数 +main