mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-04-13 22:39:10 +08:00
feat(rainbow): change rainbow plugin
This commit is contained in:
parent
cfc2b9e7b9
commit
9caa00b009
@ -17,7 +17,7 @@ function! SpaceVim#layers#tools#plugins() abort
|
||||
call add(plugins, ['tpope/vim-scriptease', { 'merged' : 0}])
|
||||
call add(plugins, ['lymslive/vimloo', { 'merged' : 0}])
|
||||
call add(plugins, ['lymslive/vnote', { 'merged' : 0}])
|
||||
call add(plugins, ['junegunn/rainbow_parentheses.vim', { 'merged' : 0}])
|
||||
call add(plugins, [g:_spacevim_root_dir . 'bundle/rainbow', { 'merged' : 0}])
|
||||
call add(plugins, ['mbbill/fencview', { 'on_cmd' : 'FencAutoDetect'}])
|
||||
call add(plugins, ['wsdjeg/vim-cheat', { 'on_cmd' : 'Cheat'}])
|
||||
call add(plugins, ['wsdjeg/Mysql.vim', { 'on_cmd' : 'SQLGetConnection'}])
|
||||
@ -55,16 +55,6 @@ function! SpaceVim#layers#tools#config() abort
|
||||
nnoremap <silent> ma :<C-u>BookmarkShowAll<Cr>
|
||||
nnoremap <silent> mn :<C-u>BookmarkNext<Cr>
|
||||
nnoremap <silent> mp :<C-u>BookmarkPrev<Cr>
|
||||
augroup rainbow_lisp
|
||||
autocmd!
|
||||
autocmd FileType lisp,clojure,scheme,racket,java RainbowParentheses
|
||||
autocmd FileType vimcalc setlocal nonu nornu nofoldenable | inoremap <silent> <buffer> <c-d> <c-[>:q<cr>
|
||||
\ | nnoremap <silent> <buffer> q :bdelete<cr>
|
||||
augroup END
|
||||
let g:rainbow#max_level = 16
|
||||
let g:rainbow#pairs = [['(', ')'], ['[', ']'],['{','}']]
|
||||
" List of colors that you do not want. ANSI code or #RRGGBB
|
||||
let g:rainbow#blacklist = [233, 234]
|
||||
if maparg('<C-_>', 'v') ==# ''
|
||||
vnoremap <silent> <C-_> <Esc>:Ydv<CR>
|
||||
endif
|
||||
|
@ -12,6 +12,7 @@ In `bundle/` directory, there are two kinds of plugins: forked plugins without c
|
||||
- `vim-virtualenv`: based on [vim-virtualenv](https://github.com/jmcantrell/vim-virtualenv/tree/b1150223cd876f155ed7a3b2e285ed33f6f93873)
|
||||
- `clever-f.vim`: based on [`clever-f.vim@fd370f2`](https://github.com/rhysd/clever-f.vim/tree/fd370f27cca93918184a8043220cef1aa440a1fd)
|
||||
- `verilog`: based on [`vhda/verilog_systemverilog.vim@0b88f2c`](https://github.com/vhda/verilog_systemverilog.vim/tree/0b88f2ccf81983944bf00d15ec810dd807053d19)
|
||||
- `rainbow`: based on [`luochen1990/rainbow@c18071e5`](https://github.com/luochen1990/rainbow/tree/c18071e5c7790928b763c2e88c487dfc93d84a15)
|
||||
|
||||
### No changed plugins
|
||||
|
||||
|
32
bundle/rainbow/.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
32
bundle/rainbow/.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: "[Bug] "
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
### **Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
### **To Reproduce**
|
||||
Steps to reproduce the behavior, **Please provide a minimal piece of code to produce this issue**, along with it's filename and it's filetype detected by vim (via `:set ft?`), a piece of text is better than a picture here. For example:
|
||||
|
||||
File: `bug.js`, filetype=javascript
|
||||
```
|
||||
var pair = {x: 1, y: 2}
|
||||
```
|
||||
|
||||
Steps:
|
||||
1. Open file via `vim bug.js`
|
||||
2. See the color of `{` and `}` around text `{x: 1, y: 2}`
|
||||
|
||||
### **Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
### **Screenshots**
|
||||
Provide a screenshot to describe what you got.
|
||||
|
||||
### **Additional context**
|
||||
**Are you using some third-party syntax plugins?** Add any other context about the problem here.
|
20
bundle/rainbow/.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
bundle/rainbow/.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: feature request
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
10
bundle/rainbow/.github/ISSUE_TEMPLATE/not-issue.md
vendored
Normal file
10
bundle/rainbow/.github/ISSUE_TEMPLATE/not-issue.md
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
name: Not Issue
|
||||
about: Start a conversation which is not about bug report or feature request
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
This is not an Issue. You can type anything here except bug report and feature request.
|
1
bundle/rainbow/.gitignore
vendored
Normal file
1
bundle/rainbow/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
doc/tags
|
201
bundle/rainbow/LICENSE
Normal file
201
bundle/rainbow/LICENSE
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
2
bundle/rainbow/NOTICE
Normal file
2
bundle/rainbow/NOTICE
Normal file
@ -0,0 +1,2 @@
|
||||
Rainbow Parentheses Improved
|
||||
Copyright 2013 LuoChen (luochen1990@gmail.com). Licensed under the Apache License 2.0.
|
189
bundle/rainbow/README.md
Normal file
189
bundle/rainbow/README.md
Normal file
@ -0,0 +1,189 @@
|
||||
Rainbow Parentheses Improved
|
||||
===
|
||||
> help you read complex code by showing diff level of parentheses in diff color !!
|
||||
|
||||
Description [(这里有中文版)](https://github.com/luochen1990/rainbow/blob/master/README_zh.md)
|
||||
---------------------------------------------------------------------------------------------------
|
||||
|
||||
As everyone knows, the most complex codes were composed of a mass of different kinds of parentheses (typically: lisp).
|
||||
This plugin will help you read these codes by showing different levels of parentheses in different colors.
|
||||
You can also find this plugin in **[www.vim.org](http://www.vim.org/scripts/script.php?script_id=4176)**.
|
||||
|
||||
#### lisp
|
||||

|
||||
#### html
|
||||

|
||||
#### [more](https://github.com/luochen1990/rainbow/blob/demo/more.md)
|
||||
|
||||
### What is improved ?
|
||||
|
||||
- no limit of parentheses levels.
|
||||
- separately edit guifgs and ctermfgs (the colors used for highlighting).
|
||||
- now you can design your own parentheses such as 'begin' and 'end'.
|
||||
- you can also configure anything separately for different types of files.
|
||||
- now you can even decide to let some operators (like + - * / , ==) highlighted with the parentheses together.
|
||||
- dot separated combined filetype support (`:h ft`).
|
||||
- json style configuration used, more understandable and readable, easier for advanced configuration.
|
||||
- the code is shorter and easier to read now.
|
||||
- smoother and faster.
|
||||
- the Chinese document is added.
|
||||
|
||||
### Referenced:
|
||||
- http://www.vim.org/scripts/script.php?script_id=1561 (Martin Krischik)
|
||||
- http://www.vim.org/scripts/script.php?script_id=3772 (kien)
|
||||
|
||||
Install
|
||||
-------
|
||||
|
||||
#### install via Plug:
|
||||
|
||||
```vim
|
||||
Plug 'luochen1990/rainbow'
|
||||
let g:rainbow_active = 1 "set to 0 if you want to enable it later via :RainbowToggle
|
||||
```
|
||||
|
||||
#### install manually:
|
||||
|
||||
- first, execute the following commands (for windows users, use `~/vimfiles` instead of `~/.vim`)
|
||||
|
||||
```sh
|
||||
git clone https://github.com/luochen1990/rainbow.git
|
||||
cd rainbow
|
||||
mkdir -p ~/.vim/plugin ~/.vim/autoload
|
||||
cp plugin/* ~/.vim/plugin
|
||||
cp autoload/* ~/.vim/autoload
|
||||
```
|
||||
|
||||
- second, add the follow sentences to your `.vimrc` or `_vimrc` :
|
||||
|
||||
```vim
|
||||
let g:rainbow_active = 1 "set to 0 if you want to enable it later via :RainbowToggle
|
||||
```
|
||||
|
||||
- third, restart your vim and enjoy coding.
|
||||
|
||||
Configure
|
||||
---------
|
||||
|
||||
There is an example for advanced configuration, add it to your vimrc and edit it as you wish (just keep the format).
|
||||
|
||||
Note: you can remove these lines safely since they are all included by the [source code](https://github.com/luochen1990/rainbow/blob/master/autoload/rainbow_main.vim)).
|
||||
|
||||
```vim
|
||||
let g:rainbow_conf = {
|
||||
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
|
||||
\ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
|
||||
\ 'guis': [''],
|
||||
\ 'cterms': [''],
|
||||
\ 'operators': '_,_',
|
||||
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
|
||||
\ 'separately': {
|
||||
\ '*': {},
|
||||
\ 'markdown': {
|
||||
\ 'parentheses_options': 'containedin=markdownCode contained', "enable rainbow for code blocks only
|
||||
\ },
|
||||
\ 'lisp': {
|
||||
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'], "lisp needs more colors for parentheses :)
|
||||
\ },
|
||||
\ 'haskell': {
|
||||
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/\v\{\ze[^-]/ end=/}/ fold'], "the haskell lang pragmas should be excluded
|
||||
\ },
|
||||
\ 'vim': {
|
||||
\ 'parentheses_options': 'containedin=vimFuncBody', "enable rainbow inside vim function body
|
||||
\ },
|
||||
\ 'perl': {
|
||||
\ 'syn_name_prefix': 'perlBlockFoldRainbow', "solve the [perl indent-depending-on-syntax problem](https://github.com/luochen1990/rainbow/issues/20)
|
||||
\ },
|
||||
\ 'stylus': {
|
||||
\ 'parentheses': ['start=/{/ end=/}/ fold contains=@colorableGroup'], "[vim css color](https://github.com/ap/vim-css-color) compatibility
|
||||
\ },
|
||||
\ 'css': 0, "disable this plugin for css files
|
||||
\ }
|
||||
\}
|
||||
```
|
||||
|
||||
- 'guifgs': a list of `guifg` (`:h highlight-guifg`), i.e. colors for gui interface, will be used in order
|
||||
- 'guis': a list of `gui` (`:h highlight-gui`), will be used in order
|
||||
- 'ctermfgs': a list of `ctermfg` (`:h highlight-ctermfg`)
|
||||
- 'cterms': a list of `cterm` (`:h highlight-cterm`)
|
||||
- 'operators': describe the operators you want to highlight (note: be careful about special characters which needs escaping, you can find more examples [here](https://github.com/luochen1990/rainbow/issues/3), and you can also read the [vim help about syn-pattern](http://vimdoc.sourceforge.net/htmldoc/syntax.html#:syn-pattern)). note that this option will be overwritten by the `step` part of `parentheses`.
|
||||
- 'parentheses': a list of parentheses definitions, a parentheses definition contains parts like `start=/(/`, `step=/,/`, `stop=/)/`, `fold`, `contained`, `containedin=someSynNames`, `contains=@Spell`, see `:h syntax` for more details. notice that the `step` part is defined by this plugin so it is not described by the official vim doc.
|
||||
- 'parentheses_options': parentheses options shared between different parentheses, things like `containedin=xxxFuncBody`, `contains=@Spell` (or 'contains=@NoSpell') often appears here. this option is often used to solve [3rd-party-plugin-compatibility]() problems.
|
||||
- 'separately': configure for specific filetypes (decided by &ft), key `*` for filetypes without separate configuration, value `0` means disable rainbow only for this type of files, value `"default"` means keep the default shim for this filetype (notice: the default shim config will change between plugin version).
|
||||
- 'syn_name_prefix': add a prefix to name of the syntax definition, this option is often used to solve [3rd-party-plugin-compatibility]() problems.
|
||||
- 'after': execute some vim commands after the rainbow syntax rules is defined. it is often used like `['syn clear xxx']` to solve [3rd-party-plugin-compatibility]() problems.
|
||||
- keep a field empty to use the default setting.
|
||||
|
||||
To get more advanced config examples, try to search throught this [tag](https://github.com/luochen1990/rainbow/issues?utf8=%E2%9C%93&q=label%3A%22config+reference%22+).
|
||||
|
||||
User Command
|
||||
------------
|
||||
|
||||
- **:RainbowToggle** --you can use it to toggle this plugin.
|
||||
|
||||
3rd Party Plugin Compatibility
|
||||
------------------------------
|
||||
|
||||
You should notice that this plugin is very special, Vim plugins is expected to provide syntax definitions vertically, i.e. one filetype, one syntax definition set:
|
||||
|
||||
```
|
||||
----------------------------------------------------
|
||||
| cpp | java | python |
|
||||
| | | |
|
||||
| syn cppKeyword | syn javaKeyword | syn pyKeyword |
|
||||
| syn cppFunc | syn javaFunc | syn pyLambda |
|
||||
| syn cppParen | syn javaParen | syn pyParen |
|
||||
| ... | ... | ... |
|
||||
----------------------------------------------------
|
||||
```
|
||||
|
||||
But this plugin provide syntax definitions horizontally, i.e. parentheses syntax for all filetypes:
|
||||
|
||||
```
|
||||
----------------------------------------------------
|
||||
| cpp | java | python |
|
||||
| | | |
|
||||
| syn cppKeyword | syn javaKeyword | syn pyKeyword |
|
||||
| syn cppFunc | syn javaFunc | syn pyLambda |
|
||||
| ... | ... | ... |
|
||||
----------------------------------------------------
|
||||
| rainbow |
|
||||
| |
|
||||
| syn cppRainbow syn javaRainbow syn pyRainbow |
|
||||
----------------------------------------------------
|
||||
```
|
||||
|
||||
You can notice that, to provide rainbow parentheses, this plugin have to define it's own syntax rules, and these rules will overwrite the parentheses syntax provided by the filetype plugin.
|
||||
|
||||
It works well at most of the time, but in some special cases, when the parentheses syntax rule is depended somewhere else (e.g. indent, spell checking, nested syntax rules), the things depend on the original syntax rules will be broken.
|
||||
|
||||
This plugin has provide some mechanisms to solve the compatibility problems, and have provided default configurations to solve compatibility problems with the default vim syntax files.
|
||||
|
||||
But if this plugin is conflicted with some other plugins, you will probably have to solve them by yourself. First, you can search on [this issue tag](https://github.com/luochen1990/rainbow/issues?utf8=%E2%9C%93&q=label%3A%22confliction+with+other+third-party+syntax+plugins%22+) to find whether there is somebody else had the same problem and solved it. Second, you can read the following content about troubleshooting.
|
||||
|
||||
Troubleshooting
|
||||
---------------
|
||||
|
||||
- rainbow doesn't work at all: find out the current parentheses syntax name, and use the `after` mechanism to clear these syntax.
|
||||
- rainbow doesn't work inside some structure: find out the syntax region name, and use the `parentheses_options` mechanism like `'containedin=xxx'`.
|
||||
- spell checking doesn't work inside parentheses: use the `parentheses_options` mechanism like `'contains=@Spell'`.
|
||||
- spell checking works inside parentheses but you don't want it: use the `parentheses_options` mechanism like `'contains=@NoSpell'`.
|
||||
- indent not works correctly: check the indent script you are using and search `synID` inside it to find which syntax name prefix it depends on, and use the `syn_name_prefix` mechanism to solve it.
|
||||
|
||||
The following keymappings will help you to check the syntax name and definitions under the cursor, add them to your vimrc and restart vim:
|
||||
|
||||
```vim
|
||||
nnoremap <f1> :echo synIDattr(synID(line('.'), col('.'), 0), 'name')<cr>
|
||||
nnoremap <f2> :echo ("hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
|
||||
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
|
||||
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">")<cr>
|
||||
nnoremap <f3> :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')<cr>
|
||||
nnoremap <f4> :exec 'syn list '.synIDattr(synID(line('.'), col('.'), 0), 'name')<cr>
|
||||
```
|
||||
|
||||
Move your cursor to a parentheses and press the keys to use them.
|
||||
|
||||
------------------------------------------------------------------
|
||||
**Rate this script if you like it, and I'll appreciate it and improve this plugin for you because of your support!
|
||||
|
||||
Just go to [this page](http://www.vim.org/scripts/script.php?script_id=4176) and choose `Life Changing` and click `rate`**
|
103
bundle/rainbow/README_zh.md
Normal file
103
bundle/rainbow/README_zh.md
Normal file
@ -0,0 +1,103 @@
|
||||
彩虹括号增强版 (Rainbow Parentheses Improved)
|
||||
=============================================
|
||||
> 通过将不同层次的括号高亮为不同的颜色, 帮助你阅读世界上最复杂的代码
|
||||
|
||||
插件简介:
|
||||
---------
|
||||
|
||||
众所周知,最复杂的代码都是由一堆乱七八糟的括号组成。这款插件通过以不同的颜色展示不同层次的括号,致力于帮助你阅读这样的复杂代码。 你同样可以在[Vim官网](http://www.vim.org/scripts/script.php?script_id=4176)里看到这款插件
|
||||
|
||||
#### lisp
|
||||

|
||||
#### html
|
||||

|
||||
#### [more](https://github.com/luochen1990/rainbow/blob/demo/more.md)
|
||||
|
||||
### 有哪些改进?
|
||||
|
||||
- 更快速和流畅的体验。
|
||||
- 简短,高质量,并且易读的源代码。
|
||||
- 现在的版本将不再限制括号的嵌套层数。
|
||||
- 现在你可以分别自定义图形界面下和终端上所使用的各种括号颜色。
|
||||
- 现在你可以自定义括号的形式,不过在这之前你最好了解vim脚本的正则表达式。
|
||||
- 现在你甚至可以为不同类型的文件设定不同的配置。
|
||||
- 现在你甚至可以决定是否让某些符号跟着它们所在的括号一起高亮,你也可以对不同类型的文件分别设置。
|
||||
- 支持点分隔的复合文件类型 (`:h ft`)
|
||||
- 现在采用json风格的配置文件,更加可读,更易于进行高级配置。
|
||||
- 最后但并非不重要的一点是,如你所见,现在增加了中文说明。
|
||||
|
||||
### 以下是本插件所参考的旧版本:
|
||||
- http://www.vim.org/scripts/script.php?script_id=1561 (Martin Krischik)
|
||||
- http://www.vim.org/scripts/script.php?script_id=3772 (kien)
|
||||
|
||||
安装说明:
|
||||
---------
|
||||
|
||||
### 使用Vundle安装:
|
||||
|
||||
```vim
|
||||
Bundle 'luochen1990/rainbow'
|
||||
let g:rainbow_active = 1 "0 if you want to enable it later via :RainbowToggle
|
||||
```
|
||||
|
||||
### 手动安装:
|
||||
|
||||
- 首先,执行以下命令 (Windows用户需要使用 `~/vimfiles` 替代 `~/.vim`) 。
|
||||
|
||||
```sh
|
||||
git clone https://github.com/luochen1990/rainbow.git
|
||||
cd rainbow
|
||||
cp plugin/* ~/.vim/plugin
|
||||
cp autoload/* ~/.vim/autoload
|
||||
```
|
||||
|
||||
- 然后,将以下句子,加入到你的vim配置文件中(windows下配置文件是`_vimrc`,而linux下是`.vimrc`)
|
||||
|
||||
```vim
|
||||
let g:rainbow_active = 1 "0 if you want to enable it later via :RainbowToggle
|
||||
```
|
||||
|
||||
- 最后,重新启动你的vim,你就可以享受coding了。
|
||||
|
||||
高级配置:
|
||||
---------
|
||||
|
||||
以下是一个配置的样例(也是我在用的配置),将它加入到你的vimrc并按照你喜欢的方式修改它(但是保持格式)你就可以精确地控制插件的行为了。
|
||||
|
||||
```vim
|
||||
let g:rainbow_conf = {
|
||||
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
|
||||
\ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
|
||||
\ 'operators': '_,_',
|
||||
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
|
||||
\ 'separately': {
|
||||
\ '*': {},
|
||||
\ 'tex': {
|
||||
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'],
|
||||
\ },
|
||||
\ 'lisp': {
|
||||
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
|
||||
\ },
|
||||
\ 'vim': {
|
||||
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'],
|
||||
\ },
|
||||
\ 'html': {
|
||||
\ 'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold'],
|
||||
\ },
|
||||
\ 'css': 0,
|
||||
\ }
|
||||
\}
|
||||
```
|
||||
|
||||
- 'guifgs': 一个`guifg`的列表 (`:h highlight-guifg`), 即GUI界面的括号颜色, 将按顺序循环使用
|
||||
- 'guis': 一个`gui`的列表 (`:h highlight-gui`), 将按顺序循环使用
|
||||
- 'ctermfgs': 一个`ctermfg`的列表 (`:h highlight-ctermfg`), 即终端下的括号颜色
|
||||
- 'cterms': 一个`cterm`的列表 (`:h highlight-cterm`)
|
||||
- 'operators': 描述你希望哪些运算符跟着与它同级的括号一起高亮(注意:留意需要转义的特殊字符,更多样例见[这里](https://github.com/luochen1990/rainbow/issues/3), 你也可以读[vim帮助 :syn-pattern](http://vimdoc.sourceforge.net/htmldoc/syntax.html#:syn-pattern))
|
||||
- 'parentheses': 一个关于括号定义的列表, 每一个括号的定义包含形如以下的部分: `start=/(/`, `step=/,/`, `stop=/)/`, `fold`, `contained`, `containedin=someSynNames`, `contains=@Spell`. 各个部分具体含义可参考 `:h syntax`, 其中 `step` 为本插件的扩展定义, 表示括号中间需要高亮的运算符.
|
||||
- 'separately': 针对文件类型(由&ft决定)作不同的配置,未被单独设置的文件类型使用`*`下的配置,值为`0`表示仅对该类型禁用插件,值为`"default"`表示使用针对该类型的默认兼容配置 (注意, 默认兼容配置可能随着该插件版本的更新而改变, 如果你不希望它改变, 那么你应该将它拷贝一份放到你的vimrc文件里).
|
||||
- 省略某个字段以使用默认设置
|
||||
|
||||
-------------------------------------------------------------------
|
||||
**最后,如果你喜欢这个插件,给它一个评价,我会心存感激,并且因为你的肯定继续改进这个插件!(从[该页面](http://www.vim.org/scripts/script.php?script_id=4176)下方,选择`Life Changing`选项,然后点击`rate`)**
|
||||
|
128
bundle/rainbow/autoload/rainbow.vim
Normal file
128
bundle/rainbow/autoload/rainbow.vim
Normal file
@ -0,0 +1,128 @@
|
||||
" Copyright 2013 LuoChen (luochen1990@gmail.com). Licensed under the Apache License 2.0.
|
||||
|
||||
if exists('s:loaded') | finish | endif | let s:loaded = 1
|
||||
|
||||
fun s:trim(s)
|
||||
return substitute(a:s, '\v^\s*(.{-})\s*$', '\1', '')
|
||||
endfun
|
||||
|
||||
fun s:concat(strs)
|
||||
return join(filter(a:strs, "v:val !~ '^[ ]*$'"), ',')
|
||||
endfun
|
||||
|
||||
fun s:resolve_parenthesis_with(init_state, p)
|
||||
let [paren, contained, containedin, contains_prefix, contains, op] = a:init_state
|
||||
let p = (type(a:p) == type([])) ? ((len(a:p) == 3) ? printf('start=#%s# step=%s end=#%s#', a:p[0], op, a:p[-1]) : printf('start=#%s# end=#%s#', a:p[0], a:p[-1])) : a:p "NOTE: preprocess the old style parentheses config
|
||||
|
||||
let ls = split(p, '\v%(%(start|step|end)\=(.)%(\1@!.)*\1[^ ]*|\w+%(\=[^ ]*)?) ?\zs', 0)
|
||||
for s in ls
|
||||
let [k, v] = [matchstr(s, '^[^=]\+\ze\(=\|$\)'), matchstr(s, '^[^=]\+=\zs.*')]
|
||||
if k == 'step'
|
||||
let op = s:trim(v)
|
||||
elseif k == 'contains_prefix'
|
||||
let contains_prefix = s:trim(v)
|
||||
elseif k == 'contains'
|
||||
let contains = s:concat([contains, s:trim(v)])
|
||||
elseif k == 'containedin'
|
||||
let containedin = s:concat([containedin, s:trim(v)])
|
||||
elseif k == 'contained'
|
||||
let contained = 1
|
||||
else
|
||||
let paren .= s
|
||||
endif
|
||||
endfor
|
||||
let rst = [paren, contained, containedin, contains_prefix, contains, op]
|
||||
"echom json_encode(rst)
|
||||
return rst
|
||||
endfun
|
||||
|
||||
fun s:resolve_parenthesis_from_config(config)
|
||||
return s:resolve_parenthesis_with(['', 0, '', a:config.contains_prefix, '', a:config.operators], a:config.parentheses_options)
|
||||
endfun
|
||||
|
||||
fun s:synID(prefix, group, lv, id)
|
||||
return a:prefix.'_lv'.a:lv.'_'.a:group.a:id
|
||||
endfun
|
||||
|
||||
fun s:synGroupID(prefix, group, lv)
|
||||
return a:prefix.a:group.'_lv'.a:lv
|
||||
endfun
|
||||
|
||||
fun rainbow#syn(config)
|
||||
let conf = a:config
|
||||
let prefix = conf.syn_name_prefix
|
||||
let cycle = conf.cycle
|
||||
|
||||
let glob_paran_opts = s:resolve_parenthesis_from_config(conf)
|
||||
let b:rainbow_loaded = cycle
|
||||
for id in range(len(conf.parentheses))
|
||||
let [paren, contained, containedin, contains_prefix, contains, op] = s:resolve_parenthesis_with(glob_paran_opts, conf.parentheses[id])
|
||||
for lv in range(cycle)
|
||||
let lv2 = ((lv + cycle - 1) % cycle)
|
||||
let [rid, pid, gid2] = [s:synID(prefix, 'r', lv, id), s:synID(prefix, 'p', lv, id), s:synGroupID(prefix, 'Regions', lv2)]
|
||||
|
||||
if len(op) > 2
|
||||
exe 'syn match '.s:synID(prefix, 'o', lv, id).' '.op.' containedin='.s:synID(prefix, 'r', lv, id).' contained'
|
||||
endif
|
||||
|
||||
let real_contained = (lv == 0)? (contained? 'contained ' : '') : 'contained '
|
||||
let real_containedin = (lv == 0)? s:concat([containedin, '@'.gid2]) : '@'.gid2
|
||||
let real_contains = s:concat([contains_prefix, contains])
|
||||
exe 'syn region '.rid.' matchgroup='.pid.' '.real_contained.'containedin='.real_containedin.' contains='.real_contains.' '.paren
|
||||
endfor
|
||||
endfor
|
||||
for lv in range(cycle)
|
||||
exe 'syn cluster '.s:synGroupID(prefix, 'Regions', lv).' contains='.join(map(range(len(conf.parentheses)), 's:synID(prefix, "r", lv, v:val)'), ',')
|
||||
exe 'syn cluster '.s:synGroupID(prefix, 'Parentheses', lv).' contains='.join(map(range(len(conf.parentheses)), 's:synID(prefix, "p", lv, v:val)'), ',')
|
||||
exe 'syn cluster '.s:synGroupID(prefix, 'Operators', lv).' contains='.join(map(range(len(conf.parentheses)), 's:synID(prefix, "o", lv, v:val)'), ',')
|
||||
endfor
|
||||
exe 'syn cluster '.prefix.'Regions contains='.join(map(range(cycle), '"@".s:synGroupID(prefix, "Regions", v:val)'), ',')
|
||||
exe 'syn cluster '.prefix.'Parentheses contains='.join(map(range(cycle), '"@".s:synGroupID(prefix, "Parentheses", v:val)'), ',')
|
||||
exe 'syn cluster '.prefix.'Operators contains='.join(map(range(cycle), '"@".s:synGroupID(prefix, "Operators", v:val)'), ',')
|
||||
if has_key(conf, 'after') | for cmd in conf.after | exe cmd | endfor | endif
|
||||
endfun
|
||||
|
||||
fun rainbow#syn_clear(config)
|
||||
let conf = a:config
|
||||
let prefix = conf.syn_name_prefix
|
||||
|
||||
for id in range(len(conf.parentheses))
|
||||
for lv in range(conf.cycle)
|
||||
let [rid, oid] = [s:synID(prefix, 'r', lv, id), s:synID(prefix, 'o', lv, id)]
|
||||
exe 'syn clear '.rid
|
||||
exe 'syn clear '.oid
|
||||
endfor
|
||||
endfor
|
||||
endfun
|
||||
|
||||
fun rainbow#hi(config)
|
||||
let conf = a:config
|
||||
let prefix = conf.syn_name_prefix
|
||||
|
||||
for id in range(len(conf.parentheses))
|
||||
for lv in range(conf.cycle)
|
||||
let [pid, oid] = [s:synID(prefix, 'p', lv, id), s:synID(prefix, 'o', lv, id)]
|
||||
let ctermfg = conf.ctermfgs[lv % len(conf.ctermfgs)]
|
||||
let guifg = conf.guifgs[lv % len(conf.guifgs)]
|
||||
let cterm = conf.cterms[lv % len(conf.cterms)]
|
||||
let gui = conf.guis[lv % len(conf.guis)]
|
||||
let hi_style = 'ctermfg='.ctermfg.' guifg='.guifg.(len(cterm) > 0 ? ' cterm='.cterm : '').(len(gui) > 0 ? ' gui='.gui : '')
|
||||
exe 'hi '.pid.' '.hi_style
|
||||
exe 'hi '.oid.' '.hi_style
|
||||
endfor
|
||||
endfor
|
||||
endfun
|
||||
|
||||
fun rainbow#hi_clear(config)
|
||||
let conf = a:config
|
||||
let prefix = conf.syn_name_prefix
|
||||
|
||||
for id in range(len(conf.parentheses))
|
||||
for lv in range(conf.cycle)
|
||||
let [pid, oid] = [s:synID(prefix, 'p', lv, id), s:synID(prefix, 'o', lv, id)]
|
||||
exe 'hi clear '.pid
|
||||
exe 'hi clear '.oid
|
||||
endfor
|
||||
endfor
|
||||
endfun
|
||||
|
136
bundle/rainbow/autoload/rainbow_main.vim
Normal file
136
bundle/rainbow/autoload/rainbow_main.vim
Normal file
@ -0,0 +1,136 @@
|
||||
" Copyright 2013 LuoChen (luochen1990@gmail.com). Licensed under the Apache License 2.0.
|
||||
|
||||
let s:rainbow_conf = {
|
||||
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
|
||||
\ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
|
||||
\ 'guis': [''],
|
||||
\ 'cterms': [''],
|
||||
\ 'operators': '_,_',
|
||||
\ 'contains_prefix': 'TOP',
|
||||
\ 'parentheses_options': '',
|
||||
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
|
||||
\ 'separately': {
|
||||
\ '*': {},
|
||||
\ 'markdown': {
|
||||
\ 'parentheses_options': 'containedin=markdownCode contained',
|
||||
\ },
|
||||
\ 'lisp': {
|
||||
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
|
||||
\ },
|
||||
\ 'haskell': {
|
||||
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/\v\{\ze[^-]/ end=/}/ fold'],
|
||||
\ },
|
||||
\ 'ocaml': {
|
||||
\ 'parentheses': ['start=/(\ze[^*]/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/\[|/ end=/|\]/ fold', 'start=/{/ end=/}/ fold'],
|
||||
\ },
|
||||
\ 'tex': {
|
||||
\ 'parentheses_options': 'containedin=texDocZone',
|
||||
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'],
|
||||
\ },
|
||||
\ 'vim': {
|
||||
\ 'parentheses_options': 'containedin=vimFuncBody,vimExecute',
|
||||
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold'],
|
||||
\ },
|
||||
\ 'xml': {
|
||||
\ 'syn_name_prefix': 'xmlRainbow',
|
||||
\ 'parentheses': ['start=/\v\<\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'))?)*\>/ end=#</\z1># fold'],
|
||||
\ },
|
||||
\ 'xhtml': {
|
||||
\ 'parentheses': ['start=/\v\<\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'))?)*\>/ end=#</\z1># fold'],
|
||||
\ },
|
||||
\ 'html': {
|
||||
\ 'parentheses': ['start=/\v\<((script|style|area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold'],
|
||||
\ },
|
||||
\ 'lua': {
|
||||
\ 'parentheses': ["start=/(/ end=/)/", "start=/{/ end=/}/", "start=/\\v\\[\\ze($|[^[])/ end=/\\]/"],
|
||||
\ },
|
||||
\ 'perl': {
|
||||
\ 'syn_name_prefix': 'perlBlockFoldRainbow',
|
||||
\ },
|
||||
\ 'php': {
|
||||
\ 'syn_name_prefix': 'phpBlockRainbow',
|
||||
\ 'contains_prefix': '',
|
||||
\ 'parentheses': ['start=/(/ end=/)/ containedin=@htmlPreproc contains=@phpClTop', 'start=/\[/ end=/\]/ containedin=@htmlPreproc contains=@phpClTop', 'start=/{/ end=/}/ containedin=@htmlPreproc contains=@phpClTop', 'start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold contains_prefix=TOP'],
|
||||
\ },
|
||||
\ 'stylus': {
|
||||
\ 'parentheses': ['start=/{/ end=/}/ fold contains=@colorableGroup'],
|
||||
\ },
|
||||
\ 'css': 0,
|
||||
\ 'sh': 0,
|
||||
\ 'vimwiki': 0,
|
||||
\ }
|
||||
\}
|
||||
|
||||
fun s:eq(x, y)
|
||||
return type(a:x) == type(a:y) && a:x == a:y
|
||||
endfun
|
||||
|
||||
fun s:gcd(a, b)
|
||||
let [a, b, t] = [a:a, a:b, 0]
|
||||
while b != 0
|
||||
let t = b
|
||||
let b = a % b
|
||||
let a = t
|
||||
endwhile
|
||||
return a
|
||||
endfun
|
||||
|
||||
fun s:lcm(a, b)
|
||||
return (a:a / s:gcd(a:a, a:b)) * a:b
|
||||
endfun
|
||||
|
||||
fun rainbow_main#gen_config(ft)
|
||||
let g = exists('g:rainbow_conf')? g:rainbow_conf : {}
|
||||
"echom 'g:rainbow_conf:' string(g)
|
||||
let s = get(g, 'separately', {})
|
||||
"echom 'g:rainbow_conf.separately:' string(s)
|
||||
let dft_conf = extend(copy(s:rainbow_conf), g) | unlet dft_conf.separately
|
||||
"echom 'default config options:' string(dft_conf)
|
||||
let dx_conf = s:rainbow_conf.separately['*']
|
||||
"echom 'default star config:' string(dx_conf)
|
||||
let ds_conf = get(s:rainbow_conf.separately, a:ft, dx_conf)
|
||||
"echom 'default separately config:' string(ds_conf)
|
||||
let ux_conf = get(s, '*', ds_conf)
|
||||
"echom 'user star config:' string(ux_conf)
|
||||
let us_conf = get(s, a:ft, ux_conf)
|
||||
"echom 'user separately config:' string(us_conf)
|
||||
let af_conf = (s:eq(us_conf, 'default') ? ds_conf : us_conf)
|
||||
"echom 'almost finally config:' string(af_conf)
|
||||
if s:eq(af_conf, 0)
|
||||
return 0
|
||||
else
|
||||
let conf = extend(extend({'syn_name_prefix': substitute(a:ft, '\v\A+(\a)', '\u\1', 'g').'Rainbow'}, dft_conf), af_conf)
|
||||
let conf.cycle = (has('gui_running') || (has('termguicolors') && &termguicolors)) ? s:lcm(len(conf.guifgs), len(conf.guis)) : s:lcm(len(conf.ctermfgs), len(conf.cterms))
|
||||
return conf
|
||||
endif
|
||||
endfun
|
||||
|
||||
fun rainbow_main#gen_configs(ft)
|
||||
return filter(map(split(a:ft, '\v\.'), 'rainbow_main#gen_config(v:val)'), 'type(v:val) == type({})')
|
||||
endfun
|
||||
|
||||
fun rainbow_main#load()
|
||||
let b:rainbow_confs = rainbow_main#gen_configs(&filetype)
|
||||
for conf in b:rainbow_confs
|
||||
call rainbow#syn(conf)
|
||||
call rainbow#hi(conf)
|
||||
endfor
|
||||
endfun
|
||||
|
||||
fun rainbow_main#clear()
|
||||
if !exists('b:rainbow_confs') | return | endif
|
||||
for conf in b:rainbow_confs
|
||||
call rainbow#hi_clear(conf)
|
||||
call rainbow#syn_clear(conf)
|
||||
endfor
|
||||
unlet b:rainbow_confs
|
||||
endfun
|
||||
|
||||
fun rainbow_main#toggle()
|
||||
if exists('b:rainbow_confs')
|
||||
call rainbow_main#clear()
|
||||
else
|
||||
call rainbow_main#load()
|
||||
endif
|
||||
endfun
|
||||
|
18
bundle/rainbow/doc/rainbow.txt
Normal file
18
bundle/rainbow/doc/rainbow.txt
Normal file
@ -0,0 +1,18 @@
|
||||
Rainbow Parentheses Improved *rainbow*
|
||||
==========================================================================
|
||||
|
||||
Commands: *rainbow-commands*
|
||||
--------------------------------------------------------------------------
|
||||
|
||||
*RainbowToggle* --- toggle this plugin on/off
|
||||
*RainbowToggleOn* --- toggle this plugin on
|
||||
*RainbowToggleOff* --- toggle this plugin off
|
||||
|
||||
Configurations: *rainbow-config*
|
||||
--------------------------------------------------------------------------
|
||||
|
||||
*g:rainbow_active* --- 1 to auto enable this plugin
|
||||
0 to enable it later via :RainbowToggle
|
||||
*g:rainbow_conf* --- https://github.com/luochen1990/rainbow#configure
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
16
bundle/rainbow/plugin/rainbow_main.vim
Normal file
16
bundle/rainbow/plugin/rainbow_main.vim
Normal file
@ -0,0 +1,16 @@
|
||||
" Copyright 2013 LuoChen (luochen1990@gmail.com). Licensed under the Apache License 2.0.
|
||||
|
||||
if exists('s:loaded')
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:loaded = 1
|
||||
|
||||
command! RainbowToggle call rainbow_main#toggle()
|
||||
command! RainbowToggleOn call rainbow_main#load()
|
||||
command! RainbowToggleOff call rainbow_main#clear()
|
||||
|
||||
if (exists('g:rainbow_active') && g:rainbow_active)
|
||||
auto syntax * call rainbow_main#load()
|
||||
auto colorscheme * call rainbow_main#load()
|
||||
endif
|
11
bundle/rainbow/tests/test.c
Normal file
11
bundle/rainbow/tests/test.c
Normal file
@ -0,0 +1,11 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typoo
|
||||
(typoo)
|
||||
|
||||
int main() {
|
||||
printf("hello, world");
|
||||
return 0;
|
||||
}
|
3
bundle/rainbow/tests/test.css
Normal file
3
bundle/rainbow/tests/test.css
Normal file
@ -0,0 +1,3 @@
|
||||
div {
|
||||
color: red
|
||||
}
|
14
bundle/rainbow/tests/test.csv
Normal file
14
bundle/rainbow/tests/test.csv
Normal file
@ -0,0 +1,14 @@
|
||||
a,b,c,d
|
||||
1,2,3,4
|
||||
1,,3,4
|
||||
1,,,4
|
||||
1 , , , 4
|
||||
1,2,3,4,5
|
||||
1, 2, 3, 4
|
||||
1 ,2 ,3, 4, 5
|
||||
1 , 2 , 3 , 4
|
||||
1 , 2 , 3 , 4
|
||||
1, 3
|
||||
1,2,3
|
||||
1,3,4,5
|
||||
|
|
4
bundle/rainbow/tests/test.go
Normal file
4
bundle/rainbow/tests/test.go
Normal file
@ -0,0 +1,4 @@
|
||||
typoo
|
||||
(typoo)
|
||||
|
||||
client := &http.Client{}
|
5
bundle/rainbow/tests/test.hs
Normal file
5
bundle/rainbow/tests/test.hs
Normal file
@ -0,0 +1,5 @@
|
||||
{- this is a comment block -}
|
||||
|
||||
xs = [1, 2, 3]
|
||||
ps = [(1, 2), (3, 1 / 4)]
|
||||
|
22
bundle/rainbow/tests/test.html
Normal file
22
bundle/rainbow/tests/test.html
Normal file
@ -0,0 +1,22 @@
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
h1 {color:red;}
|
||||
p {color:blue;}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<img />
|
||||
(1 + (2 + 3))
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var foo = true;
|
||||
if (foo) {
|
||||
alert("hey");
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
8
bundle/rainbow/tests/test.html.txt
Normal file
8
bundle/rainbow/tests/test.html.txt
Normal file
@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<div>
|
||||
<img />
|
||||
(1 + (2 + 3))
|
||||
</div>
|
||||
</html>
|
||||
|
||||
<!-- vim: set ft=html.txt : -->
|
5
bundle/rainbow/tests/test.js
Normal file
5
bundle/rainbow/tests/test.js
Normal file
@ -0,0 +1,5 @@
|
||||
typoo
|
||||
(typoo)
|
||||
|
||||
console.log({w: 200, h: 100, pos: [{x: 1, y: 2}, {x: 3, y: 4}]})
|
||||
|
12
bundle/rainbow/tests/test.lua
Normal file
12
bundle/rainbow/tests/test.lua
Normal file
@ -0,0 +1,12 @@
|
||||
(function(args)
|
||||
lst = { a=function(arg) print("hello") end,
|
||||
b=(1+2)*3/4,
|
||||
[3+5]={ ["hello"]=("hi") },
|
||||
}
|
||||
lst[
|
||||
(function() return 0 end)()] = 1
|
||||
end)("blah")
|
||||
|
||||
[[
|
||||
Special lua string...
|
||||
]]
|
13
bundle/rainbow/tests/test.php
Normal file
13
bundle/rainbow/tests/test.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
if ($_FILES["file"]["error"] > 0)
|
||||
{
|
||||
echo "Error: " . $_FILES["file"]["error"] . "<br />";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
|
||||
}
|
||||
?>
|
||||
<html>
|
||||
hello (world)
|
||||
</html>
|
10
bundle/rainbow/tests/test.pl
Normal file
10
bundle/rainbow/tests/test.pl
Normal file
@ -0,0 +1,10 @@
|
||||
typoo
|
||||
(typoo)
|
||||
|
||||
sub test {
|
||||
correct indent;
|
||||
}
|
||||
|
||||
if ($test) {
|
||||
incorrect indent;
|
||||
}
|
15
bundle/rainbow/tests/test.rb
Normal file
15
bundle/rainbow/tests/test.rb
Normal file
@ -0,0 +1,15 @@
|
||||
{{{}}}
|
||||
((()))
|
||||
[[[]]]
|
||||
[[[[]]]]
|
||||
|
||||
def sample_function(a, b)
|
||||
((()))
|
||||
[[[]]]
|
||||
end
|
||||
|
||||
class SampleClass
|
||||
def sample_method(a, b)
|
||||
[[[]]]
|
||||
end
|
||||
end
|
52
bundle/rainbow/tests/test.sh
Normal file
52
bundle/rainbow/tests/test.sh
Normal file
@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
typoo
|
||||
(typoo)
|
||||
|
||||
if stuff
|
||||
then
|
||||
somestuff
|
||||
test = (())
|
||||
(())
|
||||
a = (1 + (2 + 3))
|
||||
if
|
||||
then
|
||||
elif
|
||||
then
|
||||
else
|
||||
fi
|
||||
else
|
||||
otherstuff
|
||||
fi
|
||||
|
||||
if stuff
|
||||
then
|
||||
somestuff
|
||||
else
|
||||
otherstuff
|
||||
fi
|
||||
|
||||
function f() {
|
||||
if
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# check if command exists
|
||||
command_exists () {
|
||||
type "${1}" > /dev/null 2>&1;
|
||||
a = (1 + (2 + 3))
|
||||
}
|
||||
|
||||
# Fetch the update
|
||||
fetch() {
|
||||
if type wget > /dev/null 2>&1 ; then
|
||||
$debug && echo "fetching update via wget"
|
||||
wget --no-check-certificate -O "${2}" "${1}" >/dev/null 2>&1
|
||||
elif type curl > /dev/null 2>&1 ; then
|
||||
$debug && echo "fetching update via curl"
|
||||
curl --insecure --remote-name -o "${2}" "${1}" >/dev/null 2>&1
|
||||
else
|
||||
echo 'Warning: Neither wget nor curl is available. online updates unavailable' >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
5
bundle/rainbow/tests/test.special-ft
Normal file
5
bundle/rainbow/tests/test.special-ft
Normal file
@ -0,0 +1,5 @@
|
||||
(((())))
|
||||
[[[[]]]]
|
||||
{{{{}}}}
|
||||
|
||||
# vim: set ft=this-is-a--very-SPECIAL-filetype :
|
3
bundle/rainbow/tests/test.styl
Normal file
3
bundle/rainbow/tests/test.styl
Normal file
@ -0,0 +1,3 @@
|
||||
div {
|
||||
color: red
|
||||
}
|
11
bundle/rainbow/tests/test.tex
Normal file
11
bundle/rainbow/tests/test.tex
Normal file
@ -0,0 +1,11 @@
|
||||
\documentclass[]{article}
|
||||
|
||||
{{{{}}}}
|
||||
((((((()))))))
|
||||
[[[[[[]]]]]]
|
||||
\begin{document}
|
||||
((((()))))
|
||||
${{{{}}}}$
|
||||
{{{{}}}}
|
||||
[[[[[[]]]]]]
|
||||
\end{document}
|
6
bundle/rainbow/tests/test.xml
Normal file
6
bundle/rainbow/tests/test.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<html>
|
||||
<div>
|
||||
<img />
|
||||
</div>
|
||||
</html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user