rainbow-delimiters.nvim-v0.10.0/ 0000775 0000000 0000000 00000000000 15066556776 0016555 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/.busted 0000664 0000000 0000000 00000003430 15066556776 0020044 0 ustar 00root root 0000000 0000000 -- SPDX-License-Identifier: Unlicense
-- This is free and unencumbered software released into the public domain.
--
-- Anyone is free to copy, modify, publish, use, compile, sell, or distribute
-- this software, either in source code form or as a compiled binary, for any
-- purpose, commercial or non-commercial, and by any means.
--
-- In jurisdictions that recognize copyright laws, the author or authors of
-- this software dedicate any and all copyright interest in the software to
-- the public domain. We make this dedication for the benefit of the public
-- at large and to the detriment of our heirs and successors. We intend this
-- dedication to be an overt act of relinquishment in perpetuity of all
-- present and future rights to this software under copyright law.
--
-- 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 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.
--
-- For more information, please refer to
return {
_all = {
coverage = false,
lua = './test/bin/lua',
['exclude-tags'] = {'skip'},
},
default = {
verbose = true,
},
unit = {
ROOT = {'./test/unit/'},
},
e2e = {
ROOT = {'./test/e2e/'},
pattern = '', -- No fancy names for E2E tests
},
highlight = {
ROOT = {'./test/highlight/busted.lua'},
pattern = '', -- No fancy names for highlight tests
},
query = {
ROOT = {'./test/query/busted.lua'},
pattern = '', -- No fancy names for query tests
},
}
-- vim:ft=lua
rainbow-delimiters.nvim-v0.10.0/.editorconfig 0000664 0000000 0000000 00000000270 15066556776 0021231 0 ustar 00root root 0000000 0000000 root = true
[*]
indent_size = tab
tab_width = 4
end_of_line = lf
insert_final_newline = true
charset = utf-8
[*.lua]
indent_style = tab
[*.scm]
indent_style = space
indent_size = 2
rainbow-delimiters.nvim-v0.10.0/.github/ 0000775 0000000 0000000 00000000000 15066556776 0020115 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/.github/ISSUE_TEMPLATE/ 0000775 0000000 0000000 00000000000 15066556776 0022300 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/.github/ISSUE_TEMPLATE/bug-report.yml 0000664 0000000 0000000 00000001774 15066556776 0025122 0 ustar 00root root 0000000 0000000 name: Bug Report
description: File a bug report
title: "[Bug]: "
labels: ["bug"]
assignees:
- "HiPhish"
body:
- type: 'input'
attributes:
label: 'Neovim version'
description: 'Version of your Neovim'
placeholder: '0.0.0'
- type: 'input'
attributes:
label: 'Language affected'
description: 'Leave empty if you experience the issue with any file type.'
placeholder: 'Lua'
- type: 'input'
attributes:
label: 'Query'
description: 'Leave empty if the issue is not tied to a specific query.'
placeholder: 'rainbow-delimiters'
- type: 'input'
attributes:
label: 'Strategy'
description: 'Leave empty if the issue is not tied to a specific strategy.'
placeholder: 'global'
- type: 'textarea'
attributes:
label: 'Description'
description: |
Please describe the bug in detail here. If possible provide a minimal
code sample which replicates the issue
placeholder: 'print((("Hello world!")))'
rainbow-delimiters.nvim-v0.10.0/.github/ISSUE_TEMPLATE/config.yml 0000664 0000000 0000000 00000000310 15066556776 0024262 0 ustar 00root root 0000000 0000000 blank_issues_enabled: true
contact_links:
- name: Main repoo
url: 'https://gitlab.com/HiPhish/rainbow-delimiters.nvim'
about: 'Upstream repository; you can also report bugs here on GitHub.'
rainbow-delimiters.nvim-v0.10.0/.gitignore 0000664 0000000 0000000 00000000730 15066556776 0020545 0 ustar 00root root 0000000 0000000 # Hack: because most plugin managers will try to automatically download
# submodules I have renamed the `.gitmodules` file. Contributors will have to
# symlink the `.submodules` file to `.gitmodules` before they can use submodule
# commands
# Tag file created by Vim
doc/tags
# Fake user directory structures
test/xdg/local/share/nvim/
test/xdg/local/state/nvim/
!test/xdg/local/share/nvim/site/pack/testing/start/rainbow-delimiters
test/highlight/samples/gleam/build
rainbow-delimiters.nvim-v0.10.0/.gitlab/ 0000775 0000000 0000000 00000000000 15066556776 0020075 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/.gitlab/issue_templates/ 0000775 0000000 0000000 00000000000 15066556776 0023303 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/.gitlab/issue_templates/bug-report.md 0000664 0000000 0000000 00000000266 15066556776 0025717 0 ustar 00root root 0000000 0000000 - Neovim version:
- Language affected:
- Query used:
- Strategy used:
Please describe the bug in detail here. If possible provide a minimal code
sample which replicates the issue.
rainbow-delimiters.nvim-v0.10.0/.gitmodules 0000664 0000000 0000000 00000001076 15066556776 0020736 0 ustar 00root root 0000000 0000000 # This file would normally be named `.gitmodules`, but I have intentionally
# renamed it to prevent Neovim plugin managers from picking up on it. This
# avoids the problem where the submodules would get installed for users of the
# plugin.
[submodule ".luals/addons/luassert"]
path = .luals/addons/luassert
url = https://github.com/LuaCATS/luassert
[submodule ".luals/addons/busted"]
path = .luals/addons/busted
url = https://github.com/LuaCATS/busted
[submodule "test/bin"]
path = test/bin
url = https://gitlab.com/HiPhish/nvim-busted-shims.git
# vim:ft=gitconfig
rainbow-delimiters.nvim-v0.10.0/.luals/ 0000775 0000000 0000000 00000000000 15066556776 0017753 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/.luals/meta/ 0000775 0000000 0000000 00000000000 15066556776 0020701 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/.luals/meta/busted.lua 0000664 0000000 0000000 00000000331 15066556776 0022667 0 ustar 00root root 0000000 0000000 ---@meta
---@class luassert.custom
local custom = {}
---A remote Neovim process controlled by yo-dawg.nvim
---@param nvim table
---@return table
function custom.remote(nvim) end
---@class luassert: luassert.custom
rainbow-delimiters.nvim-v0.10.0/.luarc.json 0000664 0000000 0000000 00000000515 15066556776 0020635 0 ustar 00root root 0000000 0000000 {
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
"runtime.path": ["?.lua"],
"workspace.ignoreDir": ["test/xdg"],
"workspace.ignoreSubmodules": false,
"workspake.userThirdParty": [
".luals/addons"
],
"workspace.library": [
".luals/addons/luassert/library",
".luals/meta"
]
}
rainbow-delimiters.nvim-v0.10.0/.nvimrc 0000664 0000000 0000000 00000000133 15066556776 0020051 0 ustar 00root root 0000000 0000000 " Use the custom shim as the busted binary for testing
let g:bustedprg='./test/bin/busted'
rainbow-delimiters.nvim-v0.10.0/CHANGELOG.rst 0000664 0000000 0000000 00000000216 15066556776 0020575 0 ustar 00root root 0000000 0000000 .. default-role:: code
The changelog is in `doc/news.txt`_; you can read it from within Neovim by
executing `:help rainbow-delimiters-news`.
rainbow-delimiters.nvim-v0.10.0/CONTRIBUTING.rst 0000664 0000000 0000000 00000003725 15066556776 0021225 0 ustar 00root root 0000000 0000000 .. default-role:: code
#####################
Contributor's guide
#####################
Developer's setup
#################
You will need the following on your system:
- `tree-sitter` CLI tool
- LuaRocks_
- `busted` installed from LuaRocks for Lua 5.1
Next, install the development dependencies from Git submodules.
.. code:: sh
git submodule init
git submodule update --checkout
The first test run will install and compile Tree-sitter parsers as needed,
which may take a while.
Adding support for a new language
#################################
Languages are supported through language-specific queries. Each language needs
at lease one query which matches the most common delimiters, usually `(`, `)`,
`[`, `]`, `{`, `}`, `<` and `>`. Read `:h rb-delimiters-custom-query` in the
manual first to understand how to write queries. Your query should meet the
following criteria:
- Named `rainbow-delimiters`
- Few `@delimiter` capture groups per `@container`; we do not want the default
query to be too vibrant
- Write one or more files in the language under `test/highlight/` (where
`` is the language); the standard file name is `regular.`
- The test code must have at least one instance of each pattern in the query
- The test code must not have parsing errors
- The test code should ideally have multiple levels of nesting
- The test code should compile and have no linter errors if that is feasible
(this is not a hard rule though)
If there are many test cases or if the code becomes too verbose feel free to
create multiple test files.
In addition to the queries and test file(s), please consider adding the type
annotations in `lua/rainbow-delimiters.types.lua` if you are adding queries
for a new language. You will need to update:
- `@class rainbow_delimiters.config.strategies`
- `@class rainbow_delimiters.config.queries`
- `@class rainbow_delimiters.config.priorities`
- `@alias rainbow_delimiters.language`
.. _LuaRocks: https://luarocks.org/
rainbow-delimiters.nvim-v0.10.0/HACKING.rst 0000664 0000000 0000000 00000043011 15066556776 0020352 0 ustar 00root root 0000000 0000000 .. default-role:: code
#################################
Hacking on Rainbow Delimiters 2
#################################
Testing
#######
A test setup must meet the following criteria:
- Test definitions must be run by with Neovim as the Lua interpreter to get
access to all Neovim APIs
- Tests must not be affected by the user's own plugins and configuration
- Each test which mutates editor state must run in its own Neovim process
The first two points are achieved through a small command-line interface
adapter script (a shim). The shim exposes the command-line interface of a Lua
interpreter, and internally it sets up environment variable to point Neovim at
a prepared blank directory structure. Neovim is then called with the `-l`
flag.
We do have to use some plugins though:
- This plugin itself
- nvim-treesitter_ to install parsers for some languages
Both plugins are stored under the `$XDG_DATA_HOME` directory, the former as a
symlink and the latter as a Git submodule.
As for process isolation, this is achieved inside the tests. We start a
headless embedded Neovim instance which we control through MsgPack RPC from
inside the test. We can control and probe this process only indirectly, which
is awkward, but this is the best solution I could find.
Unit testing
============
We use busted_ for unit testing. A unit is a self-contained module which can
be used on its own independent of the editor. Execute `make unit-test` to run
unit tests. The `busted` binary must be available on the system `$PATH`.
End to end testing
==================
End-to-end tests run in a separate Neovim instance which we control via RPC.
These are tests which mutate the state of the editor, such as adding
highlighting on changes. Execute `make e2e-test` to run all end to end tests.
Running tests with Neotest-busted
=================================
To run tests the `g:bustedprg` variable must be set to `'./test/busted'`, which
is the path to the shim script. If the `exrc` option is set the variable will
be set automatically.
Highlight testing
=================
Highlights are tested by comparing the current highlights of a sample file with
previously recorded highlights known to be correct. Of course this does
nothing when defining new patterns or making changes to a sample file; in this
case a human has to initially approve of the highlighting. Once that is done
the current state can be recorded. Automated highlighting tests are useful
when making changes to the highlighting logic itself to ensure the results
remain unchanged.
Execute `make highlight-test` to run highlighting tests.
Definitions
-----------
Sample file
A file in the language we want to highlight. The contents have to be
syntactically correct, and ideally the file should compile, but it does not
have to make sense. Sample files are stored under an arbitrary name
(although `regular` is the most common) in `test/highlight/samples/`.
Specification or spec
A Lua file which records all rainbow delimiter extmarks for a given
combination of sample file and query. Why Lua? It could have been JSON,
but generating nicely formatted Lua was simpler, that's all. Each spec is
just a table, there is no logic.
Recording
The act of reading a sample file, extracting all highlighting information
and writing it to a spec. You could write all the specs by hand, but there
is a helper function for that instead.
Recording highlighting
----------------------
First make the necessary changes to the sample file or query. Then build the
`record-highlight` target in the makefile and pass the language as a variable.
.. code:: sh
make record-highlight LANGUAGE=lua
Running highlight tests
-----------------------
Build the `highlight-test` target.
Design decisions
################
Tables over strings for configuration
=====================================
Strategies are given as a complex table, but a string identifier would have
been much more pleasant on the eye. Which of these two is easier to read and
write?
.. code:: lua
-- This?
settings = {
strategy = {
'global'
html = 'local'
}
}
-- Or this?
settings = {
strategy = {
require 'ts-rainbow.strategy.global'
html = require 'ts-rainbow.strategy.local'
}
}
Using strings might seem like the more elegant choice, but it it makes the code
more complicated to maintain and less flexible for the user. With tables a
user can create a new custom strategy and assign it directly without the need
to "register" them first under some name.
More importantly though, we have unlimited freedom where that table is coming
from. Suppose we wanted to add settings to a strategy. With string
identifiers we now need much more machinery to connect a string identifier and
its settings. On the other hand, we can just call a function with the settings
are arguments which returns the strategy table.
.. code:: lua
settings = {
strategy = {
require 'ts-rainbow.strategy.global',
-- Function call evaluates to a strategy table
latext = my_custom_strategy {
option_1 = true,
option_2 = 'test'
}
}
}
Strategies
##########
On container nodes
==================
Every query has to define a `container` capture in addition to `opening` and
`closing` captures. As humans we understand the code at an abstract level, but
Tree-sitter works on a more concrete level. To a human the HTML tag `
` is
one atomic object, but to Tree-sitter it is actually a container with further
elements.
Consider the following HTML snippet:
.. code:: html
Hello
The tree looks like this (showing anonymous nodes):
.. code::
element [0, 0] - [2, 6]
start_tag [0, 0] - [0, 5]
"<" [0, 0] - [0, 1]
tag_name [0, 1] - [0, 4]
">" [0, 4] - [0, 5]
text [1, 1] - [1, 6]
end_tag [2, 0] - [2, 6]
"" [2, 0] - [2, 2]
tag_name [2, 2] - [2, 5]
">" [2, 5] - [2, 6]
We want to highlight the lower-level nodes like `tag_name` or `start_tag` and
`end_tag`, but we want to base our logic on the higher-level nodes like
`element`. The `@container` node will not be highlighted, we use it to
determine the nesting level or the relationship to other container nodes.
Determining the level of container node
=======================================
In order to correctly highlight containers we need to know the nesting level of
each container relative to the other containers in the document. We can use
the order in which matches are returned by the `iter_matches` method of a
query. The iterator traverses the document tree in a depth-first manner
according to the visitor patter, but matches are created whenever the match is
complete. This happens upon exiting the node if the child nodes are sandwiched
in-between delimiters, as is the case with delimiters like parentheses or
`begin`/`end` blocks. However, if the child nodes are outside the delimiters
(e.g. when using Python keywords like `def` or `while` as delimiters) the child
nodes are not sandwiched between delimiters and the match will be returned upon
entering the node.
Sandwiching delimiters
----------------------
Let us look at a practical example. Here is a hypothetical tree:
.. code::
A
├─B
│ └─C
│ └─D
└─E
├─F
└─G
The nodes are returned in the following order:
#) D
#) C
#) B
#) F
#) G
#) E
#) A
We can only know how deeply nodes are nested relative to one another. We need
to build the entire tree structure to know the absolute nesting levels. Here
is an algorithm which can build up the tree, it uses the fact that the order of
nodes never skips over an ancestor.
Start with an empty stack `s = []`. For each match `m` do the following:
#) Keep popping matches off `s` up until we find a match `m'` whose
`@container` node is not a descendant of the container node of `m`. Collect
the popped matches (excluding `m'`) onto a new set `s_m` (order does not
matter)
#) Set `s_m` as the child match set of `m`
#) Add `m` to `s`
Eventually `s` will only contain root-level matches, i.e. matches of nesting
level one. To apply the highlighting we can then traverse the match tree,
incrementing the highlighting level by one each time we descend a level.
The order of matches among siblings in the tree does not matter. The stack
`s` is important for determining the relationship between nodes: since we know
that no ancestors will be skipped we can be certain that we can stop checking
the stack for descendants of `m` once we encounter the first non-descendant
match. Otherwise we would have to compare each match with each other match,
which would tank the performance.
Here is a step-by-step illustration of the algorithm applied to the above
example. The left-hand side is the current stack (with the bottom of the stack
on the left) and current node, the right-hand side is the resulting stack for
that iteration. If a match has no children I have omitted the braces for
brevity.
+-------------------------+-------+--------------------------------------------+
| Current stack | Match | New stack and popped-of match |
+=========================+=======+============================================+
| `[]` | `D` | `[D]` |
+-------------------------+-------+--------------------------------------------+
| `[D]` | `C` | `[]`, `C{D}` |
| | +--------------------------------------------+
| | | `[C{D}]` |
+-------------------------+-------+--------------------------------------------+
| `[C{D}]` | `B` | `[]`, `B{C{D}}` |
| | +--------------------------------------------+
| | | `[B{C{D}}]` |
+-------------------------+-------+--------------------------------------------+
| `[B{C{D}}]` | `F` | `[B{C{D}}, F]` |
+-------------------------+-------+--------------------------------------------+
| `[B{C{D}}, F]` | `G` | `[B{C{D}}, F, G]` |
+-------------------------+-------+--------------------------------------------+
| `[B{C{D}}, F, G]` | `E` | `[B{C{D}}, F]`, `E{G}` |
| | +--------------------------------------------+
| | | `[B{C{D}}]`, `E{G, F}` |
| | +--------------------------------------------+
| | | `[B{C{D}}, E{F, G}]` |
+-------------------------+-------+--------------------------------------------+
| `[B{C{D}}, E{F, G}]` | `A` | `[B{C{D}}]`, `A{E{F, G}}` |
| | +--------------------------------------------+
| | | `[]`, `A{B{C{D}}, E{F, G}}` |
| | +--------------------------------------------+
| | | `[A{B{C{D}}, E{F, G}}]` |
+-------------------------+-------+--------------------------------------------+
| `[A{B{C{D}}, E{F, G}}]` |
+------------------------------------------------------------------------------+
Without sandwiching
-------------------
In some languages like Python it makes sense to define block-level delimiters
which have only one delimiter. Here is an example:
.. code:: python
def derp():
for (k, v) in {'a': 1, 'b': 2}:
print(k, v)
We want to highlight the `def` of the function definition and the `for`/`in` of
the loop. This means we have a mix of sandwiching and no sandwiching. The
order of matches is:
#) `def` (because it is completed first)
#) `()` (the parentheses of `def`)
#) `(k, v)` (because it is completed before `for`/`in`)
#) `for`/`in`
#) `{...}`
#) `print(k, v)`
The intended match tree should look like this according to the syntax tree:
.. code::
def
├ ()
└ for/in
├ (k, v)
├ {...}
└ print(k, v)
Eyeballing the code however suggest a match tree like this:
.. code::
├def
└ ()
├ for/in
│ ├ (k, v)
│ └ print(k, v)
└ {...}
The idea is that matches which logicaly appear together (such as the head of a
for-loop) should be cousins. This raises the question of what belongs
together. I will probably need to add a new capture like `@body` which matches
the delimited content. In the sandwich case the body was implicitly that which
is between both delimiters, but here we would need to be explicit about it.
Example:
.. code:: query
(for_statement
"for" @delimiter
"in" @delimiter
body: _ @body) @container
(list
"[" @delimiter
_ @body
"]" @delimiter) @container
Then a match is a child of a parent if and only if the `@container` of the
child is contained inside the `@body` of the parent.
Not only can the parent-child order be reversed, we can also skip over
generations. In the above example `(k, v)` is a grandchild of `def`, but it
comes directly after it. We need to revise the algorithm to account for this
case. All in all we have the following cases:
- The new node and the top of the stack are cousins
- The new node is an ancestor of the top node
- The new node is a descendant of the top node
Here the term “cousin” is cross-generational, i.e. if A is the parent of B and
C, and D the child of C, then B and D are considered cousins. They have a
common ancestor, but share no lineage from one to the other. Siblings are also
considered cousins.
The local highlight strategy
============================
Consider the following bit of contrived HTML code:
.. code:: html
Supposed the cursor was inside the angle brackets of `Bravo`, which tags
should we highlight? From eyeballing the obvious answer is `Alpha`, `Bravo`
and `Charlie`. Obviously `Alpha` and `Bravo` both contain the cursor within
the range, but how do we know that we need to highlight `Charlie`? `Charlie`
is contained inside `Bravo`, which contains the cursor, but on the other hand
`Delta` is contained inside `Alpha`, which also contains the cursor. We cannot
simply check whether the parent contains the cursor.
When working with the Tree-sitter API and iterating through matches and
captures we have no way of knowing that any of the captures within `Charlie`
are contained within `Bravo`. However, due to the order of traversal we do
know that `Bravo` is the lowest node to still contain the cursor.
Therefore we that the first match which contains the cursor is the lowest one.
If a match does not contain the cursor we can check whether it is a
descendant of the cursor container match.
The problem with nested languages
#################################
The language tree of a buffer is a tree of parsers. Some languages like
Markdown can contain other languages, which complicates things.
Foreign extmarks
================
Extmarks move along with the text they belong to. This is generally a good
thing, but it can become a problem if we move text from one language to
another. Consider the following Markdown code:
.. code:: markdown
Hello world
```lua
print {{{{}}}}
print {{{{}}}}
```
We can move the cursor to line 4 and move that line out of the Lua block by
executing `:move 1` to move it to the second line. However, this will preserve
the extmarks and we will end up with Lua delimiter highlighting inside
Markdown.
My solution is on every change to delete all rainbow delimiter extmarks which
do not belong to the current language.
Overwritten extmarks
====================
Take the following Markdown code:
.. code:: markdown
Hello world
```c
puts("This is an injected language")
{
{
{
{
{
return ((((((2)))))) + ((((3))))
}
}
}
}
}
```
If we put the cursor on the line with the `puts` statement and move it up one
line (`:move -2`) we get the following changes:
- Markdown
- `{ 2, 0, 3, 0 }`
This means lines 3 and 4 of the Markdown tree have changed; we have changed the
contents of the fifth line and added one more line. This is all as expected.
However, let us now move the line back down by executing `:move +1`. We get
the following changes:
- Markdown
- `{ 3, 0, 15, 0 }`
- C
- `{ 3, 0, 4, 0 }`
The changes to the C tree are what we expect. However, the changes to the
Markdown tree span the code block as well. This is a problem when we start
deleting foreign extmarks (see above). If we work from the outside we wipe out
all non-Markdown extmarks in the range, which includes the C extmarks. Then we
apply the C extmarks inside the C block, but the C change does not span the
entire C tree. Thus we will only apply highlighting to the changed C line, but
not the remainder of the C block.
The solution at the moment is to overwrite the changes of nested languages. If
the changes belong to a language tree with parent language we replace all the
changes with a range that spans the entire tree for that language.
.. _busted: https://lunarmodules.github.io/busted/#defining-tests
.. _nvim-treesitter: https://github.com/nvim-treesitter/nvim-treesitter
rainbow-delimiters.nvim-v0.10.0/LICENSE 0000664 0000000 0000000 00000026135 15066556776 0017571 0 ustar 00root root 0000000 0000000 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.
rainbow-delimiters.nvim-v0.10.0/README.rst 0000664 0000000 0000000 00000017034 15066556776 0020251 0 ustar 00root root 0000000 0000000 .. default-role:: code
###############################
Rainbow delimiters for Neovim
###############################
This Neovim plugin provides alternating syntax highlighting (“rainbow
parentheses”) for Neovim, powered by `Tree-sitter`_. The goal is to have a
hackable plugin which allows for different configuration of queries and
strategies, both globally and per file type. Users can override and extend the
built-in defaults through their own configuration.
This is a fork of `nvim-ts-rainbow2`_, which was implemented as a module for
`nvim-treessiter`_. However, since nvim-treesitter has deprecated the module
system I had to create this standalone plugin.
Installation and setup
######################
Installation
============
Install it like any other Neovim plugin; you do not need the Git submodules of
this repository. They are just used for development and won't cause any harm,
they will just bloat your setup.
You will need a Tree-sitter parser for each language you want to use rainbow
delimiters with.
Setup
=====
No configuration is needed to get started, this plugin has reasonable defaults
which you can override. Configuration is done by setting entries in the Vim
script dictionary `g:rainbow_delimiters`. Here is an example configuration:
.. code:: vim
let g:rainbow_delimiters = {
\ 'strategy': {
\ '': 'rainbow-delimiters.strategy.global',
\ 'vim': 'rainbow-delimiters.strategy.local'
\ },
\ 'query': {
\ '': 'rainbow-delimiters',
\ 'lua': 'rainbow-blocks',
\ },
\ 'priority': {
\ '': 110,
\ 'lua': 210,
\ },
\ 'highlight': [
\ 'RainbowDelimiterRed',
\ 'RainbowDelimiterYellow',
\ 'RainbowDelimiterBlue',
\ 'RainbowDelimiterOrange',
\ 'RainbowDelimiterGreen',
\ 'RainbowDelimiterViolet',
\ 'RainbowDelimiterCyan',
\ ],
\ }
The equivalent code in Lua:
.. code:: lua
---@type rainbow_delimiters.config
vim.g.rainbow_delimiters = {
strategy = {
[''] = 'rainbow-delimiters.strategy.global',
vim = 'rainbow-delimiters.strategy.local',
},
query = {
[''] = 'rainbow-delimiters',
lua = 'rainbow-blocks',
},
priority = {
[''] = 110,
lua = 210,
},
highlight = {
'RainbowDelimiterRed',
'RainbowDelimiterYellow',
'RainbowDelimiterBlue',
'RainbowDelimiterOrange',
'RainbowDelimiterGreen',
'RainbowDelimiterViolet',
'RainbowDelimiterCyan',
},
}
Please refer to the `manual`_ for more details. For those who prefer a `setup`
function there is the module `rainbow-delimiters.setup` that accepts all the
same parameters as `g:rainbow-delimiters`.
.. code:: lua
require('rainbow-delimiters.setup').setup {
strategy = {
-- ...
},
query = {
-- ...
},
highlight = {
-- ...
},
}
Help wanted
###########
There are only so many languages which I understand to the point that I can
write queries for them. If you want support for a new language please consider
contributing code. See the CONTRIBUTING_ for details.
Contributing
============
TL;DR: Run these steps first if you want to run tests:
.. code:: sh
ln -s .submodules .gitmodules
git submodule init
git submodule updated --checkout
To provide some context, there are dependencies needed to run tests. These are
included as Git submodules. The problem is that a number of package managers
will download submodules by default, which means that users will end up with a
bunch of stuff installed that they don't want. There is no way to tell Git to
use a different file, so we have to create a symbolic link instead if we
actually do want to download these submodules.
Status of the plugin
####################
Tree-sitter support in Neovim is still experimental. This plugin and its API
should be considered stable insofar as breaking changes will only happen if
changes to Neovim necessitates them.
License
#######
Licensed under the Apache-2.0 license. Please see the `LICENSE`_ file for
details.
Migrating from nvim-ts-rainbow2
###############################
Rainbow-Delimiters uses different settings than nvim-ts-rainbow2, but
converting the configuration is straight-forward. The biggest change is where
the settings are stored.
- Settings are stored in the global variable `g:rainbow-delimiters`, which has
the same keys as the old settings
- The default strategy and query have index `''` (empty string) instead of `1`
- Default highlight groups have the prefix `RainbowDelimiter` instead of
`TSRainbow`, e.g. `RainbowDelimiterRed` instead of `TSRainbowRed`
- The default query is now called `rainbow-delimiters` instead of
`rainbow-parens`
- The public Lua module is called `rainbow-delimiters` instead of `ts-rainbow`
The name of the default query is now `rainbow-delimiters` because for some
languages like HTML the notion of "parentheses" does not make any sense. In
HTML the only meaningful delimiter is the tag. Hence the generic notion of a
"delimiter".
Attribution
###########
This is a fork of a previous Neovim plugin, the original repository is
available under https://sr.ht/~p00f/nvim-ts-rainbow/.
Attributions from the original author
=====================================
Huge thanks to @vigoux, @theHamsta, @sogaiu, @bfredl and @sunjon and
@steelsojka for all their help
.. _Tree-sitter: https://tree-sitter.github.io/tree-sitter/
.. _nvim-treesitter: https://github.com/nvim-treesitter/nvim-treesitter
.. _CONTRIBUTING: CONTRIBUTING.rst
.. _LICENSE: LICENSE
.. _manual: doc/rainbow-delimiters.txt
.. _neovim/neovim#17099: https://github.com/neovim/neovim/pull/17099
.. _nvim-ts-rainbow2: https://gitlab.com/HiPhish/nvim-ts-rainbow2
.. _nvim-treessiter: https://github.com/nvim-treesitter/nvim-treesitter
Screenshots
###########
Bash
====
.. image:: https://github.com/HiPhish/rainbow-delimiters.nvim/assets/4954650/514ed2a2-68a4-427e-aef6-7ac3a02a2ba0
:alt: Screenshot of a Bash script with alternating coloured delimiters
C
=
.. image:: https://github.com/HiPhish/rainbow-delimiters.nvim/assets/4954650/45f8e727-d507-43df-b112-a269e7262533
:alt: Screenshot of a C program with alternating coloured delimiters
Common Lisp
===========
.. image:: https://github.com/HiPhish/rainbow-delimiters.nvim/assets/4954650/5e7e15bb-a4e3-41e5-b3fc-3c4150ffd252
:alt: Screenshot of a Common Lisp program with alternating coloured delimiters
HTML
====
.. image:: https://github.com/HiPhish/rainbow-delimiters.nvim/assets/4954650/371d310c-d5a7-490d-bb55-d3fe4bd8b1a8
:alt: Screenshot of an HTML document with alternating coloured delimiters
Java
====
.. image:: https://github.com/HiPhish/rainbow-delimiters.nvim/assets/4954650/bb372051-ec5f-4c0b-a9b9-3cd37edafa4f
:alt: Screenshot of a Java program with alternating coloured delimiters
LaTeX
=====
Using the `rainbow-blocks` query to highlight the entire `\begin` and `\end`
instructions.
.. image:: https://github.com/HiPhish/rainbow-delimiters.nvim/assets/4954650/0176cc0d-b729-417e-8f85-c31da70d49f5
:alt: Screenshot of a LaTeX document with alternating coloured delimiters
Lua
===
Using the `rainbow-blocks` query to highlight the entire keywords like
`function`, `if`, `else` and `end`.
.. image:: https://github.com/HiPhish/rainbow-delimiters.nvim/assets/4954650/a915f7e0-b1c9-4af2-ae1d-f2f48aa325e5
:alt: Screenshot of a Lua script with alternating coloured delimiters
rainbow-delimiters.nvim-v0.10.0/TODO.rst 0000664 0000000 0000000 00000002410 15066556776 0020051 0 ustar 00root root 0000000 0000000 .. default-role:: code
#######################
Plans for this plugin
#######################
Built-in queries
################
As of version 0.8.3 until (excluding) version 0.10.0 Neovim can only match one
node per query. This is a limitation of Neovim and there is nothing that could
be done on this end.
As of version 0.10.0 we could use `iter_matches` for highlighting.
As of version 0.10.0 updating the highlighting of a nested node is messed up.
This is because the undocumented behaviour of `iter_captures` was changed.
This is a good opportunity to switch back to `iter_matches`.
Insufficient information from parsers
#####################################
Some languages do not have a container node for parenthesized expressions,
which makes it impossible to write queries which can reliable determine
nesting. We can either just give up and not try or make a best-effort attempt
and if the highlighting messed up then so be it.
Affected languages:
- Elm
- SQL
- Vim script
Queries which I cannot port
===========================
I do not know enough about the following languages in order to write good
queries. Contributions are welcome.
- devicetree
- gdscript
- graphql
- meson
- ocaml
- ocaml_interface
- scala
- solidity
- sparql
- supercollider
- turtle
rainbow-delimiters.nvim-v0.10.0/autoload/ 0000775 0000000 0000000 00000000000 15066556776 0020365 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/autoload/rainbow_delimiters.vim 0000664 0000000 0000000 00000003626 15066556776 0024773 0 ustar 00root root 0000000 0000000 " Copyright 2023 Alejandro "HiPhish" Sanchez
"
" 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.
let g:rainbow_delimiters#strategy = {
\ 'global': luaeval("require 'rainbow-delimiters.strategy.global'"),
\ 'local': luaeval("require 'rainbow-delimiters.strategy.local'"),
\ 'noop': luaeval("require 'rainbow-delimiters.strategy.no-op'"),
\ }
" Get the appropriate highlight group for the given level of nesting.
function! rainbow_delimiters#hlgroup_at(i)
return luaeval("require('rainbow-delimiters').hlgroup_at(_A)", a:i)
endfunction
" Disable highlighting for the given buffer. Buffer number zero means current
" buffer.
function! rainbow_delimiters#disable(bufnr)
call luaeval("require('rainbow-delimiters').disable(_A)", a:bufnr)
endfunction
" Enable highlighting for the given buffer. Buffer number zero means current
" buffer.
function! rainbow_delimiters#enable(bufnr)
call luaeval("require('rainbow-delimiters').enable(_A)", a:bufnr)
endfunction
" Toggle highlighting for the given buffer. Buffer number zero means current
" buffer.
function! rainbow_delimiters#toggle(bufnr)
call luaeval("require('rainbow-delimiters').toggle(_A)", a:bufnr)
endfunction
" Check if highlighting is enabled for the given buffer. Buffer number zero
" means current buffer.
function! rainbow_delimiters#is_enabled(bufnr)
return luaeval("require('rainbow-delimiters').is_enabled(_A)", a:bufnr)
endfunction
" vim:tw=79:ts=4:sw=4:noet:
rainbow-delimiters.nvim-v0.10.0/doc/ 0000775 0000000 0000000 00000000000 15066556776 0017322 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/doc/news.txt 0000664 0000000 0000000 00000032367 15066556776 0021052 0 ustar 00root root 0000000 0000000 *rainbow-delimiters-news*
*rb-delimiters-news*
All notable changes to this project will be documented in this file. The
format is based on "Keep a Changelog" and this project adheres to "Semantic
Versioning".
https://keepachangelog.com/en/1.1.0/
https://semver.org/
==============================================================================
Version 0.10.0 (released on 2025-09-29)
FIXED
------------------------------------------------------------------------------
Highlighting disappearing when scrolling if the language has macros (e.g. C,
C++, Rust).
Replaced `verilog` with `systemverilog`.
Missing patters:
• LaTeX:
- `curly_group_label`
- `curly_group_label_list`
Fixed patterns:
• LaTeX:
- `curly_group_label` instead of `curly_group_text`
• Templ:
- Missing `script_tag_start` and `script_tag_end` nodes in
`script_element`
------------------------------------------------------------------------------
ADDED
New languages:
• F#
• GLSL
• Nu shell
• Yuck
Missing patterns:
• C++:
- `for_range_loop`
- `lambda_capture_specifier`
- `new_declarator`
• JavaScript:
- `computed_property_name`
• LaTeX:
- `brack_group_key_value`
- `curly_group`
- `curly_group_author_list`
- `curly_group_text_list`
- `curly_group_path`
- `curly_group_path_list`
- `label_definition`
- `math_delimiter`
• OCaml:
- `abstract_type`
- `function_expression`
- `let_expression`
- `let_module_expression`
- `let_open_expression`
- `package_pattern`
- `packed_module`
- `parameter`
- `polymorphic_variant_type`
- `type_binding`
• Python:
- `with_clause`
• TypeScript:
- `array_type`
- `tuple_type`
• Zig:
- `address_space`
- `byte_alignment`
- `error_set_declaration`
- `for_expression`
- `if_expression`
- `if_type_expression`
- `parenthesized_expression`
- `while_expression`
==============================================================================
Version 0.9.1 (released on 2025-03-23)
FIXED
------------------------------------------------------------------------------
Health check failing if a strategy was a string.
==============================================================================
Version 0.9.0 (released on 2025-03-17)
FIXED
------------------------------------------------------------------------------
Fixed patterns:
• Templ:
- Missing `style_tag_start` and `style_tag_end` nodes in
`style_element`
• Perl:
- All patterns were obsolete
------------------------------------------------------------------------------
ADDED
New languages:
• Gleam
• Groovy
• KDL
• OCaml
Missing patterns:
• C++:
- `enumerator_list`
• Java:
- `switch_block`
• Query:
- `missing_node`
Other:
• Strategies in configuration may be strings
• Built-in stategies can be referenced via their module strings (see
|rb-delimiters-strategy|)
------------------------------------------------------------------------------
CHANGED
• The default highlight priority is computed dynamically to be halfway between
semantic tokens and Tree-sitter.
• Deprecated |rb-delimiters.strategy| and its Vim script mirror
|g:rainbow_delimiters#strategy|, refer to strategies via strings instead.
==============================================================================
VERSION 0.8.0 (released on 2024-12-10)
------------------------------------------------------------------------------
ADDED
New languages:
• Swift
• Odin
Missing patterns:
• Python:
- `format_expression`
• Starlark:
- `list_pattern`
- `dict_pattern`
- `interpolation`
- `format_expression`
------------------------------------------------------------------------------
CHANGED
Renamed patterns:
• Astro:
- `interpolation` to `html_interpolation`
==============================================================================
VERSION 0.7.0 (released on 2024-11-03)
This is a bugfix release for Neovim 0.10 and later.
------------------------------------------------------------------------------
FIXED
• Highlighting wrong in global strategy after making changes inside a nested
node
------------------------------------------------------------------------------
CHANGED
• Queries no longer need the `@sentinel` capture group
==============================================================================
VERSION 0.6.2 (released on 2024-09-26)
Maintenance release which fixes a number of subtly broken queries.
------------------------------------------------------------------------------
ADDED
Missing patterns:
• SQL:
- `parenthesized_expression`
------------------------------------------------------------------------------
FIXED
Renamed patterns:
• Go query:
- `var_declaration` to `var_spec_list`
Fixed patterns:
• C++:
- missing `@container` capture in one pattern
- duplicate pattern for `initializer_list`
• Common Lisp:
- duplicate extmarks on some delimiters
• Luadoc:
- Remove broken pattern for dictionary key type
• Ruby:
- duplicate extmarks on some delimiters
• Rust:
- duplicate pattern for `closure_parameters`
• SQL:
- Remove broken patterns
• Zig:
- duplicate extmarks on some delimiters
- renamed nodes in updated parser
• Vim:
- Make a better effort to make parentheses in expressions work (there
is only so much that can be done though)
==============================================================================
VERSION 0.6.1 (released on 2024-08-07)
------------------------------------------------------------------------------
FIXED
• Health check is not aware of new `condition` configuration option
==============================================================================
VERSION 0.6.0 (released on 2024-08-07)
------------------------------------------------------------------------------
ADDED
• New option `condition`: allows users to dynamically enable or disable
rainbow delimiters for a buffer.
==============================================================================
VERSION 0.5.0 (released on 2024-07-29)
Mostly a maintenance support with added support for a few new languages.
------------------------------------------------------------------------------
ADDED
New languages:
• Awk
• WebGL Shading Language (WGSL)
• Django HTML (preliminary, will only pass through injected languages)
Missing patterns:
• C++
- `condition_clause`
- `for_statement`
- `cast_expression`
- `array_declarator`
• C#:
- `tuple_pattern`
• Common Lisp:
- `loop_macro`
• Cue:
- `dynamic`
- `index_expression`
• Javascript:
- `array_pattern`
- `for_in_statement`
- `for_statement`
• Rust:
- `bracketed_type`
• Typescript:
- `enum_body`
- `interface_body`
• Haskell:
- `children`
- `fields`
- `list`
- `parens`
- `prefix_id`
- `record`
- `tuple`
- `unit`
Other:
• Recipes section in the manual
------------------------------------------------------------------------------
CHANGED
Renamed patterns:
• C#:
- `for_each_statement` to `foreach_statement`
- `type_of_expression` to `typeof_expression`
- `size_of_expression` to `sizeof_expression`
- `implicit_stack_alloc_array_creation_expression` to
`implicit_stackalloc_expression`
Updated R patterns for current parser
------------------------------------------------------------------------------
REMOVED
Deprecated patterns:
• C#:
- `interpolation`
• Java:
- `condition`
• Haskell:
- `con_list`
- `context`
- `deriving`
- `exp_arithmetic_sequence`
- `exp_lambda`
- `exp_list_comprehension`
- `exp_list`
- `exp_name`
- `exp_record`
- `exp_section_right`
- `pat_fields`
- `pat_list`
- `pat_parens`
- `pat_tuple`
- `record_fields`
- `type_list`
- `type_parens`
- `type_tuple`
- `type_tuple`
==============================================================================
VERSION 0.4.0 (released on 2024-05-07)
------------------------------------------------------------------------------
ADDED
- Public API function `is_enabled`
New languages:
• Rasi
• Svelte
• Teal
• Typst
• XML
Missing patterns:
• Java:
- `array_initializer`
- `annotation_argument_list`
- `catch_clause`
- `condition`
- `constructor_body`
- `dimensions_expr`
- `enhanced_for_statement`
- `for_statement`
- `inferred_parameters`
- `parenthesized_expression`
- `resource_specification`
- `cast_expression`
• Go:
- `type_assertion_expression`
• Julia:
- `curly_expression`
- `tuple_expression`
• Lua:
- `field`
• Luadoc:
- `indexed_field`
- `tuple_type`
• Python:
- `dict_pattern`
- `import_from_statement`
- `interpolation` (literal string interpolation)
- `list_pattern`
- `tuple_pattern`
• R:
- `for`
- `while`
- `switch`
- `function_definition`
• Rust:
- `array_type`
• Starlark:
- `tuple_pattern`
------------------------------------------------------------------------------
FIXED
• Default configuration settings override custom settings if the configuration
value was used before setting the custom value
• Deleted obsolete Julia pattern `parameter_list`
• Switched Fennel queries to new upstream grammar (#6132):
https://github.com/nvim-treesitter/nvim-treesitter/pull/6132
==============================================================================
VERSION 0.3.0 (released on 2023-12-24)
This release brings a plethora of missing patterns to existing queries and
lets you specify priorities and queries dynamically at runtime. This means
that it is possible to set different queries for the same language depending
on external conditions, such as whether a buffer is read-only.
And as a little extra given the date of this release, there is a new Christmas
strategy module. This will let you decorate your syntax tree in an especially
festive mood. The module is just a joke, so it will not be loaded by default
and you will have to figure out yourself how to set it up.
------------------------------------------------------------------------------
ADDED
New languages:
• Starlark
Missing patters:
• C:
- `enumerator_list`
- `macro_type_specifier`
- `preproc_params`
- `compound_literal_expression`
- `parenthesized_declarator`
• Elixir:
- `access_call`
• Fennel:
- `table_binding`
New queries:
• Query:
- `rainbow-blocks`
• Javascript:
- `rainbow-tags-react`
• TypeScript React:
- `rainbow-tags-react`
New Christmas strategy module `rainbow-delimiters.strategy.christmas` (not
loaded by default)
------------------------------------------------------------------------------
FIXED
• Query can be a function in configuration
• Priority can be a function in configuration
• Functions in configuration take buffer number as argument
• Updated Nim queries
==============================================================================
VERSION 0.2.0 (released on 2023-11-26)
------------------------------------------------------------------------------
ADDED
Ability to set highlight priority
New languages:
• Cue
• Luadoc
• Nim
• Kotlin
• templ
• Terraform
• TOML
------------------------------------------------------------------------------
FIXED
- Type error in local strategy
- Log error in local strategy (Neovim <0.10 only)
Missing patterns:
• CSS:
- `feature_query`
- `arguments`
- `attribute_selector`
• Go
- `array_type`
- `slice_expression`
• HCL
- `for_tuple_expr`
- `new_index`
- `expression`
- `binary_operation`
- `for_object_expr`
- `template_interpolation`
- `unary_operation`
• Javascript and Typescript
- `switch_body`
• Nix
- `rec_attrset_expression`
- `inherit_from`
• SCSS
- `parameters`
------------------------------------------------------------------------------
CHANGED
Default highlight priority is 110 instead of 210, which is between Tree-sitter
and LSP semantic tokens
==============================================================================
VERSION 0.1.0 (released on 2023-11-12)
Initial release
vim:tw=78:ts=8:sw=4:et:ft=help:norl:
rainbow-delimiters.nvim-v0.10.0/doc/rainbow-delimiters.txt 0000664 0000000 0000000 00000072554 15066556776 0023700 0 ustar 00root root 0000000 0000000 *rainbow-delimiters.txt* Alternating highlight for delimiters in code
*rainbow-delimiters*
*rb-delimiters*
Author: Alejandro "HiPhish" Sanchez
License: Apache-2.0
Version: 0.10.0
==============================================================================
TABLE OF CONTENTS *rb-delimiters-contents*
1. Introduction .............................. |rb-delimiters-intro|
2. Setup and configuration ................... |rb-delimiters-setup|
2.1 Highlight colors ...................... |rb-delimiters-colors|
2.2 Strategies ............................ |rb-delimiters-strategy|
2.3 Queries ............................... |rb-delimiters-query|
2.4 Logging ............................... |rb-delimiters-logging|
3. Extending ................................. |rb-delimiters-extending|
3.1 The library ........................... |rb-delimiters-api|
3.2 Custom queries ........................ |rb-delimiters-custom-query|
3.3 Custom strategies ..................... |rb-delimiters-custom-strategy|
3.4 Adding new languages .................. |rb-delimiters-custom-lang|
3.5 Adding highlight tests ................ |rb-delimiters-highlight-test|
4. Recipes ................................... |rb-delimiters-recipes|
5. Acknowledgements .......................... |rb-delimiters-credit|
6. Further reading ........................... |rb-delimiters-reading|
7. Changelog ................................. |rb-delimiters-news|
==============================================================================
INTRODUCTION *rb-delimiters-intro*
This plugin provides alternating highlighting for delimiters in Neovim, also
known as "rainbow parentheses". Thanks to the built-in |treesitter| support
we are not limited to just parentheses. We can match any part of the document
tree, such as HTML tags or `do` / `end` pairs in Lua. We can define new
patterns for existing languages, add support for new languages and even change
the strategy used for highlighting.
==============================================================================
SETUP AND CONFIGURATION *rb-delimiters-setup*
Install Rainbow-Delimiters like any other Neovim plugin. You also need a
Tree-sitter parser for each language to want to support.
*g:rainbow_delimiters*
Configuration is done through the variable `g:rainbow_delimiters`. It is a
dictionary which can be defined both in Vim script and in Lua. The following
keys are recognized:
`strategy`
How to apply highlighting. The empty string is the key for the default
strategy. See |rb-delimiters-strategy| for more information about strategies
and the possible values.
`query`
Dictionary mapping Tree-sitter language names to queries. The empty string
is the key for the default query. See |rb-delimiters-query| for more
information about queries.
`priority`
Dictionary mapping Tree-sitter language names to highlight priority values.
The empty string is the key for the default priority. See
|vim.highlight.priorities| and |treesitter-highlight-priority| for more
information on priorities.
`highlight`
List of names of the highlight groups to use for highlighting, for more
information see |rb-delimiters-colors|.
`whitelist`
List of Tree-sitter languages for which to enabled rainbow delimiters.
Rainbow delimiters will be disabled for all other languages.
`blacklist`
List of Tree-sitter languages for which to disabled rainbow delimiters.
Rainbow delimiters will be enabled for all other languages.
`condition`
Function which receives the current buffer number and returns a boolean; can
be used to dynamically decide whether to enable (true) or disable (false)
rainbow delimiters for a given buffer. You could for example use this
predicate to disable rainbow delimiters for large files.
Superceeded by the blacklist, but superceedes the whitelist. This means if
the file type is blacklisted the condtion is ignored, but if the file type
is whitelisted or not blacklisted the condition will be evaluated and
honoured.
`log`
Settings for logging information. This is a dictionary which contains
further settings. See |rb-delimiters-logging| for details.
If neither the white- nor the blacklist are set rainbow delimiters will be
enabled for all languages. If both lists are set it is undefined which will
take precedence.
Here is an example configuration:
>vim
let g:rainbow_delimiters = {
\ 'strategy': {
\ '': 'rainbow-delimiters.strategy.global',
\ 'vim': 'rainbow-delimiters.strategy.local',
\ },
\ 'query': {
\ '': 'rainbow-delimiters',
\ 'lua': 'rainbow-blocks',
\ },
\ 'priority': {
\ '': 110,
\ 'lua': 210,
\ },
\ 'highlight': [
\ 'RainbowDelimiterRed',
\ 'RainbowDelimiterYellow',
\ 'RainbowDelimiterBlue',
\ 'RainbowDelimiterOrange',
\ 'RainbowDelimiterGreen',
\ 'RainbowDelimiterViolet',
\ 'RainbowDelimiterCyan',
\ ],
\ 'blacklist': ['c', 'cpp'],
\ }
<
Alternatively, the same configuration in Lua:
>lua
-- This module contains a number of default definitions
local rainbow_delimiters = require 'rainbow-delimiters'
---@type rainbow_delimiters.config
vim.g.rainbow_delimiters = {
strategy = {
[''] = 'rainbow-delimiters.strategy.global',
commonlisp = 'rainbow-delimiters.strategy.local',
},
query = {
[''] = 'rainbow-delimiters',
lua = 'rainbow-blocks',
},
priority = {
[''] = 110,
lua = 210,
},
highlight = {
'RainbowDelimiterRed',
'RainbowDelimiterYellow',
'RainbowDelimiterBlue',
'RainbowDelimiterOrange',
'RainbowDelimiterGreen',
'RainbowDelimiterViolet',
'RainbowDelimiterCyan',
},
blacklist = {'c', 'cpp'},
}
<
*rainbow-delimiters.setup*
'rainbow-delimiters.setup'.setup({config})
Some people prefer to call a Lua `setup` function, so a setup function is
available as part of a Lua module.
>lua
require 'rainbow-delimiters.setup'.setup {
strategy = {
[''] = 'rainbow-delimiters.strategy.global',
commonlisp = 'rainbow-delimiters.strategy.local',
},
query = {
[''] = 'rainbow-delimiters',
latex = 'rainbow-blocks',
},
highlight = {
'RainbowDelimiterRed',
'RainbowDelimiterYellow',
'RainbowDelimiterBlue',
'RainbowDelimiterOrange',
'RainbowDelimiterGreen',
'RainbowDelimiterViolet',
'RainbowDelimiterCyan',
},
blacklist = {'c', 'cpp'},
}
<
The keys are exactly the same as for |g:rainbow_delimiters|. In fact, this
function does the same as setting the variable directly.
As an aside, this is a bad practice carried over from a time when Lua support
in Neovim still had issues with Vim script interoperability, but it has
persisted through cargo-culting. You are better off not using this function.
------------------------------------------------------------------------------
HIGHLIGHT COLORS *rb-delimiters-colors*
The `highlight` setting controls which highlight group to apply. It is a list
of any number of highlight group names as strings. The default values are in
this order:
- `RainbowDelimiterRed`
- `RainbowDelimiterYellow`
- `RainbowDelimiterBlue`
- `RainbowDelimiterOrange`
- `RainbowDelimiterGreen`
- `RainbowDelimiterViolet`
- `RainbowDelimiterCyan`
These are non-standard highlight groups and I have tried to find reasonable
default values for most uses. Nevertheless, you probably want to redefine
them for your colour scheme or link them to some existing group.
The colors are intentionally not in the order of the rainbow to help make the
contrast between adjacent delimiters more noticeable. Re-order the groups in
your settings if you prefer a different order.
Example highlight group definitions:
>vim
" Link to an existing highlight group
highlight link RainbowDelimiterRed WarningMsg
" Define the highlight from scratch
highlight RainbowDelimiterOrange guifg=#d65d0e ctermfg=White
<
You will probably want to have different colours per theme. Since most themes
will lack definitions for the above groups you will need to hook in somehow.
A simple solution is to use an autocommand.
>vim
au ColorSchemePre MyTheme highlight link RainbowDelimiter MyThemeRed
au ColorSchemePre MyTheme highlight link RainbowDelimiter MyThemeYellow
" and so on...
<
------------------------------------------------------------------------------
STRATEGIES *rb-delimiters-strategy*
A strategy defines how to perform the highlighting of delimiters. For
example, the included global strategy highlights every delimiter in a buffer
and updates the highlights when the document tree changes. On the other hand,
the included local strategy highlights only the sub-tree of the document which
contains the cursor and is updated whenever the cursor moves.
The strategy is set globally with per-language overrides. The empty string is
the key for the default strategy used by all languages which do not have their
own setting. The setting value is of one of the following types:
• String path to a Lua module which is a strategy
• A dictionary according to |rb-delimiters-custom-strategy|
• A function which returns a string or a strategy
A function can be used to defer the decision to a later point in time. It has
the following signature:
Parameters: ~
• {bufnr} Number of the buffer to highlight
Return: ~
Either a string, a strategy or `nil` (or |v:null|). If `nil`, rainbow
delimiters will be disabled for that buffer.
NOTE
Functions can only be used from Lua.
>lua
strategy = {
-- Use global strategy by default
[''] = 'rainbow-delimiters.strategy.global',
-- Use local for HTML
html = 'rainbow-delimiters.strategy.local',
-- Pick the strategy for LaTeX dynamically based on the buffer size
latex = function(bufnr)
-- Disabled for very large files, global strategy for large files,
-- local strategy otherwise
local line_count = vim.api.nvim_buf_line_count(bufnr)
if line_count > 10000 then
return nil
elseif line_count > 1000 then
return 'rainbow-delimiters.strategy.global'
end
return 'rainbow-delimiters.strategy.local'
end
}
<
A strategy is a table which must contain specific fields. It is possible to
define your own strategy, see |rb-delimiters-custom-strategy|. The following
strategies are included:
*rb-delimiters.strategy.global*
Global~
"rainbow-delimiters.strategy.global"
The default strategy, highlights the entire buffer. Has very simple logic.
*rb-delimiters.strategy.local*
Local~
"rainbow-delimiters.strategy.local"
Based on the cursor position highlights only the sub-tree which contains the
cursor. Updated every time the cursor moves and uses more complex logic than
the global strategy to figure out which nodes exactly to highlight.
*rb-delimiters.strategy.noop*
No-op~
"rainbow-delimiters.strategy.noop"
A dummy strategy which does nothing. This is only useful in testing or if you
really want an empty strategy.
------------------------------------------------------------------------------
QUERIES *rb-delimiters-query*
A query defines what to match. Every language needs its own custom query.
The query setting is a table where each entry maps a language name to a query
name. The empty string is the key for the default query.
Each value in the table can be either the name of a query file or a function
which evaluates to the name of a query file. A function can be used to defer
the decision to a later point in time.
The function has the following signature:
Parameters: ~
• {bufnr} Number of the buffer to highlight
Return: ~
The name of the query as a string.
NOTE
Functions can only be used from Lua.
>lua
query = {
-- Use parentheses by default
[''] = 'rainbow-delimiters',
-- Use blocks for Lua
lua = 'rainbow-blocks',
-- Determine the query dynamically
query = function(bufnr)
-- Use blocks for read-only buffers like in `:InspectTree`
local is_nofile = vim.bo[bufnr].buftype == 'nofile'
return is_nofile and 'rainbow-blocks' or 'rainbow-delimiters'
end
}
<
If you wish to define your own custom query or add support for a new language,
consult |rb-delimiters-custom-query| for details.
For every language the query `rainbow-delimiters` is defined, which matches a
reasonable set of parentheses and similar delimiters for each language. In
addition there are the following extra queries for certain languages:
- `latex`
- `rainbow-blocks` Matches `\begin` and `\end` instructions
- `lua`
- `rainbow-blocks` Matches keyword delimiters like like `function` and
`end`, in addition to parentheses
- `javascript`
- `rainbow-delimiters-react` Includes React support, set by default for
Javascript files
- `rainbow-parens` Only parentheses without React tags
- `rainbow-tags-react` Only React tags without parentheses
- `query`
- `rainbow-blocks` Highlight named nodes and identifiers in addition to
parentheses (useful for |:InspectTree|)
- `tsx`
- `rainbow-parens` Just Typescript highlighting without React tags
- `rainbow-tags-react` Only React tags without Typescript highlighting
- `typescript`
- `rainbow-parens` Just Typescript highlighting without React tags
- `verilog`
- `rainbow-blocks` Matches keyword delimiters like `begin` and `end`, in
addition to parentheses
------------------------------------------------------------------------------
LOGGING *rb-delimiters-logging*
By default only errors are logged. You can adjust what and how to log by
adjusting the values of the `log` entry in the settings. For information how
to change settings. see |rb-delimiters-setup|.
The following settings are supported:
`file`
Path to the log file, default is `rainbow-delimiters.log` in your standard
log path (see |standard-path|).
`level`
Only messages equal to or above this value will be logged. The default is
to log warnings or above. See |log_levels| for possible values.
The log file format is a CSV file which uses the `TAB` character (ASCII
`0x09`) as the field separator and a `NL` (ASCII `0x0A`) as the record
separator.
The fields are in this order:
- Time stamp of when the message was logged in ISO 8601 format with time zone
- Log level as string
- Lua module from which the message was logged, or the empty string if outside
a module
- The logged message
==============================================================================
EXTENDING RAINBOW DELIMITERS
Rainbow delimiters are hackable, you can add your own strategies, queries for
existing languages or even queries for new languages. Strategies and queries
are split up to be independent and can be mixed arbitrarily, but there are
some rules which need to be followed.
------------------------------------------------------------------------------
THE LIBRARY *rb-delimiters-api*
There is a utility library provided for people writing their own strategies.
It is available as a table under the Lua module `'rainbow-delimiters'`.
*rb-delimiters.enable*
*rb_delimiters#enable*
'rainbow-delimiters'.enable({bufnr})
Re-enable rainbow delimiters for the buffer {bufnr} (or the current buffer
if {bufnr} is `0`) after it has been disabled.
rainbow_delimiters#enable({bufnr})
Vim script binding for the above function.
*rb-delimiters.disable*
*rb_delimiters#disable*
'rainbow-delimiters'.disable({bufnr})
Disable rainbow delimiters for the buffer {bufnr} (or the current buffer
if {bufnr} is `0`).
rainbow_delimiters#disable({bufnr})
Vim script binding for the above function.
*rb-delimiters.toggle*
*rb_delimiters#toggle*
'rainbow-delimiters'.toggle({bufnr})
Toggle rainbow delimiters for the buffer {bufnr} (or the current buffer
if {bufnr} is `0`).
rainbow_delimiters#toggle({bufnr})
Vim script binding for the above function.
*rb-delimiters.is_enabled*
*rb_delimiters#is_enabled*
'rainbow-delimiters'.is_enabled({bufnr})
Check if rainbow delimiters are enabled for the buffer {bufnr} (or the
current buffer if {bufnr} is `0`).
rainbow_delimiters#is_enabled({bufnr})
Vim script binding for the above function.
*rb-delimiters.hlgroup_at*
*rainbow-delimiters#hlgroup_at*
'rainbow-delimiters'.hlgroup_at({nesting_level})
Gets the name of the highlight group set up at the given nesting level.
This function will properly roll over, meaning that if there are seven
highlight groups defined and the {nesting_level} is nine, you will get the
second highlight group.
rainbow-delimiters#hlgroup_at({nesting_level})
Vim script binding for the above function.
*rb-delimiters.strategy*
*g:rainbow_delimiters#strategy*
'rainbow-delimiters'.strategy
WARNING: This is deprecated, use the string values listed in
|rb-delimiters-strategy|.
Table of included strategies. For more information about strategies see
|rb-delimiters-strategy|. The included ones are:
- `global` |rb-delimiters.strategy.global|
- `local` |rb-delimiters.strategy.local|
- `noop` |rb-delimiters.strategy.noop|
Do not add your own strategies to this table.
g:rainbow_delimiters#strategy
Vim script dictionary, equivalent of the above table with the same keys.
------------------------------------------------------------------------------
CUSTOM STRATEGIES *rb-delimiters-custom-strategy*
A strategy is a table which must contain a certain set of fields. In
object-oriented terminology we would say that a strategy table must implement
the strategy protocol.
>
strategy = {
on_attach = function(bufnr: integer, settings: table),
on_detach = function(bufnr: integer),
on_reset = function(bufnr: integer, settings: table),
}
<
------------------------------------------------------------------------------
on_attach({bufnr}, {settings})
This function takes two arguments: the number of the buffer and the table of
settings used by the buffer. This function is generally used to set up
autocommands or other callbacks for events when the highlighting needs to be
updated.
The settings table contains the following entries:
- `strategy` Strategy in use
- `parser` Reference to the buffer parser (|treesitter-languagetree|)
- `lang` Language of the current parser
A strategy should pick the settings it needs and either cache them in an
internal table, or construct closures (e.g. for callback functions) around
them.
------------------------------------------------------------------------------
on_detach({bufnr})
This function takes one argument: the number of the buffer. This function is
generally used to clean up any custom state, autocommands and callbacks set up
in the `on_attach` function.
------------------------------------------------------------------------------
on_reset({bufnr}, {settings})
Similar to `on_attach` with the same signature, except that this function is
called when the buffer has been reset in some way, for example if the
underlying file has been modified by a code formatter. Usually the strategy
should highlight the entire buffer from scratch again because we cannot rely
on Tree-sitter to tell us what has changed.
As a rule of thumb, `on_reset` should do the work of `on_attach`, minus all
the initial setup.
------------------------------------------------------------------------------
The logic within the strategy can vary wildly between strategies. Usually you
will want to install some callback in the `on_attach` function. That callback
can then use the Tree-sitter API and the utility library (see
|rb-delimiters-api|) to select which nodes to highlight and what highlight
group to apply.
See |rb-delimiters-custom-query| for the standard capture groups used.
Selecting standard capture groups allows your strategy to work with any of the
built-in queries as well as user-specified custom queries.
------------------------------------------------------------------------------
CUSTOM QUERIES *rb-delimiters-custom-query*
A query defines what exactly needs to be highlighted. Different languages
have different document trees, so you need a separate query for each language.
The queries need to define the following capture groups:
- `@container`
The entire delimited node.
- `@delimiter`
Any delimiter you want to highlight in the current `@container`.
- `@_`
Delimiters starting with `_` (underscore) are ignored for highlighting
purposes, but you can use them for treesitter predicates like
`#eq?`, `#any-eq?`, etc. (These are very rarely needed.)
`@container` is mandatory, and at least one `@delimiter` will always be
present as well since `@delimiter` is what is highlighted. The captures
starting with underscore will be rarely used, since you only need them for
predicates in a few special cases.
Let's look at an example first. Here is a snippet of HTML code:
>html
Example link
<
The corresponding document tree including anonymous nodes is as follows:
>query
(element ; [0, 0] - [2, 4]
(start_tag ; [0, 0] - [0, 30]
"<" ; [0, 0] - [0, 1]
(tag_name) ; [0, 1] - [0, 2]
(attribute ; [0, 3] - [0, 29]
(attribute_name) ; [0, 3] - [0, 7]
"=" ; [0, 7] - [0, 8]
(quoted_attribute_value ; [0, 8] - [0, 29]
"\"" ; [0, 8] - [0, 9]
(attribute_value) ; [0, 9] - [0, 28]
"\"")) ; [0, 28] - [0, 29]
">") ; [0, 29] - [0, 30]
(text) ; [1, 4] - [1, 11]
(element ; [1, 11] - [1, 16]
(self_closing_tag ; [1, 11] - [1, 16]
"<" ; [1, 11] - [1, 12]
(tag_name) ; [1, 12] - [1, 14]
"/>")) ; [1, 14] - [1, 16]
(text) ; [1, 16] - [1, 20]
(end_tag ; [2, 0] - [2, 4]
"" ; [2, 0] - [2, 2]
(tag_name) ; [2, 2] - [2, 3]
">")) ; [2, 3] - [2, 4]
<
As a human I immediately perceive the entire link as one object with two
delimiters: the opening `` tag and the closing `` tag. Perhaps the
self-closing ` ` tag can be seen as an intermediate delimiter because it
does not open a new scope. On the other hand, it is part of the content of
the entire link, not one of its delimiters.
As you can see, it is up to interpretation as to what exactly constitutes a
delimiter. In this example for the sake of exhaustiveness we will consider
the ` ` tag a delimiter. The corresponding query is as follows:
>query
(element
(start_tag) @delimiter
(element
(self_closing_tag) @delimiter)? ; Optional!
(end_tag) @delimiter) @container
<
Highlighting the entire tag might be too vibrant though. What if we want to
highlight only the opening and closing angle brackets? The query gets
slightly more complex because we have to descend deeper into the document
tree.
>query
(element
((start_tag
["<" ">"] @delimiter)
(element
(self_closing_tag
["<" "/>"] @delimiter))? ;Optional!
(end_tag
"" @delimiter
">" @delimiter))) @container
<
You might now see why we need the `@container` capture group: there is no way
to know in general how deeply the delimiter is nested. Even for one language
our understanding of what constitutes a delimiter is up for debate. Therefore
a human must decide for each query which node is the container and which nodes
are the delimiters. Capturing this information makes it available for use in
strategies.
We are not limited to only one opening and one closing delimiter. The
included default query captures the angle brackets and the tag name, but not
attributes between the tag name and closing angle bracket. This strikes a
pleasant middle ground between the two above extremes.
>query
(element
(start_tag
"<" @delimiter
(tag_name) @delimiter
">" @delimiter)
(end_tag
"" @delimiter
(tag_name) @delimiter
">" @delimiter)) @container
<
Here both opening and closing tag have three delimiters each.
In HTML the terminating slash in a self-closing tag is optional. Instead of
` ` we can write ` `. A naïve query would look like this:
>query
(element
(start_tag
"<" @delimiter
(tag_name) @delimiter @_tag_name
">" @delimiter)) @container
<
However, this query also matches the opening tag of regular tags like `
`.
This is where the `@_tag_name` capture comes in. The set of self-closing tags
is finite, so we can list them explicitly. This way a regular opening tag
will not match this particular pattern.
>query
(element
(start_tag
"<" @delimiter
(tag_name) @delimiter @_tag_name
">" @delimiter)
;; List abridged for brevity
(#any-of? @_tag_name "br" "hr" "input")) @container
<
We need the `@_tag_name` capture so that it can be used with the `#any-of?`
predicate (|treesitter-predicate-any-of?|), but the capture itself is not used
for highlighting.
------------------------------------------------------------------------------
ADDING SUPPORT FOR NEW LANGUAGES *rb-delimiters-custom-lang*
Supporting a new new language requires creating one or more queries for the
language. If the query is mature enough please consider upstreaming it so
everyone can benefit.
------------------------------------------------------------------------------
ADDING HIGHLIGHT TESTS *rb-delimiters-highlight-test*
Whenever you make changes to a query or add support for a new language you
should also add highlighting tests if you want to upsteam your changes. There
are two steps:
- Add a sample file to show off the highlighting
- Record the state of highlighting
See the `CONTRIBUTING` file of this repository for details.
==============================================================================
RECIPES *rb-delimiters-recipes*
Various tricks and hacks which have accumulated over time.
------------------------------------------------------------------------------
DISABLE WITHOUT BLACKLISTING
If you wish to disable rainbow delimiters for a language but for whatever
reason you do not want to blacklist this language you can create a custom
query (|rb-delimiters-custom-query|) without any patterns. Then set the name
of that query as the query for that language (|rb-delimiters-query|).
Or you could name your custom query the same as the default query (by default
`rainbow-delimiters`), then you do not have to change your configuration.
==============================================================================
ACKNOWLEDGMENTS *rb-delimiters-credit*
The original version of nvim-ts-rainbow was written by Chinmay "p00f" Dalal,
and discontinued in January of 2023. The original repositories can be found
under these URLs:
- https://sr.ht/~p00f/nvim-ts-rainbow/
- https://github.com/p00f/nvim-ts-rainbow
==============================================================================
FURTHER READING *rb-delimiters-reading*
- nvim-treesitter plugin https://github.com/nvim-treesitter/nvim-treesitter
- Official Tree-sitter website https://tree-sitter.github.io/tree-sitter/
- Neovim Tree-sitter documentation: |treesitter.txt|
==============================================================================
vim:tw=78:ts=8:sw=4:et:ft=help:norl:
rainbow-delimiters.nvim-v0.10.0/lua/ 0000775 0000000 0000000 00000000000 15066556776 0017336 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters.lua 0000664 0000000 0000000 00000005622 15066556776 0023646 0 ustar 00root root 0000000 0000000 --[[
Copyright 2023 Alejandro "HiPhish" Sanchez
Copyright 2020-2022 Chinmay Dalal
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.
--]]
---Lazily loaded reference to the private library
local lib
---Disable rainbow delimiters for a given buffer.
---@param bufnr integer Buffer number, zero for current buffer.
local function disable(bufnr)
lib = lib or require 'rainbow-delimiters.lib'
if not bufnr or bufnr == 0 then bufnr = vim.api.nvim_get_current_buf() end
lib.detach(bufnr)
lib.buffers[bufnr] = false
end
---Enable rainbow delimiters for a given buffer.
---@param bufnr integer Buffer number, zero for current buffer.
local function enable(bufnr)
lib = lib or require 'rainbow-delimiters.lib'
if not bufnr or bufnr == 0 then bufnr = vim.api.nvim_get_current_buf() end
lib.buffers[bufnr] = nil
lib.attach(bufnr)
end
---Toggle rainbow delimiters for a given buffer.
---@param bufnr integer Buffer number, zero for current buffer.
local function toggle(bufnr)
lib = lib or require 'rainbow-delimiters.lib'
if not bufnr or bufnr == 0 then bufnr = vim.api.nvim_get_current_buf() end
if lib.buffers[bufnr] then
disable(bufnr)
else
enable(bufnr)
end
end
---Check if rainbow delimiters are enabled for a given buffer.
---@param bufnr integer Buffer number, zero for current buffer.
---@return boolean # Whether or not rainbow delimiters is enabled
local function is_enabled(bufnr)
lib = lib or require 'rainbow-delimiters.lib'
if not bufnr or bufnr == 0 then bufnr = vim.api.nvim_get_current_buf() end
return lib.buffers[bufnr] ~= nil and lib.buffers[bufnr] ~= false
end
---Get the appropriate highlight group for the given level of nesting.
---@param i integer One-based index into the highlight groups
---@return string hlgroup Name of the highlight groups
local function hlgroup_at(i)
lib = lib or require 'rainbow-delimiters.lib'
return lib.hlgroup_at(i)
end
---Public API for use in writing strategies or other custom code.
local M = {
hlgroup_at = hlgroup_at,
---Available default highlight strategies
strategy = {
---Global highlighting strategy
['global'] = 'rainbow-delimiters.strategy.global',
---Local highlighting strategy
['local'] = 'rainbow-delimiters.strategy.local',
---Empty highlighting strategy for testing
['noop'] = 'rainbow-delimiters.strategy.no-op',
},
enable = enable,
disable = disable,
toggle = toggle,
is_enabled = is_enabled,
}
return M
-- vim:tw=79:ts=4:sw=4:noet:
rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters.types.lua 0000664 0000000 0000000 00000060675 15066556776 0025022 0 ustar 00root root 0000000 0000000 ---@meta
--# Utility Library #--
---Strategy to use for highlighting with rainbow-delimiters
---Must implement `on_attach`, `on_detach` and `on_reset`
---@class rainbow_delimiters.strategy
---`on_attach`: setup the highlighting on attach
---@field on_attach fun(bufnr: integer, settings: rainbow_delimiters.buffer_settings)
---`on_detach`: remove any unneccesary remaining setup on detach
---@field on_detach fun(bufnr: integer)
---`on_reset`: update the highlighting on reset
---@field on_reset fun(bufnr: integer, settings: rainbow_delimiters.buffer_settings)
---@class (exact) rainbow_delimiters.buffer_settings
---@field strategy rainbow_delimiters.strategy
---@field parser vim.treesitter.LanguageTree
---@field lang string
--# Config #--
---Configuration table for rainbow-delimiters
---@class (exact) rainbow_delimiters.config
---Strategy to use for highlighting
---@field strategy rainbow_delimiters.config.strategies?
---Query to use for highlighting
---@field query rainbow_delimiters.config.queries?
---Highlight priority of rainbow delimiters
---@field priority rainbow_delimiters.config.priorities?
---Highlight colors
---@field highlight string[]?
---Whitelist for languages to highlight
---@field whitelist rainbow_delimiters.language[]?
---Blacklist for languages not to highlight
---@field blacklist rainbow_delimiters.language[]?
---Dynamic condition whether to enable rainbow highlighting
---@field condition (fun(bufnr: number): boolean)?
---Logging with log file and log level
---@field log rainbow_delimiters.logging?
---@class rainbow_delimiters.config.strategies
---@field [''] (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field astro (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field bash (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field c (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field c_sharp (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field clojure (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field commonlisp (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field cpp (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field css (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field cuda (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field cue (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field dart (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field elixir (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field elm (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field fennel (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field fish (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field glsl (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field go (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field groovy (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field haskell (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field hcl (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field html (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field janet_simple (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field java (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field javascript (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field json (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field json5 (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field jsonc (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field jsonnet (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field julia (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field kdl (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field kotlin (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field latex (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field lua (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field luadoc (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field make (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field markdown (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field nim (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field nix (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field nu (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field ocaml (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field odin (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field perl (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field php (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field python (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field query (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field r (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field racket (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field rasi (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field regex (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field rst (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field ruby (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field rust (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field scheme (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field scss (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field sql (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field starlark (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field templ (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field terraform (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field toml (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field tsx (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field typescript (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field typst (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field verilog (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field vim (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field vimdoc (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field vue (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field wgsl (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field yaml (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field yuck (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@field zig (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---User defined language, not part of rainbow_delimiters support
---@field [string] (string | rainbow_delimiters.strategy | fun(bufnr: integer): string | rainbow_delimiters.strategy?)?
---@class rainbow_delimiters.config.queries
---@field [''] (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field astro (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field bash (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field c (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field c_sharp (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field clojure (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field commonlisp (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field cpp (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field css (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field cuda (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field cue (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field dart (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field elixir (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field elm (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field fennel (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field fish (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field glsl (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field go (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field groovy (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field haskell (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field hcl (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field html (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field janet_simple (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field java (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field javascript (('rainbow-delimiters' | 'rainbow-parens' | 'rainbow-delimiters-react' | string) | fun(bufnr: integer): ('rainbow-delimiters' | 'rainbow-parens' | 'rainbow-delimiters-react' | string))?
---@field json (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field json5 (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field jsonc (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field jsonnet (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field julia (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field kdl (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field kotlin (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field latex (('rainbow-delimiters' | 'rainbow-blocks' | string) | fun(bufnr: integer): ('rainbow-delimiters' | 'rainbow-blocks' | string))?
---@field lua (('rainbow-delimiters' | 'rainbow-blocks' | string) | fun(bufnr: integer): ('rainbow-delimiters' | 'rainbow-blocks' | string))?
---@field luadoc (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field make (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field markdown (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field nim (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field nix (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field nu (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field ocaml (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field odin (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field perl (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field php (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field python (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field query (('rainbow-delimiters' | 'rainbow-blocks' | string) | fun(bufnr: integer): ('rainbow-delimiters' | 'rainbow-blocks' | string))?
---@field r (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field racket (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field rasi (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field regex (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field rst (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field ruby (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field rust (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field scheme (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field scss (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field sql (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field starlark (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field templ (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field terraform (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field toml (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field tsx (('rainbow-delimiters' | 'rainbow-parens' | string) | fun(bufnr: integer): ('rainbow-delimiters' | 'rainbow-parens' | string))?
---@field typescript (('rainbow-delimiters' | 'rainbow-parens' | string) | fun(bufnr: integer): ('rainbow-delimiters' | 'rainbow-parens' | string))?
---@field typst (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field verilog (('rainbow-delimiters' | 'rainbow-blocks' | string) | fun(bufnr: integer): ('rainbow-delimiters' | 'rainbow-blocks' | string))?
---@field vim (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field vimdoc (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field vue (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field wgsl (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field yaml (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field yuck (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---@field zig (('rainbow-delimiters' | string) | fun(bufnr: integer): ('rainbow-delimiters' | string))?
---User defined language, not part of rainbow_delimiters support
---@field [string] (string | fun(bufnr: integer): string)?
---@class rainbow_delimiters.config.priorities
---@field [''] (integer | fun(bufnr: integer): integer)?
---@field astro (integer | fun(bufnr: integer): integer)?
---@field bash (integer | fun(bufnr: integer): integer)?
---@field c (integer | fun(bufnr: integer): integer)?
---@field c_sharp (integer | fun(bufnr: integer): integer)?
---@field clojure (integer | fun(bufnr: integer): integer)?
---@field commonlisp (integer | fun(bufnr: integer): integer)?
---@field cpp (integer | fun(bufnr: integer): integer)?
---@field css (integer | fun(bufnr: integer): integer)?
---@field cuda (integer | fun(bufnr: integer): integer)?
---@field cue (integer | fun(bufnr: integer): integer)?
---@field dart (integer | fun(bufnr: integer): integer)?
---@field elixir (integer | fun(bufnr: integer): integer)?
---@field elm (integer | fun(bufnr: integer): integer)?
---@field fennel (integer | fun(bufnr: integer): integer)?
---@field fish (integer | fun(bufnr: integer): integer)?
---@field glsl (integer | fun(bufnr: integer): integer)?
---@field go (integer | fun(bufnr: integer): integer)?
---@field groovy (integer | fun(bufnr: integer): integer)?
---@field haskell (integer | fun(bufnr: integer): integer)?
---@field hcl (integer | fun(bufnr: integer): integer)?
---@field html (integer | fun(bufnr: integer): integer)?
---@field janet_simple (integer | fun(bufnr: integer): integer)?
---@field java (integer | fun(bufnr: integer): integer)?
---@field javascript (integer | fun(bufnr: integer): integer)?
---@field json (integer | fun(bufnr: integer): integer)?
---@field json5 (integer | fun(bufnr: integer): integer)?
---@field jsonc (integer | fun(bufnr: integer): integer)?
---@field jsonnet (integer | fun(bufnr: integer): integer)?
---@field julia (integer | fun(bufnr: integer): integer)?
---@field kdl (integer | fun(bufnr: integer): integer)?
---@field kotlin (integer | fun(bufnr: integer): integer)?
---@field latex (integer | fun(bufnr: integer): integer)?
---@field lua (integer | fun(bufnr: integer): integer)?
---@field luadoc (integer | fun(bufnr: integer): integer)?
---@field make (integer | fun(bufnr: integer): integer)?
---@field markdown (integer | fun(bufnr: integer): integer)?
---@field nim (integer | fun(bufnr: integer): integer)?
---@field nix (integer | fun(bufnr: integer): integer)?
---@field nu (integer | fun(bufnr: integer): integer)?
---@field ocaml (integer | fun(bufnr: integer): integer)?
---@field odin (integer | fun(bufnr: integer): integer)?
---@field perl (integer | fun(bufnr: integer): integer)?
---@field php (integer | fun(bufnr: integer): integer)?
---@field python (integer | fun(bufnr: integer): integer)?
---@field query (integer | fun(bufnr: integer): integer)?
---@field r (integer | fun(bufnr: integer): integer)?
---@field racket (integer | fun(bufnr: integer): integer)?
---@field rasi (integer | fun(bufnr: integer): integer)?
---@field regex (integer | fun(bufnr: integer): integer)?
---@field rst (integer | fun(bufnr: integer): integer)?
---@field ruby (integer | fun(bufnr: integer): integer)?
---@field rust (integer | fun(bufnr: integer): integer)?
---@field scheme (integer | fun(bufnr: integer): integer)?
---@field scss (integer | fun(bufnr: integer): integer)?
---@field sql (integer | fun(bufnr: integer): integer)?
---@field starlark (integer | fun(bufnr: integer): integer)?
---@field templ (integer | fun(bufnr: integer): integer)?
---@field terraform (integer | fun(bufnr: integer): integer)?
---@field toml (integer | fun(bufnr: integer): integer)?
---@field tsx (integer | fun(bufnr: integer): integer)?
---@field typescript (integer | fun(bufnr: integer): integer)?
---@field typst (integer | fun(bufnr: integer): integer)?
---@field verilog (integer | fun(bufnr: integer): integer)?
---@field vim (integer | fun(bufnr: integer): integer)?
---@field vimdoc (integer | fun(bufnr: integer): integer)?
---@field vue (integer | fun(bufnr: integer): integer)?
---@field wgsl (integer | fun(bufnr: integer): integer)?
---@field yaml (integer | fun(bufnr: integer): integer)?
---@field yuck (integer | fun(bufnr: integer): integer)?
---@field zig (integer | fun(bufnr: integer): integer)?
---User defined language, not part of rainbow_delimiters support
---@field [string] (integer | fun(bufnr: integer): integer)?
---@alias rainbow_delimiters.language
---| 'astro'
---| 'bash'
---| 'c'
---| 'c_sharp'
---| 'clojure'
---| 'commonlisp'
---| 'cpp'
---| 'css'
---| 'cuda'
---| 'cue'
---| 'dart'
---| 'elixir'
---| 'elm'
---| 'fennel'
---| 'fish'
---| 'go'
---| 'groovy'
---| 'haskell'
---| 'hcl'
---| 'html'
---| 'janet_simple'
---| 'java'
---| 'javascript'
---| 'json'
---| 'json5'
---| 'jsonc'
---| 'jsonnet'
---| 'julia'
---| 'kdl'
---| 'kotlin'
---| 'latex'
---| 'lua'
---| 'luadoc'
---| 'make'
---| 'markdown'
---| 'nim'
---| 'nix'
---| 'nu'
---| 'ocaml'
---| 'odin'
---| 'perl'
---| 'php'
---| 'python'
---| 'query'
---| 'r'
---| 'racket'
---| 'rasi'
---| 'regex'
---| 'rst'
---| 'ruby'
---| 'rust'
---| 'scheme'
---| 'scss'
---| 'sql'
---| 'starlark'
---| 'templ'
---| 'terraform'
---| 'toml'
---| 'tsx'
---| 'typescript'
---| 'typst'
---| 'verilog'
---| 'vim'
---| 'vimdoc'
---| 'vue'
---| 'wgsl'
---| 'yaml'
---| 'yuck'
---| 'zig'
---User defined language, not part of rainbow_delimiters support
---| string
---@class (exact) rainbow_delimiters.logging
---@field file ('rainbow_delimiters.log' | string)?
---@field level integer
rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/ 0000775 0000000 0000000 00000000000 15066556776 0023136 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/_test/ 0000775 0000000 0000000 00000000000 15066556776 0024254 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/_test/highlight.lua 0000664 0000000 0000000 00000011636 15066556776 0026735 0 ustar 00root root 0000000 0000000 ---Helper script of functions which are used in highlight tests. Do not
---require this file at runtime, it is only used for testing.
local M = {}
local yd = require 'yo-dawg'
local EXTMARK_OPTS = {
type = 'highlight',
details = true,
}
---Job options for the embedded Neovim process; note the custom environment
---variables.
local JOB_OPTS = {
rpc = true,
width = 80,
height = 40,
env = {
XDG_DATA_HOME = 'test/xdg/local/share/',
XDG_CONFIG_HOME = 'test/xdg/config/',
XDG_STATE_HOME = 'test/xdg/local/state/',
}
}
---Reduces an extmark to only those fields we care about
---@param extmark table An extmark as returned by Neovim
---@return table reduced A reduced extmark
local function reduce_extmark(extmark)
return {
start_row = extmark[2],
start_col = extmark[3],
end_row = extmark[4].end_row,
end_col = extmark[4].end_col,
hl_group = extmark[4].hl_group,
}
end
---Retrieves the extmarks of a given language from a remote Neovim process.
---@param nvim table A Yo-Dawg Neovim handle
---@param lang string Name of the language
---@return table extmarks The extmarks from the remote instance.
local function fetch_extmarks(nvim, lang)
local nsid = nvim:exec_lua('return require("rainbow-delimiters.lib").nsids[...]', {lang})
local extmarks = nvim:buf_get_extmarks(0, nsid, 0, -1, EXTMARK_OPTS)
return vim.tbl_map(reduce_extmark, extmarks)
end
local function is_directory(_name, type)
return type == 'directory'
end
local function is_file(_name, type)
return type == 'file'
end
local function is_query_file(name, type)
return type == 'file' and name:match('%.scm$')
end
local function to_name(name, _type)
return name
end
local function to_query_name(name, _type)
local result = name:gsub('%.scm$', '')
return result
end
---List all languages which have sample files.
function M.list_languages()
return vim.iter(vim.fs.dir('test/highlight/samples'))
:filter(is_directory)
:map(to_name)
:totable()
end
function M.list_queries(lang)
local query_dir = ('queries/%s'):format(lang)
return vim.iter(vim.fs.dir(query_dir))
:filter(is_query_file)
:map(to_query_name)
:totable()
end
function M.list_samples(lang)
local sample_directory = ('test/highlight/samples/%s/'):format(lang)
return vim.iter(vim.fs.dir(sample_directory))
:filter(is_file)
:map(to_name)
:totable()
end
---Given a Neovim instance, language, sample file and query collect all
---highlight information from the sample file and return it.
---@param nvim table A Yo-Dawn Neovim instance
---@param lang string Language of the sample file
---@param sample string Sample file path
---@param query string Name of the query to use
---@return table
function M.fetch_delimiters(nvim, lang, sample, query)
local sample_file = ('test/highlight/samples/%s/%s'):format(lang, sample)
-- NOTE: We have to parse the buffer first because this is an embedded
-- Neovim which has no UI. When there is a UI the buffer will be parsed
-- automatically, but in an embedded context this is not guaranteed.
nvim:set_var('rainbow_delimiters', {query = {[''] = query}})
nvim:exec_lua('EnsureTSParser(...)', {lang})
nvim:cmd({cmd = 'edit', args = {sample_file}}, {})
nvim:exec_lua('vim.treesitter.start()', {})
nvim:exec_lua('parser = vim.treesitter.get_parser()', {})
nvim:exec_lua('parser:parse(true)', {})
local children = nvim:exec_lua('return vim.tbl_keys(parser:children())', {})
local result = {}
result[lang] = fetch_extmarks(nvim, lang)
for _, child in ipairs(children) do
result[child] = fetch_extmarks(nvim, child)
end
return result
end
---Record all the rainbow delimiter extmarks for a given language, query and
---sample file for later testing. The sample file will be located according to
---the language, do no provide the path leading to the sample directory.
---@param language string The language to record for
---@param sample string Name of the sample file without leading path
---@param query string Name of the query
function M.record_extmarks(language, sample, query)
local languages = language and {language} or M.list_languages()
for _, lang in ipairs(languages) do
local samples = sample and {sample} or M.list_samples(lang)
for _, sample in ipairs(samples) do
local queries = query and {query} or M.list_queries(lang)
for _, query in ipairs(queries) do
local nvim = yd.start(JOB_OPTS)
local success, result = pcall(M.fetch_delimiters, nvim, lang, sample, query)
yd.stop(nvim)
if not success then
error(result)
return
end
local spec_file = ('test/highlight/spec/%s/%s/%s.lua'):format(lang, query, sample)
vim.fn.mkdir(('test/highlight/spec/%s/%s/'):format(lang, query), 'p')
local file = io.open(spec_file, 'w')
if not file then
error (('Could not open output file %s'):format(spec_file))
end
file:write('return ')
file:write(vim.inspect(result))
file:close()
print(string.format('Spec file "%s" written\n', spec_file))
end
end
end
end
return M
rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/config.lua 0000664 0000000 0000000 00000005720 15066556776 0025112 0 ustar 00root root 0000000 0000000 --[[
Copyright 2023 Alejandro "HiPhish" Sanchez
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.
--]]
local function get_nested(table, index, key)
local result
-- 1. User setting for file type
if vim.g.rainbow_delimiters and vim.g.rainbow_delimiters[index] then
result = rawget(vim.g.rainbow_delimiters[index], key)
end
if result ~= nil then return result end
-- 2. User setting for fallback
if vim.g.rainbow_delimiters and vim.g.rainbow_delimiters[index] then
result = rawget(vim.g.rainbow_delimiters[index], '')
end
if result ~= nil then return result end
-- 3. Default setting
result = rawget(table, key)
if result ~= nil then return result end
result = require('rainbow-delimiters.default')[index][key]
return result
end
---Plugin settings lookup table. This table is only used for looking up
---values. Set `g:rainbow_delimiters` to change the values.
local M = {
query = setmetatable({}, {
__index = function(table, key)
return get_nested(table, 'query', key)
end
}),
strategy = setmetatable({}, {
__index = function(table, key)
local value = get_nested(table, 'strategy', key)
if type(value) == 'string' then
return require(value)
end
return value
end
}),
priority = setmetatable({}, {
__index = function(table, key)
return get_nested(table, 'priority', key)
end
}),
log = setmetatable({}, {
__index = function(table, key)
return get_nested(table, 'log', key)
end
}),
enabled_for = function(lang)
if not lang then return false end
local conf = vim.g.rainbow_delimiters
if not conf then return true end
local whitelist = conf.whitelist
local blacklist = conf.blacklist
if whitelist then
for _, v in ipairs(whitelist) do
if v == lang then return true end
end
return false
end
if blacklist then
for _, v in ipairs(blacklist) do
if v == lang then return false end
end
end
return true
end,
enabled_when = function(bufnr)
local conf = vim.g.rainbow_delimiters
if not conf or not conf.condition then
return true
end
return conf.condition(bufnr)
end
}
setmetatable(M, {
__index = function(table, key)
if key == 'highlight' then
local highlight
if vim.g.rainbow_delimiters then
highlight = rawget(vim.g.rainbow_delimiters, 'highlight')
end
if highlight and #highlight > 0 then return highlight end
highlight = require('rainbow-delimiters.default').highlight
return highlight
end
return rawget(table, key)
end,
})
return M
-- vim:tw=79:ts=4:sw=4:noet:
rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/default.lua 0000664 0000000 0000000 00000004061 15066556776 0025266 0 ustar 00root root 0000000 0000000 --[[
Copyright 2023 Alejandro "HiPhish" Sanchez
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.
--]]
local priorities = (vim.hl or vim.highlight).priorities
---Default plugin configuration.
---@type rainbow_delimiters.config
local M = {
---Query names by file type
query = {
[''] = 'rainbow-delimiters',
javascript = 'rainbow-delimiters-react'
},
---Highlight strategies by file type
strategy = {
[''] = require 'rainbow-delimiters.strategy.global',
},
priority = {
-- Halfway between semantic tokens and Tree-sitter
[''] = math.floor((priorities.semantic_tokens + priorities.treesitter) / 2)
},
---Event logging settings
log = {
---Log level of the module, see `:h log_levels`.
level = vim.log.levels.WARN,
---File name of the log file
file = vim.fn.stdpath('log') .. '/rainbow-delimiters.log',
},
-- Highlight groups in order of display
highlight = {
-- The colours are intentionally not in the usual order to make
-- the contrast between them stronger
'RainbowDelimiterRed',
'RainbowDelimiterYellow',
'RainbowDelimiterBlue',
'RainbowDelimiterOrange',
'RainbowDelimiterGreen',
'RainbowDelimiterViolet',
'RainbowDelimiterCyan',
}
}
---If the key does not exist in the table fall back on the empty string as
---key.
local function get_with_fallback(table, key)
return rawget(table, key) or rawget(table, '')
end
setmetatable(M.query, {
__index = get_with_fallback,
})
setmetatable(M.strategy, {
__index = get_with_fallback,
})
setmetatable(M.priority, {
__index = get_with_fallback,
})
return M
-- vim:tw=79:ts=4:sw=4:noet:
rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/health.lua 0000664 0000000 0000000 00000020036 15066556776 0025107 0 ustar 00root root 0000000 0000000 ---Health check module.
local M = {}
-- In Neovim 0.10 the following functions have been renamed
local start = vim.health.start or vim.health.report_start
local ok = vim.health.ok or vim.health.report_ok
local info = vim.health.info or vim.health.report_info
local warn = vim.health.warn or vim.health.report_warn
local error = vim.health.error or vim.health.report_error
local filewritable = vim.fn.filewritable
local fnamemodify = vim.fn.fnamemodify
local STRATEGY_ADVICE = "See :h rb-delimiters-strategy for the strategy protocol"
local QUERY_ADVICE = "See :h rb-delimiters-query for included standard queries."
local HLGROUP_ADVICE = "Consecutive highlight groups make delimiter levels indistinguishable, use another highlight group."
local SCHEMA_ADVICE = "This might be a typo, see :h g:rainbow_delimiters for valid entries."
---Specification of valid options. The key is the name of an option, the value
---is either true (no further validation) or a table containing the nested
---schema for the option
local schema = {
strategy = true,
query = true,
highlight = true,
priority = true,
blacklist = true,
whitelist = true,
condition = true,
log = {level = true, file = true},
}
---Check whether there is a parser installed for the given language.
---@param lang string
---@return boolean
local function check_parser_installed(lang)
local success = pcall(vim.treesitter.language.inspect, lang)
return success
end
---Check whether the strategy is a valid strategy.
---
---This is not a 100% reliable check; we only test the type of the argument and
---whether the table has the correct fields, but not what the callback
---functions actually do.
---@param strategy rainbow_delimiters.strategy | fun(bufnr: integer): rainbow_delimiters.strategy?
---@return boolean
local function check_strategy(strategy)
if type(strategy) == 'string' then
local success, result = pcall(require, strategy)
if not success then return false end
strategy = result
end
if type(strategy) == 'function' then
local finfo = debug.getinfo(strategy)
return finfo.nparams == 0 or finfo.nparams == 1
end
if type(strategy) == 'table' then
if type(strategy.on_attach) ~= 'function' then
return false
end
if type(strategy.on_detach) ~= 'function' then
return false
end
if type(strategy.on_reset) ~= 'function' then
return false
end
return true
end
return false
end
---Check whether the given query is defined for the given language.
---@param lang string
---@param name string | fun(bufnr: integer): string
---@return boolean
local function check_query(lang, name)
if type(name) == 'function' then
local finfo = debug.getinfo(name)
return finfo.nparams == 0 or finfo.nparams == 1
end
if type(name) == 'string' then
local query = vim.treesitter.query.get(lang, name)
return query ~= nil
end
return false
end
---Check whether the given priority is defined for the given language.
---@param priority integer | fun(bufnr: integer): integer
---@return boolean
local function check_priority(priority)
if type(priority) == 'function' then
local finfo = debug.getinfo(priority)
return finfo.nparams == 0 or finfo.nparams == 1
end
if type(priority) == 'number' then
return true
end
return false
end
---@param settings rainbow_delimiters.logging
local function check_logging(settings)
local level, file = settings.level, settings.file
if level then
-- Note: although the log level is an integer, Lua 5.1 only has the
-- number type
if type(level) ~= 'number' then
error('The log level must be a number', 'See :h vim.log.levels for valid log levels.')
else
ok('Valid log level.')
end
end
if file then
if type(file) ~= 'string' then
error('The log file path must be a string')
elseif filewritable(file) == 0 then
if filewritable(fnamemodify(file, ':h')) == 2 then
ok('Valid location for log file.')
else
local msg = string.format("Cannot write to file '%s'", file)
error(msg)
end
else
ok('Valid log file.')
end
end
local advice = "This might be a typo, see :h rb-delimiters-logging for valid entries."
for option in pairs(settings) do
if not schema.log[option] then
local msg = string.format("Unknown logging option '%s' in settings", option)
warn(msg, advice)
end
end
end
function M.check()
local settings = vim.g.rainbow_delimiters --[[@as rainbow_delimiters.config]]
if not settings then
return
info("No custom configuration; see :h rb-delimiters-setup for information.")
end
local whitelist = settings.whitelist
if whitelist then
start 'Parsers for whitelisted languages'
for _, lang in ipairs(whitelist) do
local success = check_parser_installed(lang)
if success then
local msg = string.format("Parser installed for '%s'", lang)
ok(msg)
else
local msg = string.format("No parser installed for '%s'", lang)
warn(msg)
end
end
end
local strategies = settings.strategy
if strategies then
start 'Custom strategies'
for lang, strategy in pairs(strategies) do
local has_strategy = check_strategy(strategy)
if lang == '' then
if has_strategy then
local msg = 'Valid custom default strategy.'
ok(msg)
else
local msg = 'Invalid custom default strategy.'
error(msg, STRATEGY_ADVICE)
end
else
local has_parser = check_parser_installed(lang)
if not has_parser then
local msg = string.format("No parser installed for '%s'", lang)
error(msg)
end
if not has_strategy then
local msg = string.format("Invalid custom strategy for '%s'", lang)
error(msg, STRATEGY_ADVICE)
end
if has_parser and has_strategy then
local msg = string.format("Valid custom strategy for '%s'.", lang)
ok(msg)
end
end
end
end
local queries = settings.query
if queries then
start 'Custom queries'
for lang, query in pairs(queries) do
if lang == '' then
if query ~= 'rainbow-delimiters' then
local msg = string.format(
"User-defined default query '%s'\
If you meant 'rainbow-delimiters' check for typos",
query
)
ok(msg)
else
local msg = "Valid custom default query"
ok(msg)
end
else
local has_lang = check_parser_installed(lang)
local has_query = check_query(lang, query)
if not has_lang then
local msg = string.format("No parser installed for '%s'.", lang)
warn(msg)
end
if not has_query then
local msg = string.format("No query named '%s' for '%s' found.", query, lang)
warn(msg, QUERY_ADVICE)
end
if has_lang and has_query then
local msg = string.format("Valid custom query for '%s'", lang)
ok(msg)
end
end
end
end
local priorities = settings.priority
if priorities then
start 'Custom priorities'
for lang, priority in pairs(priorities) do
local is_valid_prirority = check_priority(priority)
if lang == '' then
if is_valid_prirority then
local msg = "Valid custom default priority"
ok(msg)
else
local msg = "Invalid custom default priority"
error(msg)
end
else
if is_valid_prirority then
local msg = string.format("Valid custom priority for '%s'", lang)
ok(msg)
else
local msg = string.format("Invalid custom priority for '%s'", lang)
error(msg)
end
end
end
end
local hlgroups = settings.highlight
if hlgroups then
start 'Custom highlight groups'
local previous
for _, hlgroup in ipairs(hlgroups) do
local has_hlgroup = vim.fn.hlID(hlgroup) ~= 0
if has_hlgroup then
ok(string.format("Highlight group '%s' defined.", hlgroup))
else
error(string.format("Highlight group '%s' not defined.", hlgroup))
end
if previous and hlgroup == previous then
local msg = string.format("Consecutive highlight group '%s'", hlgroup)
warn(msg, HLGROUP_ADVICE)
end
previous = hlgroup
end
end
local logging = settings.log
if logging then
start 'Logging settings'
check_logging(logging)
end
for option in pairs(settings) do
if not schema[option] then
local msg = string.format("Unknown option '%s' in settings", option)
warn(msg, SCHEMA_ADVICE)
end
end
end
return M
-- vim:tw=79:ts=4:sw=4:noet:
rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/lib.lua 0000664 0000000 0000000 00000016772 15066556776 0024424 0 ustar 00root root 0000000 0000000 --[[
Copyright 2023 Alejandro "HiPhish" Sanchez
Copyright 2020-2022 Chinmay Dalal
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.
--]]
local get_query = vim.treesitter.query.get
local get_parser = vim.treesitter.get_parser
local log = require 'rainbow-delimiters.log'
local config = require 'rainbow-delimiters.config'
local util = require 'rainbow-delimiters.util'
---[ Internal ]----------------------------------------------------------------
-- The following symbols should only be used internally. In particular, they
-- should not be used by strategies, or else our strategies are using
-- undocumented APIs.
---Private library of shared internal functions and variables.
local M = {}
M.enabled_for = config.enabled_for
---Per-language namespaces. This table instantiates namespaces on demand, i.e.
---a namespace won't exist until we first try to get it from the table.
M.nsids = setmetatable({}, {
__index = function(t, k)
local result = rawget(t, k)
if result == nil then
result = vim.api.nvim_create_namespace('')
rawset(t, k, result)
end
return result
end,
-- Note: this will only catch new indices, not assignment to an already
-- existing key
__newindex = function(_, _, _)
error('Table is immutable')
end
})
---Keeps track of attached buffers. The key is the buffer number and the value
---is a table of information about that buffer (e.g. language, strategy,
---query). This also makes sure we keep track of all parsers in active use to
---prevent them from being garbage-collected.
---@type table
M.buffers = {}
---[ This stuff needs to be re-exported ]--------------------------------------
-- The following entries can be used in the public API as well.
---Fetches the query object for the given language from the settings. If a
---buffer number is given it will be used as the current buffer, otherwise the
---actual current buffer is used.
---
---@param lang string Name of the language to get the query for
---@param bufnr integer Use this buffer as the current buffer
---@return vim.treesitter.Query? query The query object
function M.get_query(lang, bufnr)
local name = config['query'][lang]
if type(name) == "function" then
name = name(bufnr)
end
local query = get_query(lang, name)
if not query then
log.debug('Query %s not found for %s', name, lang)
else
log.trace('Query %s found for %s', name, lang)
end
return query
end
---Apply highlighting to a single node.
---@param bufnr integer Buffer which contains the node
---@param lang string Language of the node (to group HL into namespaces)
---@param node table Node to highlight
---@param hlgroup string Name of the highlight group to apply.
function M.highlight(bufnr, lang, node, hlgroup)
-- range of the capture, zero-indexed
local startRow, startCol, endRow, endCol = node:range()
local start, finish = {startRow, startCol}, {endRow, endCol - 1}
local priority = config.priority[lang]
if type(priority) == "function" then
priority = priority(bufnr)
end
local opts = {
regtype = 'v',
inclusive = true,
priority = priority,
}
local nsid = M.nsids[lang]
if vim.api.nvim_buf_is_loaded(bufnr) then
(vim.hl or vim.highlight).range(bufnr, nsid, hlgroup, start, finish, opts)
end
end
---Get the appropriate highlight group for the given level of nesting.
---@param i integer One-based index into the highlight groups
---@return string hlgroup Name of the highlight groups
function M.hlgroup_at(i)
local hlgroups = config.highlight
return hlgroups[(i - 1) % #hlgroups + 1]
end
---Clears the reserved Rainbow namespace.
---
---@param bufnr integer Number of the buffer for which to clear the namespace
---@param lang string
---@param line_start integer?
---@param line_end integer?
function M.clear_namespace(bufnr, lang, line_start, line_end)
local nsid = M.nsids[lang]
if vim.api.nvim_buf_is_valid(bufnr) then
vim.api.nvim_buf_clear_namespace(bufnr, nsid, line_start or 0, line_end or -1)
end
end
---Start rainbow highlighting for the given buffer
---@param bufnr integer
function M.attach(bufnr)
-- Rainbow delimiters was explicitly disabled for this buffer
if M.buffers[bufnr] == false then return end
local lang = vim.treesitter.language.get_lang(vim.bo[bufnr].ft)
if not lang then
log.trace('Cannot attach to buffer %d, no parser for %s', bufnr, lang)
return
end
log.trace('Attaching to buffer %d with language %s.', bufnr, lang)
local settings = M.buffers[bufnr]
if settings then
-- if M.buffers[bufnr].lang == lang then return end
-- TODO: If the language is the same reload the parser
if settings.lang == lang then
local parser = get_parser(bufnr, lang)
local strategy = settings.strategy
parser:invalidate(true)
parser:parse()
strategy.on_reset(bufnr, settings)
return
end
-- The file type of the buffer has changed, so we need to detach first
-- before we re-attach
M.detach(bufnr)
end
local parser
do
local success
success, parser = pcall(get_parser, bufnr, lang)
if not success then return end
end
local strategy
do
strategy = config.strategy[lang]
if type(strategy) == 'function' then
strategy = strategy(bufnr)
end
if type(strategy) == 'string' then
strategy = require(strategy)
end
end
-- Intentionally abort; the user has explicitly disabled rainbow delimiters
-- for this buffer, usually by setting a strategy- or query function which
-- returned nil.
if not strategy then
log.warn('No strategy defined for %s', lang)
end
if not strategy or strategy == vim.NIL then return end
---@param child vim.treesitter.LanguageTree
local function f(child)
if child:lang() ~= lang then
M.clear_namespace(bufnr, child:lang())
end
end
parser:register_cbs {
---@param bnr integer
on_detach = function(bnr)
if not M.buffers[bnr] then return end
M.detach(bufnr)
end,
on_child_removed = f,
}
settings = {
strategy = strategy,
parser = parser,
lang = lang
}
M.buffers[bufnr] = settings
-- For now we silently discard errors, but in the future we should log
-- them.
local success, error = pcall(strategy.on_attach, bufnr, settings)
if not success then
log.error('Error attaching strategy to buffer %d: %s', bufnr, error)
M.buffers[bufnr] = nil
end
end
---Start rainbow highlighting for the given buffer
---@param bufnr integer
function M.detach(bufnr)
log.trace('Detaching from buffer %d.', bufnr)
if not M.buffers[bufnr] then
return
end
local strategy = M.buffers[bufnr].strategy
local parser = M.buffers[bufnr].parser
-- Clear all the namespaces for each language
util.for_each_child(nil, parser:lang(), parser, function(_, lang)
M.clear_namespace(bufnr, lang)
end)
-- Finally release all resources the parser is holding on to
parser:destroy()
-- For now we silently discard errors, but in the future we should log
-- them.
local success, error = pcall(strategy.on_detach, bufnr)
if not success then
log.error('Error detaching strategy from buffer %d: %s', bufnr, error)
end
M.buffers[bufnr] = nil
end
return M
-- vim:tw=79:ts=4:sw=4:noet:
rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/log.lua 0000664 0000000 0000000 00000005323 15066556776 0024425 0 ustar 00root root 0000000 0000000 --[[
Copyright 2023 Alejandro "HiPhish" Sanchez
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.
--]]
---Logger module for rainbow delimiters. Logs any message whose log level is
---equal to or greater than the log level of the module.
local M = {}
local date = os.date
local levels = vim.log.levels
local config = require 'rainbow-delimiters.config'
---Reverse lookup table; maps a log level to its text label
local level_str = {}
for key, value in pairs(levels) do
level_str[value] = key
end
---Dynamically determines the module from which the log function was called.
---If it was called from somewhere else return the name of the plugin.
---@return string
local function get_module()
local module = debug.getinfo(4, 'S').source:match('^.+rainbow%-delimiters/(.+).lua$')
if not module then
return ''
end
return module:gsub('/', '.')
end
---@param file file*
---@param level integer
---@param module string
---@param message any
---@param ... any
local function write_log(file, level, module, message, ...)
local msg
local timestamp = date('%FT%H:%M%z')
if type(message) == 'function' then
msg = message()
else
msg = string.format(message, ...)
end
file:write(string.format('%s %s %s %s\n', timestamp, level, module, msg))
end
---@param level integer
---@param message any
---@param ... any
local function log(level, message, ...)
if level < config.log.level then return end
local file = io.open(config.log.file, 'a+')
-- Intentional: Silently discard the log if the log file cannot be opened
if not file then return end
-- Wrap inside a pcall to make sure the file gets closed even if an error
-- occurs
pcall(write_log, file, level_str[level], get_module(), message, ...)
file:close()
-- Should I also print the message?
end
---Log an error message
function M.error(message, ...)
log(levels.ERROR, message, ...)
end
---Log a warning message
function M.warn(message, ...)
log(levels.WARN, message, ...)
end
---Log a tracing message
function M.debug(message, ...)
log(levels.DEBUG, message, ...)
end
---Log a tracing message
function M.trace(message, ...)
log(levels.TRACE, message, ...)
end
---Log an info message
function M.info(message, ...)
log(levels.INFO, message, ...)
end
return M
-- vim:tw=79:ts=4:sw=4:noet:
rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/match-tree.lua 0000664 0000000 0000000 00000010153 15066556776 0025672 0 ustar 00root root 0000000 0000000 ---Functions for dealing with match trees. This library is only relevant to
---strategy authors. A match tree is the tree-like structure we use to
---organize a subset of the buffer's node tree for highlighting.
local M = {}
local lib = require 'rainbow-delimiters.lib'
local Set = require 'rainbow-delimiters.set'
---A single match from the query. All matches contain the same fields, which
---correspond to the captures from the query. Matches are hierarchical and can
---be arranged in a tree where the container of a parent match contains all the
---nodes of the descendant matches.
---@class rainbow_delimiters.Match
---The container node.
---@field container vim.treesitter.TSNode
---Sentinel node, marks the last delimiter of the match.
---@field sentinel vim.treesitter.TSNode
---The actual delimiters we want to highlight, there can be any number of them.
---@field delimiters rainbow_delimiters.Set
---A hierarchical structure of nested matches. Each node of the tree consists
---of exactly one match and a set of any number of child matches. Terminal
---matches have no children.
---
---Match trees have a strict partial ordering: for two matches `m1` and `m2` we
---say that `m1` < `m2` if and only if the container of `m1` contains the
---container of `m2`, i.e. `m1` is an ancestor of `m2`. The root node will
---have the lowest value.
---@class rainbow_delimiters.MatchTree
---The match object
---@field public match rainbow_delimiters.Match
---The children of the match
---@field public children rainbow_delimiters.Set
local match_mt = {
__tostring = function(self)
return string.format(
'{container = %s, delimiters = %s}',
tostring(self.container),
tostring(self.delimiters)
)
end
}
local tree_mt = {
---@param m1 rainbow_delimiters.MatchTree
---@param m2 rainbow_delimiters.MatchTree
---@return boolean
__lt = function(m1, m2)
local c1 = m1.match.container
local r2 = {m2.match.container:range()}
return vim.treesitter.node_contains(c1, r2)
end,
---Appends the given match tree `m2` to this match tree. Will traverse
---through the descendants until it finds the most appropriate one.
---@return boolean success Whether appending was successfull
__call = function(self, other)
if not (self < other) then return false end
for child in self.children:items() do
if child < other then
return child(other)
end
end
self.children:add(other)
return true
end,
__tostring = function(self)
return string.format(
'{match = %s, children = %s}',
tostring(self.match),
tostring(self.children)
)
end
}
---Instantiate a new match tree node without children based on the results of
---the `iter_matches` method of a query.
---@param query vim.treesitter.Query
---@param match Table
---@return rainbow_delimiters.MatchTree
function M.assemble(query, match)
local result = {delimiters = Set.new()}
for id, nodes in pairs(match) do
local capture = query.captures[id]
if capture == 'delimiter' then
-- It is expected for a match to contain any number of delimiters
for _, node in ipairs(nodes) do
result.delimiters:add(node)
end
else
-- We assume that there is only ever exactly one node per
-- non-delimiter capture
result[capture] = nodes[1]
end
end
---@type rainbow_delimiters.MatchTree
local matchtree = {
match = setmetatable(result, match_mt),
children = Set.new(),
}
return setmetatable(matchtree, tree_mt)
end
---Apply highlighting to a given match tree at a given level
---@param bufnr integer
---@param lang string
---@param tree rainbow_delimiters.MatchTree
---@param level integer Highlight level of this tree
---@param pred (fun(rainbow_delimiters): boolean)? Predicate function, will abort highlighting if it evaluates to `false` at any point down the tree for that branch only.
function M.highlight(tree, bufnr, lang, level, pred)
if pred and not pred(tree) then return end
local hlgroup = lib.hlgroup_at(level)
for delimiter in tree.match.delimiters:items() do
lib.highlight(bufnr, lang, delimiter, hlgroup)
end
for child in tree.children:items() do
M.highlight(child, bufnr, lang, level + 1, pred)
end
end
return M
rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/set.lua 0000664 0000000 0000000 00000005151 15066556776 0024436 0 ustar 00root root 0000000 0000000 --[[
Copyright 2024 Alejandro "HiPhish" Sanchez
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.
--]]
---Helper library for set-like tables.
local M = {}
---A set-like structure which holds any number of items, but only one of each.
---@generic T
---@class rainbow_delimiters.Set
---
---Add an item to the set; this function is idempotent: adding an item more
---than once produces the same result
---@field public add fun(self: rainbow_delimiters.Set, item: `T`): nil
---
---Predicate whether the set currently contains a given item
---@field public contains fun(self: rainbow_delimiters.Set, item: `T`): boolean
---
---Returns the current size of the set
---@field public size fun(self: rainbow_delimiters.Set): integer
---@field package content `T`[]
---
---Iterator which returns the contents one at a time in an arbitrary order.
---@field public items fun(self: rainbow_delimiters.Set): ((fun(content: table<`T`, true>, key: `T`): `T`), table<`T`, true>)
local function size(self)
local result = 0
for _, _ in pairs(self.content) do
result = result + 1
end
return result
end
local function add(self, item)
self.content[item] = true
end
local function contains(self, item)
return self.content[item] == true
end
---Wrapper around the built-in `next`, except that it only returns the key.
local function iter(t, k)
local result = next(t, k)
return result
end
local function items(self)
return iter, self.content
end
local function pick_key(key, _value)
return key
end
local mt = {
---A human-readable representation of a set like `'Set{1, 2, "a", "b"}'`
---@param self rainbow_delimiters.Set
---@return string
__tostring = function(self)
local keys = vim.iter(self.content)
:map(pick_key)
:map(tostring)
:join(', ')
return string.format('Set{%s}', keys)
end
}
---@return rainbow_delimiters.Set set The new set instance
function M.new(...)
---@type rainbow_delimiters.Set
local result = {
content = {},
size = size,
add = add,
contains = contains,
items = items,
}
for _, item in ipairs({...}) do
result.content[item] = true
end
setmetatable(result, mt)
return result
end
return M
rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/setup.lua 0000664 0000000 0000000 00000000770 15066556776 0025005 0 ustar 00root root 0000000 0000000 local M = {}
---Apply the given configuration to the rainbow-delimiter settings. Will
---overwrite existing settings.
---
---@param opts rainbow_delimiters.config Settings, same format as `vim.g.rainbow_delimiters`
function M.setup(opts)
vim.g.rainbow_delimiters = opts
end
-- Make it possible to call the module directly; for backwards compatibility
-- with a previous version of this module.
setmetatable(M, {__call = function(_t, opts) M.setup(opts) end})
return M
-- vim:tw=79:ts=4:sw=4:noet:
rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/stack.lua 0000664 0000000 0000000 00000007020 15066556776 0024745 0 ustar 00root root 0000000 0000000 --[[
Copyright 2023 Alejandro "HiPhish" Sanchez
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.
--]]
---Helper library for stack-like tables.
local M = {}
---@class (exact) Stack
---@field public size fun(self: Stack): integer
---@field public peek fun(self: Stack): any
---@field public push fun(self: Stack, item: any): Stack
---@field public pop fun(self: Stack): any
---@field public iter fun(self: Stack): ((fun(i: integer, item: any): integer?, any), Stack, integer)
---@field package content any[]
---The stack metatable.
local mt = {}
---The actual iterator implementation, hidden behind the iter-method.
---@param stack Stack
---@param i integer
---@return integer?
---@return any
local function iter_stack(stack, i)
if i <= 1 then return end
return i - 1, stack.content[i - 1]
end
---@param stack Stack
---@return string
local function stack_tostring(stack)
local items = {}
for _, item in ipairs(stack.content) do
items[#items + 1] = tostring(item)
end
return string.format('[%s]', table.concat(items, ', '))
end
---[ Methods ]-----------------------------------------------------------------
---Returns the current number of items in the stack.
---@param self Stack
---@return integer size Current size of the stack
local function size(self)
return #self.content
end
---Iterate through the content of the stack from top to bottom. Each iteration
---returns the current index (one-based, counting from the bottom) and the
---current item.
---@param self Stack The stack instance
---@return fun(i: integer, stack: Stack): integer?, any
---@return Stack
---@return integer
local function iter(self)
return iter_stack, self, self:size() + 1
end
---Add a new item to the top of the stack. Modifies the stack in-place.
---@param item any The item to push onto the stack
---@return Stack stack The stack.
local function push(self, item)
self.content[self:size() + 1] = item
return self
end
---Returns the topmost item of the stack without altering the stack.
---@return any top The top-most item.
local function peek(self)
local result = self.content[self:size()]
return result
end
---Returns the topmost item of the stack and removes it from the stack.
---@return any top The top-most item.
local function pop(self)
local n = self:size()
local result = self.content[n]
self.content[n] = nil
return result
end
---[ Public module interface ]-------------------------------------------------
---Instantiates a new stack containing the given items, or the empty stack if
---the argument is `nil`.
---@param items any[]? Array of items in order from bottom to top
---@return Stack stack The new stack instance
function M.new(items)
---@type Stack
local result = {
content = {},
size = size,
iter = iter,
push = push,
pop = pop,
peek = peek,
}
setmetatable(result, mt)
for _, item in ipairs(items or {}) do result:push(item) end
return result
end
---[ Metamethods ]-------------------------------------------------------------
mt.__tostring = stack_tostring
return M
-- vim:tw=79:ts=4:sw=4:noet:
rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/strategy/ 0000775 0000000 0000000 00000000000 15066556776 0025000 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/strategy/christmas.lua 0000664 0000000 0000000 00000004446 15066556776 0027510 0 ustar 00root root 0000000 0000000 --[[
Copyright 2023 Alejandro "HiPhish" Sanchez
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.
--]]
---Strategy decorator which makes your delimiters change colours like Christmas
---lights. This module is meant as a joke and will not be loaded by default
---with the rest of the plugin.
local M = {}
local uv = vim.loop
local lib = require 'rainbow-delimiters.lib'
local original_hlgroup_at = lib.hlgroup_at
local counter = 0
---Wrapper around the original function which applies some offset to the index.
---@param i integer
---@return string hlgroup
local function patched_hlgroup_at(i)
return original_hlgroup_at(counter + i)
end
---Wraps the given strategy with a new strategy that switches colours like a
---chain of Christmas lights.
---@param strategy rainbow_delimiters.strategy? Original strategy (default global)
---@param delay integer? Time between switches in milliseconds (default 500)
---@return rainbow_delimiters.strategy christmas_lights A new strategy object
function M.lights(strategy, delay)
strategy = strategy or require 'rainbow-delimiters.strategy.global'
delay = delay or 500
local timer = uv.new_timer()
---@param bufnr integer
---@param settings rainbow_delimiters.buffer_settings
local function on_attach(bufnr, settings)
local function blink()
counter = counter + 1
local function callback()
lib.hlgroup_at = patched_hlgroup_at
strategy.on_reset(bufnr, lib.buffers[bufnr])
lib.hlgroup_at = original_hlgroup_at
end
vim.schedule(callback)
end
timer:start(0, delay, blink)
strategy.on_attach(bufnr, settings)
end
---@param bufnr integer
local function on_detach(bufnr)
timer:stop()
strategy.on_detach(bufnr)
end
return {
strategy = strategy,
on_attach = on_attach,
on_detach = on_detach,
on_reset = strategy.on_reset,
}
end
return M
rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/strategy/global.lua 0000664 0000000 0000000 00000002021 15066556776 0026736 0 ustar 00root root 0000000 0000000 --[[
Copyright 2024 Alejandro "HiPhish" Sanchez
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.
--]]
-- Neovim 0.10 changed the (undocumented) behaviour of Query:iter_captures(),
-- so we need a different implementation for that version.
--
-- https://github.com/neovim/neovim/issues/27296
---@type rainbow_delimiters.strategy
local strategy
if vim.fn.has 'nvim-0.10' ~= 0 then
strategy = require 'rainbow-delimiters.strategy.global.current'
else
strategy = require 'rainbow-delimiters.strategy.global.legacy'
end
return strategy
rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/strategy/global/ 0000775 0000000 0000000 00000000000 15066556776 0026240 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/strategy/global/current.lua 0000664 0000000 0000000 00000015067 15066556776 0030436 0 ustar 00root root 0000000 0000000 --[[
Copyright 2024 Alejandro "HiPhish" Sanchez
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.
--]]
local lib = require 'rainbow-delimiters.lib'
local util = require 'rainbow-delimiters.util'
local log = require 'rainbow-delimiters.log'
local Stack = require 'rainbow-delimiters.stack'
local MatchTree = require 'rainbow-delimiters.match-tree'
---Changes are range objects and come in two variants: one with four entries and
---one with six entries. We only want the four-entry variant. See
---`:h TSNode:range()`
---@param change integer[]
---@return integer[]
local function normalize_change(change)
local result
if #change == 4 then
result = change
elseif #change == 6 then
result = {change[1], change[2], change[4], change[5]}
else
result = {}
end
return result
end
---Update highlights for a range. Called every time text is changed.
---@param bufnr integer Buffer number
---@param changes table List of node ranges in which the changes occurred
---@param tree vim.treesitter.TSTree TS tree
---@param lang string Language
local function update_range(bufnr, changes, tree, lang)
log.debug('Updated range with changes %s', vim.inspect(changes))
if not lib.enabled_for(lang) or vim.fn.pumvisible() ~= 0 then
return
end
local query = lib.get_query(lang, bufnr)
if not query then return end
---Temporary stack of partial match trees; used to build the final match trees
local root_node = tree:root()
-- Build the match tree
for _, change in ipairs(changes) do
local match_trees = Stack.new()
local start_row, end_row = change[1], change[3] + 1
lib.clear_namespace(bufnr, lang, start_row, end_row)
for _, match in query:iter_matches(root_node, bufnr, start_row, end_row, {all=true}) do
---@type rainbow_delimiters.MatchTree
local this = MatchTree.assemble(query, match)
while match_trees:size() > 0 do
local other = match_trees:pop()
if this < other then
this(other)
else
match_trees:push(other)
break
end
end
match_trees:push(this)
end
for _, match_tree in match_trees:iter() do
MatchTree.highlight(match_tree, bufnr, lang, 1)
end
end
end
---Update highlights for every tree in given buffer.
---@param bufnr integer # Buffer number
---@param parser vim.treesitter.LanguageTree
local function full_update(bufnr, parser)
log.debug('Performing full updated on buffer %d', bufnr)
local function callback(tree, sub_parser)
local changes = {{tree:root():range()}}
update_range(bufnr, changes, tree, sub_parser:lang())
end
parser:for_each_tree(callback)
end
---Sets up all the callbacks and performs an initial highlighting
---@param bufnr integer # Buffer number
---@param parser vim.treesitter.LanguageTree
---@param start_parent_lang string? # Parent language or nil
local function setup_parser(bufnr, parser, start_parent_lang)
log.debug('Setting up parser for buffer %d', bufnr)
---Sets up an individual parser for a particular language
---@param p vim.treesitter.LanguageTree Parser for that language
---@param lang string The language
local function f(p, lang, parent_lang)
log.debug("Setting up parser for '%s' in buffer %d", lang, bufnr)
-- Skip languages which are not supported, otherwise we get a
-- nil-reference error
if not lib.get_query(lang, bufnr) then return end
local function on_changedtree(changes, tree)
log.trace('Changed tree in buffer %d with languages %s', bufnr, lang)
-- HACK: As of Neovim v0.9.1 there is no way of unregistering a
-- callback, so we use this check to abort
if not lib.buffers[bufnr] then return end
-- Collect changes to pass on to the next step; might have to treat
-- injected languages differently.
if not parent_lang then
-- If we have no parent language, then we use changes, otherwise we use the
-- whole tree's range.
-- Normalize the changes object if we have no parent language (the one we
-- get from on_changedtree)
changes = vim.tbl_map(normalize_change, changes)
elseif parent_lang ~= lang and changes[1] then
-- We have a parent language, so we are in an injected language code
-- block, thus we update all of the current code block
changes = {{tree:root():range()}}
else
-- some languages (like rust) use injections of the language itself for
-- certain functionality (e.g., macros in rust). For these the
-- highlighting will be updated by the non-injected language part of the
-- code.
changes = {}
end
-- TODO
-- Clear extmarks if a line has been moved across languages
--
-- TODO
-- Update the range
-- only update highlighting if we have changes
if changes[1] then
update_range(bufnr, changes, tree, lang)
end
end
---New languages can be added into the text at some later time, e.g.
---code snippets in Markdown
---@param child vim.treesitter.LanguageTree
local function on_child_added(child)
setup_parser(bufnr, child, lang)
end
p:register_cbs {
on_changedtree = on_changedtree,
on_child_added = on_child_added,
}
log.trace("Done with setting up parser for '%s' in buffer %d", lang, bufnr)
end
-- A buffer has one primary language and potentially many child languages
-- which may have child languages of their own. We need to set up the
-- parser for each of them.
util.for_each_child(start_parent_lang, parser:lang(), parser, f)
full_update(bufnr, parser)
end
---@param bufnr integer
---@param settings rainbow_delimiters.buffer_settings
local function on_attach(bufnr, settings)
log.trace('global strategy on_attach for buffer %d', bufnr)
local parser = settings.parser
setup_parser(bufnr, parser, nil)
end
---@param bufnr integer
local function on_detach(bufnr)
log.trace('global strategy on_detach for buffer %d', bufnr)
end
---@param bufnr integer
---@param settings rainbow_delimiters.buffer_settings
local function on_reset(bufnr, settings)
log.trace('global strategy on_reset for buffer %d', bufnr)
full_update(bufnr, settings.parser)
end
---Strategy which highlights all delimiters in the current buffer.
---@type rainbow_delimiters.strategy
return {
on_attach = on_attach,
on_detach = on_detach,
on_reset = on_reset,
}
rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/strategy/global/legacy.lua 0000664 0000000 0000000 00000024573 15066556776 0030222 0 ustar 00root root 0000000 0000000 --[[
Copyright 2023 Alejandro "HiPhish" Sanchez
Copyright 2020-2022 Chinmay Dalal
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.
--]]
local Stack = require 'rainbow-delimiters.stack'
local lib = require 'rainbow-delimiters.lib'
local util = require 'rainbow-delimiters.util'
local log = require 'rainbow-delimiters.log'
---Strategy which highlights the entire buffer.
local M = {}
---Changes are range objects and come in two variants: one with four entries and
---one with six entries. We only want the four-entry variant. See
---`:h TSNode:range()`
---@param change integer[]
---@return integer[]
local function normalize_change(change)
local result
if #change == 4 then
result = change
elseif #change == 6 then
result = {change[1], change[2], change[4], change[5]}
else
result = {}
end
return result
end
---@param bufnr integer
---@param lang string
---@param matches Stack
---@param level integer
local function highlight_matches(bufnr, lang, matches, level)
local hlgroup = lib.hlgroup_at(level)
for _, match in matches:iter() do
for _, delimiter in match.delimiter:iter() do lib.highlight(bufnr, lang, delimiter, hlgroup) end
highlight_matches(bufnr, lang, match.children, level + 1)
end
end
---Create a new empty match_record
---@return table
local function new_match_record()
return {
delimiter = Stack.new(),
children = Stack.new(),
}
end
---Update highlights for a range. Called every time text is changed.
---@param bufnr integer Buffer number
---@param changes table List of node ranges in which the changes occurred
---@param tree TSTree TS tree
---@param lang string Language
local function update_range(bufnr, changes, tree, lang)
log.debug('Updated range with changes %s', vim.inspect(changes))
if not lib.enabled_for(lang) then return end
if vim.fn.pumvisible() ~= 0 or not lang then return end
local query = lib.get_query(lang, bufnr)
if not query then return end
local matches = Stack.new()
for _, change in ipairs(changes) do
-- This is the match record, it lists all the relevant nodes from
-- each match.
---@type table?
local match_record
local root_node = tree:root()
local start_row, end_row = change[1], change[3] + 1
lib.clear_namespace(bufnr, lang, start_row, end_row)
for qid, node, _ in query:iter_captures(root_node, bufnr, start_row, end_row) do
local name = query.captures[qid]
-- check for 'delimiter' first, since that should be the most
-- common name
if name == 'delimiter' and match_record then
match_record.delimiter:push(node)
elseif name == 'container' and not match_record then
match_record = new_match_record()
elseif name == 'container' then
-- temporarily push the match_record to matches to be retrieved
-- later, since we haven't closed it yet
matches:push(match_record)
match_record = new_match_record()
-- since we didn't close the previous match_record, it must
-- mean that the current match_record has it as an ancestor
match_record.has_ancestor = true
elseif name == 'sentinel' and match_record then
-- if we see the sentinel, then we are done with the current
-- container
if match_record.has_ancestor then
local prev_match_record = matches:pop()
if prev_match_record then
-- since we have an ancestor, it has to be the last
-- element of the stack
prev_match_record.children:push(match_record)
match_record = prev_match_record
else
-- since match_record.has_ancestor was true, we shouldn't
-- be able to get to here unless something went wrong
-- with the queries or treesitter itself
log.error([[You are missing a @container,
which should be impossible!
Please double check the queries.]])
end
else
-- if match_record doesn't have an ancestor, the sentinel
-- means that we are done with it
matches:push(match_record)
match_record = nil
end
elseif (name == 'delimiter' or name == 'sentinel') and not match_record then
log.error([[You query got the capture name %s.
But it didn't come with a container, which should be impossible!
Please double check your queries.]], name)
end -- do nothing with other capture names
end
if match_record then
-- we might have a dangling match_record, so we push it back into
-- matches
-- this should only happen when the query is on a proper subset
-- of the full tree (usually just one line)
matches:push(match_record)
end
end
-- when we capture on a row and not the full tree, we get the previous
-- containers (on earlier rows) included in the above, but not the
-- delimiters and sentinels from them, so we push them up as long as
-- we know they have an ancestor
local last_match = matches:pop()
while last_match and last_match.has_ancestor do
local prev_match = matches:pop()
if prev_match then
prev_match.children:push(last_match)
else
log.error('You are in what should be an unreachable position.')
end
last_match = prev_match
end
matches:push(last_match)
highlight_matches(bufnr, lang, matches, 1)
end
---Update highlights for every tree in given buffer.
---@param bufnr integer # Buffer number
---@param parser vim.treesitter.LanguageTree
local function full_update(bufnr, parser)
log.debug('Performing full updated on buffer %d', bufnr)
local function callback(tree, sub_parser)
local changes = {{tree:root():range()}}
update_range(bufnr, changes, tree, sub_parser:lang())
end
parser:for_each_tree(callback)
end
---Sets up all the callbacks and performs an initial highlighting
---@param bufnr integer # Buffer number
---@param parser vim.treesitter.LanguageTree
---@param start_parent_lang string? # Parent language or nil
local function setup_parser(bufnr, parser, start_parent_lang)
log.debug('Setting up parser for buffer %d', bufnr)
util.for_each_child(start_parent_lang, parser:lang(), parser, function(p, lang, parent_lang)
log.debug("Setting up parser for '%s' in buffer %d", lang, bufnr)
-- Skip languages which are not supported, otherwise we get a
-- nil-reference error
if not lib.get_query(lang, bufnr) then return end
p:register_cbs {
---@param changes table
---@param tree TSTree
on_changedtree = function(changes, tree)
log.trace('Changed tree in buffer %d with languages %s', bufnr, lang)
-- HACK: As of Neovim v0.9.1 there is no way of unregistering a
-- callback, so we use this check to abort
if not lib.buffers[bufnr] then return end
-- HACK: changes can accidentally overwrite highlighting in injected code
-- blocks.
if not parent_lang then
-- If we have no parent language, then we use changes, otherwise we use the
-- whole tree's range.
-- Normalize the changes object if we have no parent language (the one we
-- get from on_changedtree)
changes = vim.tbl_map(normalize_change, changes)
elseif parent_lang ~= lang and changes[1] then
-- We have a parent language, so we are in an injected language code
-- block, thus we update all of the current code block
changes = {{tree:root():range()}}
else
-- some languages (like rust) use injections of the language itself for
-- certain functionality (e.g., macros in rust). For these the
-- highlighting will be updated by the non-injected language part of the
-- code.
changes = {}
end
-- If a line has been moved from another region it will still carry with it
-- the extmarks from the old region. We need to clear all extmarks which
-- do not belong to the current language
for _, change in ipairs(changes) do
for key, nsid in pairs(lib.nsids) do
if key ~= lang then
-- HACK: changes in the main language sometimes need to overwrite
-- highlighting on one more line
local line_end = change[3] + (parent_lang and 0 or 1)
vim.api.nvim_buf_clear_namespace(bufnr, nsid, change[1], line_end)
end
end
end
-- only update highlighting if we have changes
if changes[1] then
update_range(bufnr, changes, tree, lang)
end
-- HACK: Since we update the whole tree when we have a parent
-- language, we need to make sure to then update all children
-- too, even if there is no change in them. This shouldn't
-- affect performance, since it only affects code nested at
-- least 2 injection languages deep.
if parent_lang then
local children = p:children()
for child_lang, child in pairs(children) do
if lang == child_lang then return end
child:for_each_tree(function(child_tree, child_p)
local child_changes = {{child_tree:root():range()}}
-- we don't need to remove old extmarks, since
-- the above code will handle that correctly
-- already, but we might have accidentally
-- removed extmarks that we need to set again
update_range(bufnr, child_changes, child_tree, child_p:lang())
end)
end
end
end,
-- New languages can be added into the text at some later time, e.g.
-- code snippets in Markdown
---@param child vim.treesitter.LanguageTree
on_child_added = function(child)
setup_parser(bufnr, child, lang)
end,
}
log.trace("Done with setting up parser for '%s' in buffer %d", lang, bufnr)
end)
full_update(bufnr, parser)
end
---on_attach implementation for the global strategy
---@param bufnr integer
---@param settings rainbow_delimiters.buffer_settings
function M.on_attach(bufnr, settings)
log.trace('global strategy on_attach')
local parser = settings.parser
setup_parser(bufnr, parser, nil)
end
---on_detach implementation for the global strategy
---@param _bufnr integer
function M.on_detach(_bufnr)
end
---on_reset implementation for the global strategy
---@param bufnr integer
---@param settings rainbow_delimiters.buffer_settings
function M.on_reset(bufnr, settings)
log.trace('global strategy on_reset')
full_update(bufnr, settings.parser)
end
return M --[[@as rainbow_delimiters.strategy]]
-- vim:tw=79:ts=4:sw=4:noet:
rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/strategy/local.lua 0000664 0000000 0000000 00000002020 15066556776 0026567 0 ustar 00root root 0000000 0000000 --[[
Copyright 2024 Alejandro "HiPhish" Sanchez
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.
--]]
-- Neovim 0.10 changed the (undocumented) behaviour of Query:iter_captures(),
-- so we need a different implementation for that version.
--
-- https://github.com/neovim/neovim/issues/27296
---@type rainbow_delimiters.strategy
local strategy
if vim.fn.has 'nvim-0.10' ~= 0 then
strategy = require 'rainbow-delimiters.strategy.local.current'
else
strategy = require 'rainbow-delimiters.strategy.local.legacy'
end
return strategy
rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/strategy/local/ 0000775 0000000 0000000 00000000000 15066556776 0026072 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/strategy/local/current.lua 0000664 0000000 0000000 00000021607 15066556776 0030265 0 ustar 00root root 0000000 0000000 --[[
Copyright 2024 Alejandro "HiPhish" Sanchez
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.
--]]
-- NOTE: This is mostly a copy-paste of the global strategy with some extra
-- code to only highlight the current scope. It is inefficient because it
-- computes the match trees on every cursor movement. What we want instead is
-- to compute the match trees only when changes occur and cache them. When the
-- cursor moves reference the match trees from the cache and only updated the
-- highlighting.
--
-- My problem is that in order for this to properly work I also have to handle
-- injections. I have no idea how this could be done though; I would somehow
-- need on every cursor movement to clear all highlighting in the buffer
-- (easy), then get the language at the current cursor position (how?) and
-- update the highlighting from that.
local lib = require 'rainbow-delimiters.lib'
local util = require 'rainbow-delimiters.util'
local log = require 'rainbow-delimiters.log'
local api = vim.api
local ts = vim.treesitter
local Stack = require 'rainbow-delimiters.stack'
local MatchTree = require 'rainbow-delimiters.match-tree'
---Reusable autogroup for events in this strategy.
---@type integer
local augroup = api.nvim_create_augroup('TSRainbowLocalCursor', {})
---Helper function, find the lowest container node which contains the cursor.
---@param query vim.treesitter.Query
---@param tree vim.treesitter.TSTree
---@param bufnr integer
---@return vim.treesitter.TSNode?
local function find_cursor_container(query, tree, bufnr)
local result
local curpos = api.nvim_win_get_cursor(0)
-- The order of traversal guarantees that the first match which
-- contains the cursor is also the lowest one.
for _, match in query:iter_matches(tree:root(), bufnr, 0, -1, {all=false}) do
if result then break end
for id, node in pairs(match) do
local name = query.captures[id]
if name == 'container' and ts.is_in_node_range(node, curpos[1] - 1, curpos[2]) then
result = node
break
end
end
end
return result
end
---Changes are range objects and come in two variants: one with four entries and
---one with six entries. We only want the four-entry variant. See
---`:h TSNode:range()`
---@param change integer[]
---@return integer[]
local function normalize_change(change)
local result
if #change == 4 then
result = change
elseif #change == 6 then
result = {change[1], change[2], change[4], change[5]}
else
result = {}
end
return result
end
---Update highlights for a range. Called every time text is changed.
---@param bufnr integer Buffer number
---@param changes table List of node ranges in which the changes occurred
---@param tree vim.treesitter.TSTree TS tree
---@param lang string Language
local function update_range(bufnr, changes, tree, lang)
log.debug('Updated range with changes %s', vim.inspect(changes))
if not lib.enabled_for(lang) or vim.fn.pumvisible() ~= 0 then
return
end
local query = lib.get_query(lang, bufnr)
if not query then return end
local cursor_container = find_cursor_container(query, tree, bufnr)
---Temporary stack of partial match trees; used to build the final match trees
local root_node = tree:root()
-- Build the match tree
for _, change in ipairs(changes) do
local match_trees = Stack.new()
local start_row, end_row = change[1], change[3] + 1
lib.clear_namespace(bufnr, lang, start_row, end_row)
for _, match in query:iter_matches(root_node, bufnr, start_row, end_row, {all=true}) do
---@type rainbow_delimiters.MatchTree
local this = MatchTree.assemble(query, match)
while match_trees:size() > 0 do
local other = match_trees:pop()
if this < other then
this(other)
else
match_trees:push(other)
break
end
end
match_trees:push(this)
end
local function proceed(match_tree)
local this = match_tree.match.container
return ts.is_ancestor(cursor_container, this)
or ts.is_ancestor(this, cursor_container)
or this == cursor_container
end
for _, match_tree in match_trees:iter() do
MatchTree.highlight(match_tree, bufnr, lang, 1, proceed)
end
end
end
---Update highlights for every tree in given buffer.
---@param bufnr integer # Buffer number
---@param parser vim.treesitter.LanguageTree
local function full_update(bufnr, parser)
log.debug('Performing full updated on buffer %d', bufnr)
local function callback(tree, sub_parser)
local changes = {{tree:root():range()}}
update_range(bufnr, changes, tree, sub_parser:lang())
end
parser:for_each_tree(callback)
end
---Sets up all the callbacks and performs an initial highlighting
---@param bufnr integer # Buffer number
---@param parser vim.treesitter.LanguageTree
---@param start_parent_lang string? # Parent language or nil
local function setup_parser(bufnr, parser, start_parent_lang)
log.debug('Setting up parser for buffer %d', bufnr)
---Sets up an individual parser for a particular language
---@param p vim.treesitter.LanguageTree Parser for that language
---@param lang string The language
local function f(p, lang, parent_lang)
log.debug("Setting up parser for '%s' in buffer %d", lang, bufnr)
-- Skip languages which are not supported, otherwise we get a
-- nil-reference error
if not lib.get_query(lang, bufnr) then return end
local function on_changedtree(changes, tree)
log.trace('Changed tree in buffer %d with languages %s', bufnr, lang)
-- HACK: As of Neovim v0.9.1 there is no way of unregistering a
-- callback, so we use this check to abort
if not lib.buffers[bufnr] then return end
-- Collect changes to pass on to the next step; might have to treat
-- injected languages differently.
if not parent_lang then
-- If we have no parent language, then we use changes, otherwise we use the
-- whole tree's range.
-- Normalize the changes object if we have no parent language (the one we
-- get from on_changedtree)
changes = vim.tbl_map(normalize_change, changes)
elseif parent_lang ~= lang and changes[1] then
-- We have a parent language, so we are in an injected language code
-- block, thus we update all of the current code block
changes = {{tree:root():range()}}
else
-- some languages (like rust) use injections of the language itself for
-- certain functionality (e.g., macros in rust). For these the
-- highlighting will be updated by the non-injected language part of the
-- code.
changes = {}
end
-- TODO
-- Clear extmarks if a line has been moved across languages
--
-- TODO
-- Update the range
-- only update highlighting if we have changes
if changes[1] then
update_range(bufnr, changes, tree, lang)
end
end
---New languages can be added into the text at some later time, e.g.
---code snippets in Markdown
---@param child vim.treesitter.LanguageTree
local function on_child_added(child)
setup_parser(bufnr, child, lang)
end
p:register_cbs {
on_changedtree = on_changedtree,
on_child_added = on_child_added,
}
log.trace("Done with setting up parser for '%s' in buffer %d", lang, bufnr)
end
-- A buffer has one primary language and potentially many child languages
-- which may have child languages of their own. We need to set up the
-- parser for each of them.
util.for_each_child(start_parent_lang, parser:lang(), parser, f)
full_update(bufnr, parser)
end
---@param bufnr integer
---@param settings rainbow_delimiters.buffer_settings
local function on_attach(bufnr, settings)
log.trace('global strategy on_attach for buffer %d', bufnr)
local parser = settings.parser
setup_parser(bufnr, parser, nil)
-- Autocommand to update highlighting when the cursor is moved.
api.nvim_create_autocmd('CursorMoved', {
group = augroup,
buffer = bufnr,
callback = function(args)
-- TODO: Cache the match tree and only highlight the cached tree
-- instead of computing it from scratch.
full_update(bufnr, parser)
end
})
end
---@param bufnr integer
local function on_detach(bufnr)
-- Uninstall the autocommand
api.nvim_clear_autocmds {
buffer = bufnr,
group = augroup,
}
log.trace('global strategy on_detach for buffer %d', bufnr)
end
---@param bufnr integer
---@param settings rainbow_delimiters.buffer_settings
local function on_reset(bufnr, settings)
log.trace('global strategy on_reset for buffer %d', bufnr)
end
---Strategy which highlights all delimiters in the current buffer.
---@type rainbow_delimiters.strategy
return {
on_attach = on_attach,
on_detach = on_detach,
on_reset = on_reset,
}
rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/strategy/local/legacy.lua 0000664 0000000 0000000 00000027145 15066556776 0030052 0 ustar 00root root 0000000 0000000 --[[
Copyright 2023 Alejandro "HiPhish" Sanchez
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.
--]]
local Stack = require 'rainbow-delimiters.stack'
local lib = require 'rainbow-delimiters.lib'
local log = require 'rainbow-delimiters.log'
local util = require 'rainbow-delimiters.util'
local api = vim.api
local ts = vim.treesitter
---Highlight strategy which highlights the sub-tree of the buffer which
---contains the cursor. Re-computes -highlights when the buffer contents change
---or when the cursor is moved.
local M = {}
-- Implementation note: This strategy uses a two-step process: on every change
-- to the document tree we compute the match tree and cache it, then when the
-- cursor moves we use the cached match tree and the current cursor position to
-- decide which matches to highlight.
--
-- The document tree changes rarely, so there is no need to re-compute the
-- match tree every time the cursor moves.
---Cache of match trees, maps a buffer number to its match tree. We compute
---the match tree on every change, so that when the cursor moves without
---changing the tree we don't need to re-compute it.
---
---Each match tree maps a language and TS Tree to the corresponding match tree.
---We need TS Tree because there might be multiple trees per buffer, such as a
---Markdown buffer which contains multiple code blocks.
local match_trees = {}
---Reusable autogroup for events in this strategy.
---@type integer
local augroup = api.nvim_create_augroup('TSRainbowLocalCursor', {})
---Highlights a single match with the given highlight group
---@param bufnr integer
---@param lang string
---@param match table
---@param hlgroup string
local function highlight_match(bufnr, lang, match, hlgroup)
for _, delimiter in match.delimiter:iter() do lib.highlight(bufnr, lang, delimiter, hlgroup) end
end
---Highlights all matches and their children on the stack of matches. All
---matches must be on the same level of the match tree.
---
---@param bufnr integer Number of the buffer
---@param matches Stack Stack of matches
---@param level integer Level of the matches
local function highlight_matches(bufnr, lang, matches, level)
local hlgroup = lib.hlgroup_at(level)
for _, match in matches:iter() do
highlight_match(bufnr, lang, match, hlgroup)
highlight_matches(bufnr, lang, match.children, level + 1)
end
end
---Finds a match (and its level) in the match tree whose container node is the
---given container node.
---@param matches Stack
---@param container TSNode
---@param level integer
---@return table
---@return integer
---If no match is found, return nil.
---@overload fun(matches: Stack, container: TSNode, level: integer)
local function find_container(matches, container, level)
for _, match in matches:iter() do
if match.container == container then return match, level end
local result, final_level = find_container(match.children, container, level + 1)
if result then return result, final_level end
end
end
--- Create a new empty match_record with an optionally set container
---@param container TSNode
---@return table
local function new_match_record(container)
return {
container = container,
delimiter = Stack.new(),
children = Stack.new(),
}
end
---Assembles the match tree, usually called after the document tree has
---changed.
---@param bufnr integer Buffer number
---@param changes table List of node ranges in which the changes occurred
---@param tree TSTree TS tree
---@param lang string Language
---@return Stack?
local function build_match_tree(bufnr, changes, tree, lang)
if not lib.enabled_for(lang) then return end
local query = lib.get_query(lang, bufnr)
if not query then return end
local matches = Stack.new()
for _, change in ipairs(changes) do
-- This is the match record, it lists all the relevant nodes from
-- each match.
---@type table?
local match_record
local root_node = tree:root()
local start_row, end_row = change[1], change[3] + 1
lib.clear_namespace(bufnr, lang, start_row, end_row)
for qid, node, _ in query:iter_captures(root_node, bufnr, start_row, end_row) do
local name = query.captures[qid]
-- check for 'delimiter' first, since that should be the most
-- common name
if name == 'delimiter' and match_record then
match_record.delimiter:push(node)
elseif name == 'container' and not match_record then
match_record = new_match_record(node)
elseif name == 'container' then
local prev_match_record = match_record
-- temporarily push the match_record to matches to be retrieved
-- later, since we haven't closed it yet
matches:push(match_record)
match_record = new_match_record(node)
-- since we didn't close the previous match_record, it must
-- mean that the current match_record has it as an ancestor
match_record.ancestor = prev_match_record
elseif name == 'sentinel' and match_record then
-- if we see the sentinel, then we are done with the current
-- container
if match_record.ancestor then
local prev_match_record = matches:pop()
if prev_match_record then
-- since we have an ancestor, it has to be the last
-- element of the stack
prev_match_record.children:push(match_record)
match_record = prev_match_record
else
-- since match_record.has_ancestor was true, we shouldn't
-- be able to get to here unless something went wrong
-- with the queries or treesitter itself
log.error([[You are missing a @container,
which should be impossible!
Please double check the queries.]])
end
else
-- if match_record doesn't have an ancestor, the sentinel
-- means that we are done with it
matches:push(match_record)
match_record = nil
end
elseif (name == 'delimiter' or name == 'sentinel') and not match_record then
log.error([[You query got the capture name: %s.
But it didn't come with a container, which should be impossible!
Please double check your queries.]], name)
end -- do nothing with other capture names
end
end
return matches
end
---@param bufnr integer
---@param tree TSTree
---@param lang string
local function update_local(bufnr, tree, lang)
if not lib.enabled_for(lang) then return end
local query = lib.get_query(lang, bufnr)
if not query then return end
-- Find the lowest container node which contains the cursor
local cursor_container
do
local curpos = api.nvim_win_get_cursor(0)
-- The order of traversal guarantees that the first match which
-- contains the cursor is also the lowest one.
for _, match in query:iter_matches(tree:root(), bufnr, 0, -1) do
if cursor_container then break end
for id, node in pairs(match) do
local name = query.captures[id]
if name == 'container' and ts.is_in_node_range(node, curpos[1] - 1, curpos[2]) then
cursor_container = node
break
end
end
end
end
if not cursor_container then return end
local matches_lang = match_trees[bufnr][lang]
if not matches_lang then
log.debug("Did not build any matches Stack for language '%s'", lang)
return
end
local matches = matches_lang[tree]
if not matches then
-- Note: vim.inspect(tree:root():range()) errors, so we need
-- to make it into a table instead of a list of numbers
log.debug("Did not build any matches Stack for tree '%s'", vim.inspect({tree:root():range()}))
return
end
-- Find the correct container in the match tree
local cursor_match, level = find_container(matches, cursor_container, 1)
if not cursor_match then return end
-- Highlight the container match and everything below
highlight_matches(bufnr, lang, Stack.new {cursor_match}, level)
-- Starting with the cursor match travel up and highlight every ancestor as
-- well
local ancestor = cursor_match.ancestor
level = level - 1
while ancestor do
highlight_match(bufnr, lang, ancestor, lib.hlgroup_at(level))
ancestor, level = ancestor.ancestor, level - 1
end
end
---Callback function to re-highlight the buffer according to the current cursor
---position.
---@param bufnr integer
---@param parser vim.treesitter.LanguageTree
local function local_rainbow(bufnr, parser)
parser:for_each_tree(function(tree, sub_parser)
update_local(bufnr, tree, sub_parser:lang())
end)
end
---Sets up all the callbacks and performs an initial highlighting
---@param bufnr integer # Buffer number
---@param parser vim.treesitter.LanguageTree
local function setup_parser(bufnr, parser)
log.debug('Setting up parser for buffer %d', bufnr)
util.for_each_child(nil, parser:lang(), parser, function(p, lang, _parent_lang)
log.debug("Setting up parser for '%s' in buffer %d", lang, bufnr)
-- Skip languages which are not supported, otherwise we get a
-- nil-reference error
if not lib.get_query(lang, bufnr) then return end
p:register_cbs {
---@param _changes table
---@param tree TSTree
on_changedtree = function(_changes, tree)
-- HACK: As of Neovim v0.9.1 there is no way of unregistering a
-- callback, so we use this check to abort
if not lib.buffers[bufnr] then return end
if vim.fn.pumvisible() ~= 0 then return end
-- Ideally we would only rebuild the parts of the tree that have changed,
-- but this doesn't work, so we will rebuild the entire tree
-- instead.
local fake_changes = {
{tree:root():range()}
}
match_trees[bufnr][lang] = match_trees[bufnr][lang] or {}
match_trees[bufnr][lang][tree] = build_match_tree(bufnr, fake_changes, tree, lang)
-- Re-highlight after the change
local_rainbow(bufnr, p)
end,
-- New languages can be added into the text at some later time, e.g.
-- code snippets in Markdown
---@param child vim.treesitter.LanguageTree
on_child_added = function(child)
setup_parser(bufnr, child)
end,
}
log.trace("Done with setting up parser for '%s' in buffer %d", lang, bufnr)
end)
end
---on_attach implementation for the local strategy
---@param bufnr integer
---@param settings rainbow_delimiters.buffer_settings
function M.on_attach(bufnr, settings)
local parser = settings.parser
setup_parser(bufnr, parser)
api.nvim_create_autocmd('CursorMoved', {
group = augroup,
buffer = bufnr,
callback = function(args)
util.for_each_child(nil, parser:lang(), parser, function(_, lang, _)
lib.clear_namespace(bufnr, lang)
end)
local_rainbow(args.buf, parser)
end
})
-- Build up the initial match tree
match_trees[bufnr] = {}
parser:for_each_tree(function(tree, sub_parser)
local sub_lang = sub_parser:lang()
local changes = {
{tree:root():range()}
}
match_trees[bufnr][sub_lang] = match_trees[bufnr][sub_lang] or {}
match_trees[bufnr][sub_lang][tree] = build_match_tree(bufnr, changes, tree, sub_lang)
end)
local_rainbow(bufnr, parser)
end
---on_detach implementation for the local strategy
---@param bufnr integer
function M.on_detach(bufnr)
-- Uninstall autocommand and delete cached match tree
api.nvim_clear_autocmds {
buffer = bufnr,
group = augroup,
}
match_trees[bufnr] = nil
end
---on_reset implementation for the local strategy
---@param bufnr integer
---@param settings rainbow_delimiters.buffer_settings
function M.on_reset(bufnr, settings)
local parser = settings.parser
local_rainbow(bufnr, parser)
end
return M --[[@as rainbow_delimiters.strategy]]
-- vim:tw=79:ts=4:sw=4:noet:
rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/strategy/no-op.lua 0000664 0000000 0000000 00000002310 15066556776 0026527 0 ustar 00root root 0000000 0000000 --[[
Copyright 2023 Alejandro "HiPhish" Sanchez
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.
--]]
---A dummy strategy which does nothing; can be used in testing.
local M = {}
---on_attach implementation for the noop strategy
---@param _bufnr integer
---@param _settings rainbow_delimiters.buffer_settings
M.on_attach = function(_bufnr, _settings)
end
---on_detach implementation for the noop strategy
---@param _bufnr integer
M.on_detach = function(_bufnr)
end
---on_reset implementation for the noop strategy
---@param _bufnr integer
---@param _settings rainbow_delimiters.buffer_settings
M.on_reset = function(_bufnr, _settings)
end
return M --[[@as rainbow_delimiters.strategy]]
-- vim:tw=79:ts=4:sw=4:noet:
rainbow-delimiters.nvim-v0.10.0/lua/rainbow-delimiters/util.lua 0000664 0000000 0000000 00000002737 15066556776 0024627 0 ustar 00root root 0000000 0000000 --[[
Copyright 2023 Alejandro "HiPhish" Sanchez
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.
--]]
---Internal helper functions. This module will probably be removed when I no
---longer need the helpers.
local M = {}
---Similar to the function `LanguageTree:for_each_child` which has been
---deprecated. Applies the thunk to the language tree and each of its
---descendants recursively.
---
---See also https://github.com/neovim/neovim/pull/25154 for a better
---replacement.
---@param parent_lang string? # Parent language or nil
---@param lang string
---@param language_tree vim.treesitter.LanguageTree
---@param thunk fun(p: vim.treesitter.LanguageTree, lang: string, parent_lang: string?)
function M.for_each_child(parent_lang, lang, language_tree, thunk)
thunk(language_tree, lang, parent_lang)
local children = language_tree:children()
for child_lang, child in pairs(children) do
M.for_each_child(lang, child_lang, child, thunk)
end
end
return M
-- vim:tw=79:ts=4:sw=4:noet:
rainbow-delimiters.nvim-v0.10.0/makefile 0000664 0000000 0000000 00000004565 15066556776 0020267 0 ustar 00root root 0000000 0000000 # SPDX-License-Identifier: Unlicense
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or distribute
# this software, either in source code form or as a compiled binary, for any
# purpose, commercial or non-commercial, and by any means.
#
# In jurisdictions that recognize copyright laws, the author or authors of
# this software dedicate any and all copyright interest in the software to
# the public domain. We make this dedication for the benefit of the public
# at large and to the detriment of our heirs and successors. We intend this
# dedication to be an overt act of relinquishment in perpetuity of all
# present and future rights to this software under copyright law.
#
# 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 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.
#
# For more information, please refer to
.PHONY: check unit-test e2e-test highlight-test record-highlight clean
check: unit-test e2e-test highlight-test query-test
unit-test:
@./test/bin/busted --run unit
e2e-test:
@./test/bin/busted --run e2e
highlight-test:
ifdef LANGUAGE
@./test/bin/busted --run highlight -t $(LANGUAGE)
else
@./test/bin/busted --run highlight
endif
query-test:
@./test/bin/busted --run query
# NOTE: default value empty string ensures that by default no language is
# passed because there is no language whose name is the empty string.
record-highlight:
@# Records the extmarks for the language passed via the LANGUAGE variable.
@# Use this from the command-line: make record-highlight LANGUAGE=lua
ifdef LANGUAGE
@./test/bin/lua -e 'require("rainbow-delimiters._test.highlight").record_extmarks("$(LANGUAGE)")'
else
@echo 'Must pass a language via `LANGUAGE` variable'
@exit 1
endif
clean:
@rm -rf test/xdg/local/state/nvim/*
@rm -rf test/xdg/local/share/nvim/site/pack/testing/start/nvim-treesitter/parser/*
@# The symlink might have been left over from a failed test run
@rm -rf test/xdg/local/share/nvim/site/pack/self-*
rainbow-delimiters.nvim-v0.10.0/plugin/ 0000775 0000000 0000000 00000000000 15066556776 0020053 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/plugin/rainbow-delimiters.lua 0000664 0000000 0000000 00000005251 15066556776 0024361 0 ustar 00root root 0000000 0000000 -- Copyright 2023 Alejandro "HiPhish" Sanchez
-- Copyright 2020-2022 Chinmay Dalal
--
-- 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.
if vim.g.loaded_rainbow_delimiters then
return
end
local api = vim.api
local set_hl = api.nvim_set_hl
local create_augroup = api.nvim_create_augroup
local create_autocmd = api.nvim_create_autocmd
local get_lang = vim.treesitter.language.get_lang
--- [ DEFINE HIGHLIGHT GROUPS ]------------------------------------------------
local function define_hlgroups()
set_hl(0, 'RainbowDelimiterRed' , {default = true, fg = '#cc241d', ctermfg= 'Red' })
set_hl(0, 'RainbowDelimiterOrange', {default = true, fg = '#d65d0e', ctermfg= 'White' })
set_hl(0, 'RainbowDelimiterYellow', {default = true, fg = '#d79921', ctermfg= 'Yellow' })
set_hl(0, 'RainbowDelimiterGreen' , {default = true, fg = '#689d6a', ctermfg= 'Green' })
set_hl(0, 'RainbowDelimiterCyan' , {default = true, fg = '#a89984', ctermfg= 'Cyan' })
set_hl(0, 'RainbowDelimiterBlue' , {default = true, fg = '#458588', ctermfg= 'Blue' })
set_hl(0, 'RainbowDelimiterViolet', {default = true, fg = '#b16286', ctermfg= 'Magenta'})
end
define_hlgroups()
--- [ SET UP AUTOCOMMANDS ]----------------------------------------------------
local hl_augroup = create_augroup('TSRainbowHighlight', {})
local rb_augroup = create_augroup('TSRainbowDelimits', {})
create_autocmd('ColorScheme', {
desc = 'Re-apply highlight group definitions when the colour scheme changes',
group = hl_augroup,
callback = define_hlgroups
})
create_autocmd('FileType', {
desc = 'Attach to a new buffer',
group = rb_augroup,
callback = function(args)
local config = require 'rainbow-delimiters.config'
local lib = require 'rainbow-delimiters.lib'
local lang = get_lang(args.match)
local bufnr = args.buf
if not config.enabled_for(lang) then return end
if not config.enabled_when(bufnr) then return end
lib.attach(bufnr)
end,
})
create_autocmd('BufUnload', {
desc = 'Detach from the current buffer',
group = rb_augroup,
callback = function(args)
local lib = require 'rainbow-delimiters.lib'
lib.detach(args.buf)
end
})
vim.g.loaded_rainbow_delimiters = true
-- vim:tw=79:ts=4:sw=4:noet:
rainbow-delimiters.nvim-v0.10.0/queries/ 0000775 0000000 0000000 00000000000 15066556776 0020232 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/astro/ 0000775 0000000 0000000 00000000000 15066556776 0021362 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/astro/rainbow-delimiters.scm 0000664 0000000 0000000 00000000407 15066556776 0025667 0 ustar 00root root 0000000 0000000 (element
(start_tag
"<" @delimiter
(tag_name) @delimiter
">" @delimiter)
(end_tag
"" @delimiter
(tag_name) @delimiter
">" @delimiter @sentinel)) @container
(html_interpolation
"{" @delimiter
"}" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/awk/ 0000775 0000000 0000000 00000000000 15066556776 0021014 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/awk/rainbow-delimiters.scm 0000664 0000000 0000000 00000001546 15066556776 0025326 0 ustar 00root root 0000000 0000000 (block
"{" @delimiter
"}" @delimiter @sentinel) @container
(grouping
"(" @delimiter
")" @delimiter @sentinel) @container
(array_ref
"[" @delimiter
"]" @delimiter @sentinel) @container
(func_call
"(" @delimiter
")" @delimiter @sentinel) @container
(if_statement
"if"
"(" @delimiter
")" @delimiter @sentinel) @container
(while_statement
"while"
"(" @delimiter
")" @delimiter @sentinel) @container
;; This messes up the highlighting of the sibling block
; (do_while_statement
; "(" @delimiter
; ")" @delimiter @sentinel) @container
(for_statement
"for"
"(" @delimiter
")" @delimiter @sentinel) @container
(for_in_statement
"for"
"(" @delimiter
")" @delimiter @sentinel) @container
(switch_statement
"switch"
"(" @delimiter
")" @delimiter
(switch_body
"{" @delimiter
"}" @delimiter @sentinel)) @container
rainbow-delimiters.nvim-v0.10.0/queries/bash/ 0000775 0000000 0000000 00000000000 15066556776 0021147 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/bash/rainbow-delimiters.scm 0000664 0000000 0000000 00000001323 15066556776 0025452 0 ustar 00root root 0000000 0000000 (command_substitution
"$(" @delimiter
")" @delimiter @sentinel) @container
(expansion
"${" @delimiter
(":-" @delimiter)?
"}" @delimiter @sentinel) @container
;;; The double-bracket variant is a bashism
(test_command
["[[" "["] @delimiter
["]]" "]"] @delimiter @sentinel) @container
(subshell
"(" @delimiter
")" @delimiter @sentinel) @container
(array
"(" @delimiter
")" @delimiter @sentinel) @container
(function_definition
"(" @delimiter
")" @delimiter @sentinel) @container
(arithmetic_expansion
"$((" @delimiter
"))" @delimiter @sentinel) @container
(compound_statement
"{" @delimiter
"}" @delimiter @sentinel) @container
(subscript
"[" @delimiter
"]" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/c/ 0000775 0000000 0000000 00000000000 15066556776 0020454 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/c/rainbow-delimiters.scm 0000664 0000000 0000000 00000002616 15066556776 0024765 0 ustar 00root root 0000000 0000000 (parameter_list
"(" @delimiter
")" @delimiter @sentinel) @container
(argument_list
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(compound_statement
"{" @delimiter
"}" @delimiter @sentinel) @container
(initializer_list
"{" @delimiter
"}" @delimiter @sentinel) @container
; This highlights the nested levels in an array differently
; although they are the same level in terms of the nesting
; of delimiters
(subscript_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
(field_declaration_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(array_declarator
"[" @delimiter
"]" @delimiter @sentinel) @container
(sizeof_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(for_statement
"(" @delimiter
")" @delimiter @sentinel) @container
; Comment out the following to not highlight type casts
(cast_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(enumerator_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(macro_type_specifier
"(" @delimiter
")" @delimiter @sentinel) @container
(preproc_params
"(" @delimiter
")" @delimiter @sentinel) @container
(compound_literal_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_declarator
"(" @delimiter
")" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/c_sharp/ 0000775 0000000 0000000 00000000000 15066556776 0021651 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/c_sharp/rainbow-delimiters.scm 0000664 0000000 0000000 00000005424 15066556776 0026162 0 ustar 00root root 0000000 0000000 (parenthesized_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(argument_list
"(" @delimiter
")" @delimiter @sentinel) @container
(parameter_list
"(" @delimiter
")" @delimiter @sentinel) @container
(if_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(foreach_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(for_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(while_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(do_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(tuple_type
"(" @delimiter
")" @delimiter @sentinel) @container
(tuple_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(tuple_pattern
"(" @delimiter
")" @delimiter @sentinel) @container
(attribute_argument_list
"(" @delimiter
")" @delimiter @sentinel) @container
(attribute_list
"[" @delimiter
"]" @delimiter @sentinel) @container
(switch_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(switch_body
"{" @delimiter
"}" @delimiter @sentinel) @container
(switch_expression
"{" @delimiter
"}" @delimiter @sentinel) @container
(default_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(catch_declaration
"(" @delimiter
")" @delimiter @sentinel) @container
(catch_filter_clause
"(" @delimiter
")" @delimiter @sentinel) @container
(using_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(lock_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(cast_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(typeof_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(sizeof_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(checked_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(declaration_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(accessor_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(block
"{" @delimiter
"}" @delimiter @sentinel) @container
(anonymous_object_creation_expression
"{" @delimiter
"}" @delimiter @sentinel) @container
(enum_member_declaration_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(type_parameter_list
"<" @delimiter
">" @delimiter @sentinel) @container
(type_argument_list
"<" @delimiter
">" @delimiter @sentinel) @container
(initializer_expression
"{" @delimiter
"}" @delimiter @sentinel) @container
(array_rank_specifier
"[" @delimiter
"]" @delimiter @sentinel) @container
(bracketed_argument_list
"[" @delimiter
"]" @delimiter @sentinel) @container
(implicit_array_creation_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
(implicit_stackalloc_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/clojure/ 0000775 0000000 0000000 00000000000 15066556776 0021675 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/clojure/rainbow-delimiters.scm 0000664 0000000 0000000 00000000516 15066556776 0026203 0 ustar 00root root 0000000 0000000 (list_lit
"(" @delimiter
")" @delimiter @sentinel) @container
(vec_lit
"[" @delimiter
"]" @delimiter @sentinel) @container
(map_lit
"{" @delimiter
"}" @delimiter @sentinel) @container
(set_lit
"{" @delimiter
"}" @delimiter @sentinel) @container
(anon_fn_lit
"(" @delimiter
")" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/commonlisp/ 0000775 0000000 0000000 00000000000 15066556776 0022412 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/commonlisp/rainbow-delimiters.scm 0000664 0000000 0000000 00000000312 15066556776 0026712 0 ustar 00root root 0000000 0000000 (list_lit
"(" @delimiter
")" @delimiter @sentinel) @container
(defun
"(" @delimiter
")" @delimiter @sentinel) @container
(loop_macro
"(" @delimiter
")" @delimiter @sentinel ) @container
rainbow-delimiters.nvim-v0.10.0/queries/cpp/ 0000775 0000000 0000000 00000000000 15066556776 0021014 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/cpp/rainbow-delimiters.scm 0000664 0000000 0000000 00000002672 15066556776 0025327 0 ustar 00root root 0000000 0000000 ;;; NOTE: The C and C++ grammar have diverged, so I cannot include the C query.
(parameter_list
"(" @delimiter
")" @delimiter @sentinel) @container
(argument_list
"(" @delimiter
")" @delimiter @sentinel) @container
(condition_clause
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(compound_statement
"{" @delimiter
"}" @delimiter @sentinel) @container
(for_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(for_range_loop
"(" @delimiter
")" @delimiter @sentinel) @container
(cast_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(enumerator_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(initializer_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(array_declarator
"[" @delimiter
"]" @delimiter @sentinel) @container
(subscript_argument_list
"[" @delimiter
"]" @delimiter @sentinel) @container
(lambda_capture_specifier
"[" @delimiter
"]" @delimiter @sentinel) @container
(new_declarator
"[" @delimiter
"]" @delimiter @sentinel) @container
(field_declaration_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(declaration_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(template_parameter_list
"<" @delimiter
">" @delimiter @sentinel) @container
(template_argument_list
"<" @delimiter
">" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/css/ 0000775 0000000 0000000 00000000000 15066556776 0021022 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/css/rainbow-delimiters.scm 0000664 0000000 0000000 00000000546 15066556776 0025333 0 ustar 00root root 0000000 0000000 (block
"{" @delimiter
"}" @delimiter @sentinel) @container
(parenthesized_query
"(" @delimiter
")" @delimiter @sentinel) @container
(feature_query
"(" @delimiter
")" @delimiter @sentinel) @container
(arguments
"(" @delimiter
")" @delimiter @sentinel) @container
(attribute_selector
"[" @delimiter
"]" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/cuda/ 0000775 0000000 0000000 00000000000 15066556776 0021146 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/cuda/rainbow-delimiters.scm 0000664 0000000 0000000 00000000143 15066556776 0025450 0 ustar 00root root 0000000 0000000 ; inherits: cpp
(kernel_call_syntax
"<<<" @delimiter
">>>" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/cue/ 0000775 0000000 0000000 00000000000 15066556776 0021006 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/cue/rainbow-delimiters.scm 0000664 0000000 0000000 00000001304 15066556776 0025310 0 ustar 00root root 0000000 0000000 (struct_lit
"{" @delimiter
"}" @delimiter @sentinel) @container
(index_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
(list_lit
"[" @delimiter
"]" @delimiter @sentinel) @container
(label
"[" @delimiter
"]" @delimiter @sentinel) @container
(arguments
"(" @delimiter
")" @delimiter @sentinel) @container
(attribute
"(" @delimiter
")" @delimiter @sentinel) @container
(dynamic
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(import_spec_list
"(" @delimiter
")" @delimiter @sentinel) @container
(interpolation
"\\(" @delimiter
")" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/dart/ 0000775 0000000 0000000 00000000000 15066556776 0021164 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/dart/rainbow-delimiters.scm 0000664 0000000 0000000 00000001112 15066556776 0025463 0 ustar 00root root 0000000 0000000 (block
"{" @delimiter
"}" @delimiter @sentinel) @container
(arguments
"(" @delimiter
")" @delimiter @sentinel) @container
(class_body
"{" @delimiter
"}" @delimiter @sentinel) @container
(formal_parameter_list
"(" @delimiter
")" @delimiter @sentinel) @container
(optional_formal_parameters
"{" @delimiter
"}" @delimiter @sentinel) @container
(list_literal
"[" @delimiter
"]" @delimiter @sentinel) @container
(set_or_map_literal
"{" @delimiter
"}" @delimiter @sentinel) @container
(type_arguments
"<" @delimiter
">" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/elixir/ 0000775 0000000 0000000 00000000000 15066556776 0021526 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/elixir/rainbow-delimiters.scm 0000664 0000000 0000000 00000001102 15066556776 0026024 0 ustar 00root root 0000000 0000000 (call
(arguments
"(" @delimiter
")" @delimiter @sentinel) @container)
(block
"(" @delimiter
")" @delimiter @sentinel) @container
(string
(interpolation
"#{" @delimiter
"}" @delimiter @sentinel) @container)
(tuple
"{" @delimiter
"}" @delimiter @sentinel) @container
(list
"[" @delimiter
"]" @delimiter @sentinel) @container
(access_call
"[" @delimiter
"]" @delimiter @sentinel) @container
(bitstring
"<<" @delimiter
">>" @delimiter @sentinel) @container
(map
"%" @delimiter
"{" @delimiter
"}" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/elm/ 0000775 0000000 0000000 00000000000 15066556776 0021007 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/elm/rainbow-delimiters.scm 0000664 0000000 0000000 00000002307 15066556776 0025315 0 ustar 00root root 0000000 0000000 (exposing_list
"(" @delimiter
")" @delimiter @sentinel) @container
(exposed_operator
"(" @delimiter
")" @delimiter @sentinel) @container
(exposed_union_constructors
"(" @delimiter
")" @delimiter @sentinel) @container
;;; Broken by design, see https://github.com/elm-tooling/tree-sitter-elm/issues/159
(_
"(" @delimiter
.
(type_expression)
.
")" @delimiter @sentinel
) @container
;;; Broken by design, see https://github.com/elm-tooling/tree-sitter-elm/issues/159
(_
"(" @delimiter
.
[(pattern) (union_pattern)]
.
")" @delimiter @sentinel
) @container
(record_expr
"{" @delimiter
"}" @delimiter @sentinel) @container
(record_type
"{" @delimiter
"}" @delimiter @sentinel) @container
(record_pattern
"{" @delimiter
"}" @delimiter @sentinel) @container
(tuple_expr
"(" @delimiter
")" @delimiter @sentinel) @container
(tuple_type
"(" @delimiter
")" @delimiter @sentinel) @container
(tuple_pattern
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_expr
"(" @delimiter
")" @delimiter @sentinel) @container
(list_expr
"[" @delimiter
"]" @delimiter @sentinel) @container
(list_pattern
"[" @delimiter
"]" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/fennel/ 0000775 0000000 0000000 00000000000 15066556776 0021501 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/fennel/rainbow-delimiters.scm 0000664 0000000 0000000 00000000134 15066556776 0026003 0 ustar 00root root 0000000 0000000 (_
open: ["(" "[" "{"] @delimiter
close: [")" "]" "}"] @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/fish/ 0000775 0000000 0000000 00000000000 15066556776 0021163 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/fish/rainbow-delimiters.scm 0000664 0000000 0000000 00000000456 15066556776 0025474 0 ustar 00root root 0000000 0000000 (command_substitution
"(" @delimiter
")" @delimiter @sentinel) @container
(concatenation
"[" @delimiter
"]" @delimiter @sentinel) @container
(list_element_access
"[" @delimiter
"]" @delimiter @sentinel) @container
(brace_expansion
"{" @delimiter
"}" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/fsharp/ 0000775 0000000 0000000 00000000000 15066556776 0021515 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/fsharp/rainbow-delimiters.scm 0000664 0000000 0000000 00000001310 15066556776 0026014 0 ustar 00root root 0000000 0000000 (argument_patterns
("(" @delimiter ")" @delimiter)*) @container
(ce_expression
"{" @delimiter
"}" @delimiter) @container
(generic_type
"<" @delimiter
">" @delimiter) @container
(list_pattern
"[" @delimiter
"]" @delimiter) @container
(array_pattern
"[|" @delimiter
"|]" @delimiter) @container
(paren_expression
"(" @delimiter
")" @delimiter) @container
(paren_pattern
"(" @delimiter
")" @delimiter) @container
(paren_type
"(" @delimiter
")" @delimiter) @container
(record_type_defn
"{" @delimiter
"}" @delimiter) @container
;; This one is weird because the `unit` node has no children, so it is at the
;; same time container and a delimiter
(unit) @delimiter @container
rainbow-delimiters.nvim-v0.10.0/queries/gleam/ 0000775 0000000 0000000 00000000000 15066556776 0021317 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/gleam/rainbow-delimiters.scm 0000664 0000000 0000000 00000003712 15066556776 0025626 0 ustar 00root root 0000000 0000000 ; MyRecord(3)
(arguments
"(" @delimiter
")" @delimiter @sentinel) @container
; fn main()
(function_parameters
"(" @delimiter
")" @delimiter @sentinel) @container
; fn foo(arg: fn(String) -> MyType)
(function_parameter_types
"(" @delimiter
")" @delimiter @sentinel) @container
; type Foo(arg)
(type_parameters
"(" @delimiter
")" @delimiter @sentinel) @container
; fn foo(arg: Number(_))
; The part with `Number()`
(type_arguments
"(" @delimiter
")" @delimiter @sentinel) @container
; type Foo {
; Bar(Int) # this line
; }
(data_constructor_arguments
"(" @delimiter
")" @delimiter @sentinel) @container
;; MyRecord(..foo, bar:)
(record_update
"(" @delimiter
")" @delimiter @sentinel) @container
; case foo {
; CustomType(_) -> "this line"
; }
(record_pattern_arguments
"(" @delimiter
")" @delimiter @sentinel) @container
; #(foo, bar)
(tuple
"(" @delimiter
")" @delimiter @sentinel) @container
; case foo {
; #() -> "this line"
; }
(tuple_pattern
"(" @delimiter
")" @delimiter @sentinel) @container
; fn foo(arg: #(_, _)) {
(tuple_type
"(" @delimiter
")" @delimiter @sentinel) @container
; let lst = []
(list
"[" @delimiter
"]" @delimiter @sentinel) @container
; case foo {
; [] -> "here"
; }
(list_pattern
"[" @delimiter
"]" @delimiter @sentinel) @container
; let foo = { 2 + 2 }
(block
"{" @delimiter
"}" @delimiter @sentinel) @container
; case foo {}
(case
"{" @delimiter
"}" @delimiter @sentinel) @container
; type Foo {}
(type_definition
"{" @delimiter
"}" @delimiter @sentinel) @container
; import gleam/io.{println}
(unqualified_imports
"{" @delimiter
"}" @delimiter @sentinel) @container
; let foo = << >>
(bit_string
"<<" @delimiter
">>" @delimiter @sentinel) @container
; case foo {
; <<>> -> "here"
; }
(bit_string_pattern
"<<" @delimiter
">>" @delimiter @sentinel) @container
; <>
(bit_string_segment_option
"(" @delimiter
")" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/glsl/ 0000775 0000000 0000000 00000000000 15066556776 0021173 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/glsl/rainbow-delimiters.scm 0000664 0000000 0000000 00000001257 15066556776 0025504 0 ustar 00root root 0000000 0000000 (layout_qualifiers
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(for_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(argument_list
"(" @delimiter
")" @delimiter @sentinel) @container
(field_declaration_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(compound_statement
"{" @delimiter
"}" @delimiter @sentinel) @container
(array_declarator
"[" @delimiter
"]" @delimiter @sentinel) @container
(subscript_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
(parameter_list
"(" @delimiter
")" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/go/ 0000775 0000000 0000000 00000000000 15066556776 0020637 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/go/rainbow-delimiters.scm 0000664 0000000 0000000 00000002730 15066556776 0025145 0 ustar 00root root 0000000 0000000 (parenthesized_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(import_spec_list
"(" @delimiter
")" @delimiter @sentinel) @container
(var_spec_list
"(" @delimiter
")" @delimiter @sentinel) @container
(const_declaration
"(" @delimiter
")" @delimiter @sentinel) @container
(type_assertion_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(field_declaration_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(argument_list
"(" @delimiter
")" @delimiter @sentinel) @container
(parameter_list
"(" @delimiter
")" @delimiter @sentinel) @container
(block
"{" @delimiter
"}" @delimiter @sentinel) @container
(expression_switch_statement
"{" @delimiter
"}" @delimiter @sentinel) @container
(type_switch_statement
"{" @delimiter
"}" @delimiter @sentinel) @container
(literal_value
"{" @delimiter
"}" @delimiter @sentinel) @container
(array_type
"[" @delimiter
"]" @delimiter @sentinel) @container
(slice_type
"[" @delimiter
"]" @delimiter @sentinel) @container
(map_type
"[" @delimiter
"]" @delimiter @sentinel) @container
(interface_type
"{" @delimiter
"}" @delimiter @sentinel) @container
(type_parameter_list
"[" @delimiter
"]" @delimiter @sentinel) @container
(type_arguments
"[" @delimiter
"]" @delimiter @sentinel) @container
(index_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
(slice_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/groovy/ 0000775 0000000 0000000 00000000000 15066556776 0021557 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/groovy/rainbow-delimiters.scm 0000664 0000000 0000000 00000001614 15066556776 0026065 0 ustar 00root root 0000000 0000000 (parenthesized_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(parameter_list
"(" @delimiter
")" @delimiter @sentinel) @container
(argument_list
"(" @delimiter
")" @delimiter @sentinel) @container
(for_parameters
"(" @delimiter
")" @delimiter @sentinel) @container
(for_in_loop
"(" @delimiter
")" @delimiter @sentinel) @container
(list
"[" @delimiter
"]" @delimiter @sentinel) @container
(index
"[" @delimiter
"]" @delimiter @sentinel) @container
(map
"[" @delimiter
"]" @delimiter @sentinel) @container
(closure
"{" @delimiter
"}" @delimiter @sentinel) @container
(switch_block
"{" @delimiter
"}" @delimiter @sentinel) @container
(interpolation
"{" @delimiter
"}" @delimiter @sentinel) @container
(string ; regex
"/" @delimiter
"/" @delimiter @sentinel) @container
(generics
"<" @delimiter
">" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/haskell/ 0000775 0000000 0000000 00000000000 15066556776 0021655 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/haskell/rainbow-delimiters.scm 0000664 0000000 0000000 00000001217 15066556776 0026162 0 ustar 00root root 0000000 0000000 (parens
"(" @delimiter
")" @delimiter @sentinel) @container
(tuple
"(" @delimiter
")" @delimiter @sentinel) @container
(unit
"(" @delimiter
")" @delimiter @sentinel) @container
(exports
"(" @delimiter
")" @delimiter @sentinel) @container
(children
"(" @delimiter
")" @delimiter @sentinel) @container
(import_list
"(" @delimiter
")" @delimiter @sentinel) @container
(prefix_id
"(" @delimiter
")" @delimiter @sentinel) @container
(list
"[" @delimiter
"]" @delimiter @sentinel) @container
(fields
"{" @delimiter
"}" @delimiter @sentinel) @container
(record
"{" @delimiter
"}" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/hcl/ 0000775 0000000 0000000 00000000000 15066556776 0021000 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/hcl/rainbow-delimiters.scm 0000664 0000000 0000000 00000002070 15066556776 0025303 0 ustar 00root root 0000000 0000000 (tuple
(tuple_start "[") @delimiter
(tuple_end "]") @delimiter @sentinel) @container
(for_tuple_expr
(tuple_start "[") @delimiter
(tuple_end "]") @delimiter @sentinel) @container
(new_index
"[" @delimiter
"]" @delimiter @sentinel) @container
(function_call
"(" @delimiter
")" @delimiter @sentinel) @container
(expression
"(" @delimiter
")" @delimiter @sentinel) @container
(binary_operation
"(" @delimiter
")" @delimiter @sentinel) @container
(unary_operation
"(" @delimiter
")" @delimiter @sentinel) @container
(block
(block_start "{") @delimiter
(block_end "}") @delimiter @sentinel) @container
(object
(object_start "{") @delimiter
(object_end "}") @delimiter @sentinel) @container
(for_object_expr
(object_start "{") @delimiter
(object_end "}") @delimiter @sentinel) @container
(template_interpolation
(template_interpolation_start) @delimiter
(template_interpolation_end) @delimiter @sentinel) @container
(_
(template_directive_start) @delimiter
(template_directive_end) @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/html/ 0000775 0000000 0000000 00000000000 15066556776 0021176 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/html/rainbow-delimiters.scm 0000664 0000000 0000000 00000002607 15066556776 0025507 0 ustar 00root root 0000000 0000000 ;;; A pair of delimiter tags with any content in-between.
;;; Last tag should be a sentinel.
;;; If instead you want rainbow-delimiters to only highlight
;;; the tag names without any of "<", "", ">" or "/>", then
;;; you can make your own query file, e.g.,
;;; 'rainbow-tag-names'
;;; and use the following with
;;; x @delimiter
;;; deleted for x equal to any of "<", "", ">" or "/>".
(element
(start_tag
"<" @delimiter
(tag_name) @delimiter
">" @delimiter)
(end_tag
"" @delimiter
(tag_name) @delimiter
">" @delimiter @sentinel)) @container
(element
(self_closing_tag
"<" @delimiter
(tag_name) @delimiter
"/>" @delimiter @sentinel)) @container
(element
(start_tag
"<" @delimiter
(tag_name) @delimiter @_tag_name
">" @delimiter @sentinel)
(#any-of? @_tag_name
"area"
"base"
"br"
"col"
"embed"
"hr"
"img"
"input"
"link"
"meta"
"param"
"source"
"track"
"wbr")
) @container
(style_element
(start_tag
"<" @delimiter
(tag_name) @delimiter
">" @delimiter)
(element (self_closing_tag) @delimiter)*
(end_tag
"" @delimiter
(tag_name) @delimiter
">" @delimiter @sentinel)) @container
(script_element
(start_tag
"<" @delimiter
(tag_name) @delimiter
">" @delimiter)
(end_tag
"" @delimiter
(tag_name) @delimiter
">" @delimiter @sentinel)) @container
rainbow-delimiters.nvim-v0.10.0/queries/htmldjango/ 0000775 0000000 0000000 00000000000 15066556776 0022361 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/htmldjango/rainbow-delimiters.scm 0000664 0000000 0000000 00000000307 15066556776 0026665 0 ustar 00root root 0000000 0000000 ;;; Intentionally empty. A Django template contains HTML, and this file exists
;;; so that the HTML nodes can be highlighted. This query only exists to
;;; satisfy the requirements of this plugin.
rainbow-delimiters.nvim-v0.10.0/queries/janet_simple/ 0000775 0000000 0000000 00000000000 15066556776 0022704 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/janet_simple/rainbow-delimiters.scm 0000664 0000000 0000000 00000000641 15066556776 0027211 0 ustar 00root root 0000000 0000000 (par_tup_lit
"(" @delimiter
")" @delimiter @sentinel) @container
(par_arr_lit
"@(" @delimiter
")" @delimiter @sentinel) @container
(sqr_tup_lit
"[" @delimiter
"]" @delimiter @sentinel) @container
(sqr_arr_lit
"@[" @delimiter
"]" @delimiter @sentinel) @container
(struct_lit
"{" @delimiter
"}" @delimiter @sentinel) @container
(tbl_lit
"@{" @delimiter
"}" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/java/ 0000775 0000000 0000000 00000000000 15066556776 0021153 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/java/rainbow-delimiters.scm 0000664 0000000 0000000 00000002701 15066556776 0025457 0 ustar 00root root 0000000 0000000 (class_body
"{" @delimiter
"}" @delimiter @sentinel) @container
(block
"{" @delimiter
"}" @delimiter @sentinel) @container
(switch_block
"{" @delimiter
"}" @delimiter @sentinel) @container
(array_initializer
"{" @delimiter
"}" @delimiter @sentinel) @container
(formal_parameters
"(" @delimiter
")" @delimiter @sentinel) @container
(resource_specification
"(" @delimiter
")" @delimiter @sentinel) @container
(catch_clause
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(cast_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(inferred_parameters
"(" @delimiter
")" @delimiter @sentinel) @container
(argument_list
"(" @delimiter
")" @delimiter @sentinel) @container
(annotation_argument_list
"(" @delimiter
")" @delimiter @sentinel) @container
(for_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(enhanced_for_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(constructor_body
"{" @delimiter
"}" @delimiter @sentinel) @container
;; Treat it as a single delimiter because it will always have the same color
(dimensions) @container @delimiter @sentinel
(dimensions_expr
"[" @delimiter
"]" @delimiter @sentinel) @container
(array_access
"[" @delimiter
"]" @delimiter @sentinel) @container
(type_arguments
"<" @delimiter
">" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/javascript/ 0000775 0000000 0000000 00000000000 15066556776 0022400 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/javascript/rainbow-delimiters-react.scm 0000664 0000000 0000000 00000004412 15066556776 0030001 0 ustar 00root root 0000000 0000000 ;;; This query includes React support as well.
;; String interpolation inside template strings
(template_substitution
"${" @delimiter
"}" @delimiter @sentinel) @container
(object
"{" @delimiter
"}" @delimiter @sentinel) @container
(computed_property_name
"[" @delimiter
"]" @delimiter @sentinel) @container
(statement_block
"{" @delimiter
"}" @delimiter @sentinel) @container
(class_body
"{" @delimiter
"}" @delimiter @sentinel) @container
(switch_body
"{" @delimiter
"}" @delimiter @sentinel) @container
(arguments
"(" @delimiter
")" @delimiter @sentinel) @container
(formal_parameters
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(for_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(for_in_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(subscript_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
(named_imports
"{" @delimiter
"}" @delimiter @sentinel) @container
(export_clause
"{" @delimiter
"}" @delimiter @sentinel) @container
(object_pattern
"{" @delimiter
"}" @delimiter @sentinel) @container
(array
"[" @delimiter
"]" @delimiter @sentinel) @container
(array_pattern
"[" @delimiter
"]" @delimiter @sentinel) @container
;;; React.js support
(jsx_element
open_tag: (jsx_opening_element
"<" @delimiter
name: (identifier) @delimiter
">" @delimiter)
close_tag: (jsx_closing_element
"" @delimiter
name: (identifier) @delimiter
">" @delimiter @sentinel)) @container
(jsx_element
open_tag: (jsx_opening_element
"<" @delimiter
name: (member_expression) @delimiter
">" @delimiter)
close_tag: (jsx_closing_element
"" @delimiter
name: (member_expression) @delimiter
">" @delimiter @sentinel)) @container
(jsx_self_closing_element
"<" @delimiter
name: (identifier) @delimiter
"/>" @delimiter @sentinel) @container
(jsx_self_closing_element
"<" @delimiter
name: (member_expression) @delimiter
"/>" @delimiter @sentinel) @container
(jsx_expression
"{" @delimiter
"}" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/javascript/rainbow-delimiters.scm 0000664 0000000 0000000 00000002611 15066556776 0026704 0 ustar 00root root 0000000 0000000 ;;; This query only covers Javascript without any React support. It exists so
;;; that Typescript query can inherit it.
;; String interpolation inside template strings
(template_substitution
"${" @delimiter
"}" @delimiter @sentinel) @container
(object
"{" @delimiter
"}" @delimiter @sentinel) @container
(computed_property_name
"[" @delimiter
"]" @delimiter @sentinel) @container
(statement_block
"{" @delimiter
"}" @delimiter @sentinel) @container
(class_body
"{" @delimiter
"}" @delimiter @sentinel) @container
(switch_body
"{" @delimiter
"}" @delimiter @sentinel) @container
(arguments
"(" @delimiter
")" @delimiter @sentinel) @container
(formal_parameters
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(for_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(for_in_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(subscript_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
(named_imports
"{" @delimiter
"}" @delimiter @sentinel) @container
(export_clause
"{" @delimiter
"}" @delimiter @sentinel) @container
(object_pattern
"{" @delimiter
"}" @delimiter @sentinel) @container
(array
"[" @delimiter
"]" @delimiter @sentinel) @container
(array_pattern
"[" @delimiter
"]" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/javascript/rainbow-parens.scm 0000777 0000000 0000000 00000000000 15066556776 0032332 2rainbow-delimiters.scm ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/javascript/rainbow-tags-react.scm 0000664 0000000 0000000 00000001554 15066556776 0026602 0 ustar 00root root 0000000 0000000 (jsx_element
open_tag: (jsx_opening_element
"<" @delimiter
name: (identifier) @delimiter
">" @delimiter)
close_tag: (jsx_closing_element
"" @delimiter
name: (identifier) @delimiter
">" @delimiter @sentinel)) @container
(jsx_element
open_tag: (jsx_opening_element
"<" @delimiter
name: (member_expression) @delimiter
">" @delimiter)
close_tag: (jsx_closing_element
"" @delimiter
name: (member_expression) @delimiter
">" @delimiter @sentinel)) @container
(jsx_self_closing_element
"<" @delimiter
name: (identifier) @delimiter
"/>" @delimiter @sentinel) @container
(jsx_self_closing_element
"<" @delimiter
name: (member_expression) @delimiter
"/>" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/json/ 0000775 0000000 0000000 00000000000 15066556776 0021203 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/json/rainbow-delimiters.scm 0000664 0000000 0000000 00000000200 15066556776 0025477 0 ustar 00root root 0000000 0000000 (object
"{" @delimiter
"}" @delimiter @sentinel) @container
(array
"[" @delimiter
"]" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/json5/ 0000775 0000000 0000000 00000000000 15066556776 0021270 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/json5/rainbow-delimiters.scm 0000664 0000000 0000000 00000000021 15066556776 0025565 0 ustar 00root root 0000000 0000000 ; inherits: json
rainbow-delimiters.nvim-v0.10.0/queries/jsonc/ 0000775 0000000 0000000 00000000000 15066556776 0021346 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/jsonc/rainbow-delimiters.scm 0000664 0000000 0000000 00000000021 15066556776 0025643 0 ustar 00root root 0000000 0000000 ; inherits: json
rainbow-delimiters.nvim-v0.10.0/queries/jsonnet/ 0000775 0000000 0000000 00000000000 15066556776 0021712 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/jsonnet/rainbow-delimiters.scm 0000664 0000000 0000000 00000001242 15066556776 0026215 0 ustar 00root root 0000000 0000000 (anonymous_function
"(" @delimiter
")" @delimiter @sentinel) @container
(functioncall
"(" @delimiter
")" @delimiter @sentinel) @container
(bind
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesis
"(" @delimiter
")" @delimiter @sentinel) @container
(field
"(" @delimiter
")" @delimiter @sentinel) @container
(fieldname
"[" @delimiter
"]" @delimiter @sentinel) @container
(array
"[" @delimiter
"]" @delimiter @sentinel) @container
(forloop
"[" @delimiter
"]" @delimiter @sentinel) @container
(indexing
"[" @delimiter
"]" @delimiter @sentinel) @container
(object
"{" @delimiter
"}" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/julia/ 0000775 0000000 0000000 00000000000 15066556776 0021336 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/julia/rainbow-delimiters.scm 0000664 0000000 0000000 00000001033 15066556776 0025637 0 ustar 00root root 0000000 0000000 (vector_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
(matrix_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
(argument_list
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(comprehension_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
(tuple_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(curly_expression
"{" @delimiter
"}" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/kdl/ 0000775 0000000 0000000 00000000000 15066556776 0021004 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/kdl/rainbow-delimiters.scm 0000664 0000000 0000000 00000000233 15066556776 0025306 0 ustar 00root root 0000000 0000000 (node_children
"{" @delimiter
"}" @delimiter @sentinel) @container
(type
"(" @delimiter
(annotation_type)
")" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/kotlin/ 0000775 0000000 0000000 00000000000 15066556776 0021532 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/kotlin/rainbow-delimiters.scm 0000664 0000000 0000000 00000002017 15066556776 0026036 0 ustar 00root root 0000000 0000000 (class_body
"{" @delimiter
"}" @delimiter @sentinel) @container
(function_body
"{" @delimiter
"}" @delimiter @sentinel) @container
(control_structure_body
"{" @delimiter
"}" @delimiter @sentinel) @container
(lambda_literal
"{" @delimiter
"}" @delimiter @sentinel) @container
(primary_constructor
"(" @delimiter
")" @delimiter @sentinel) @container
(function_value_parameters
"(" @delimiter
")" @delimiter @sentinel) @container
(value_arguments
"(" @delimiter
")" @delimiter @sentinel) @container
(multi_variable_declaration
"(" @delimiter
")" @delimiter @sentinel) @container
(for_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(when_expression
(when_subject
"(" @delimiter
")" @delimiter)?
"{" @delimiter
"}" @delimiter @sentinel) @container
(indexing_suffix
"[" @delimiter
"]" @delimiter @sentinel) @container
(type_parameters
"<" @delimiter
">" @delimiter @sentinel) @container
(type_arguments
"<" @delimiter
">" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/latex/ 0000775 0000000 0000000 00000000000 15066556776 0021347 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/latex/rainbow-blocks.scm 0000664 0000000 0000000 00000002160 15066556776 0024766 0 ustar 00root root 0000000 0000000 (inline_formula
"$" @delimiter
"$" @delimiter @sentinel) @container
(generic_environment
(begin) @delimiter
(end) @delimiter @sentinel) @container
(math_environment
(begin) @delimiter
(end) @delimiter @sentinel) @container
(math_delimiter
left_command: _ @delimiter
left_delimiter: _ @delimiter @sentinel
right_command: _ @delimiter
right_delimiter: _ @delimiter @sentinel) @container
(brack_group_key_value
"[" @delimiter
"]" @delimiter @sentinel) @container
(curly_group
"{" @delimiter
"}" @delimiter @sentinel) @container
(label_definition
"\\label" @delimiter
name: (curly_group_label
"{" @delimiter
"}" @delimiter @sentinel) @container)
(label_reference
"\\ref" @delimiter
(curly_group_label_list
"{" @delimiter
"}" @delimiter @sentinel)) @container
(curly_group_text_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(curly_group_path
"{" @delimiter
"}" @delimiter @sentinel) @container
(curly_group_path_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(curly_group_author_list
"{" @delimiter
"}" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/latex/rainbow-delimiters.scm 0000664 0000000 0000000 00000001371 15066556776 0025655 0 ustar 00root root 0000000 0000000 (brack_group_key_value
"[" @delimiter
"]" @delimiter @sentinel) @container
(curly_group
"{" @delimiter
"}" @delimiter @sentinel) @container
(curly_group_text
"{" @delimiter
"}" @delimiter @sentinel) @container
(curly_group_text_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(inline_formula
"$" @delimiter
"$" @delimiter @sentinel) @container
(curly_group_label
"{" @delimiter
"}" @delimiter @sentinel) @container
(curly_group_label_list
"{" @delimiter
"}" @delimiter) @container
(curly_group_path
"{" @delimiter
"}" @delimiter @sentinel) @container
(curly_group_path_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(curly_group_author_list
"{" @delimiter
"}" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/lua/ 0000775 0000000 0000000 00000000000 15066556776 0021013 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/lua/rainbow-blocks.scm 0000664 0000000 0000000 00000002655 15066556776 0024443 0 ustar 00root root 0000000 0000000 ;;; Note: Some patterns are commented out because currently Neovim can capture
;;; only one node at a time. Once it becomes possible to capture multiple
;;; nodes they should be commented back in.
(function_declaration
"function" @delimiter
"end" @delimiter @sentinel) @container
(function_definition
"function" @delimiter
"end" @delimiter @sentinel) @container
(if_statement
"if" @delimiter
"then" @delimiter
(elseif_statement
"elseif" @delimiter
"then" @delimiter)*
(else_statement
"else" @delimiter)?
"end" @delimiter @sentinel) @container
(while_statement
"while" @delimiter
"do" @delimiter
"end" @delimiter @sentinel) @container
(repeat_statement
"repeat" @delimiter
"until" @delimiter @sentinel) @container
(for_statement
"for" @delimiter
(for_generic_clause
"in" @delimiter)?
"do" @delimiter
"end" @delimiter @sentinel) @container
(do_statement
"do" @delimiter
"end" @delimiter @sentinel) @container
;;; Copied over from rainbow-parens
(arguments
"(" @delimiter
")" @delimiter @sentinel) @container
(parameters
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(table_constructor
"{" @delimiter
"}" @delimiter @sentinel) @container
(bracket_index_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
(field
"[" @delimiter
"]" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/lua/rainbow-delimiters.scm 0000664 0000000 0000000 00000000672 15066556776 0025324 0 ustar 00root root 0000000 0000000 (arguments
"(" @delimiter
")" @delimiter @sentinel) @container
(parameters
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(table_constructor
"{" @delimiter
"}" @delimiter @sentinel) @container
(bracket_index_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
(field
"[" @delimiter
"]" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/luadoc/ 0000775 0000000 0000000 00000000000 15066556776 0021501 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/luadoc/rainbow-delimiters.scm 0000664 0000000 0000000 00000002266 15066556776 0026013 0 ustar 00root root 0000000 0000000 (function_type
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_type
"(" @delimiter
")" @delimiter @sentinel) @container
;;; I wanted to use something like
; (union_type
; "|" @delimiter @sentinel
; ) @container
;;; too, but it doesn't fully work with the current parser
(array_type
"[" @delimiter
"]" @delimiter @sentinel) @container
(table_type
"<" @delimiter
">" @delimiter @sentinel) @container
(table_literal_type
"{" @delimiter
"}" @delimiter @sentinel) @container
(indexed_field
"[" @delimiter
"]" @delimiter @sentinel) @container
(tuple_type
"(" @delimiter
")" @delimiter @sentinel) @container
;;; Dictionary-type tables cannot be matched. Their syntax is
;;; { [string]: VALUE_TYPE }
;;; The type of the key is written in square brackets. The square brackets and
;;; their contents need to be their own node, but instead they are all on the
;;; same level without any container node.
;;;
;;; See also https://github.com/tree-sitter-grammars/tree-sitter-luadoc/issues/11
;;; https://luals.github.io/wiki/annotations/#documenting-types
; (_
; "[" @delimiter
; .
; field: (_)
; .
; "]" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/make/ 0000775 0000000 0000000 00000000000 15066556776 0021147 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/make/rainbow-delimiters.scm 0000664 0000000 0000000 00000000120 15066556776 0025444 0 ustar 00root root 0000000 0000000 ;;; Nothing I can think of, everything gets taken from the injected bash query.
rainbow-delimiters.nvim-v0.10.0/queries/markdown/ 0000775 0000000 0000000 00000000000 15066556776 0022054 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/markdown/rainbow-delimiters.scm 0000664 0000000 0000000 00000000314 15066556776 0026356 0 ustar 00root root 0000000 0000000 ;;; Intentionally empty. Markdown can have other languages embedded and we
;;; want to let those grammars handle the highlighting. This query only exists
;;; to satisfy the requirements of this plugin.
rainbow-delimiters.nvim-v0.10.0/queries/nim/ 0000775 0000000 0000000 00000000000 15066556776 0021015 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/nim/rainbow-delimiters.scm 0000664 0000000 0000000 00000002032 15066556776 0025316 0 ustar 00root root 0000000 0000000 (array_construction
"[" @delimiter
"]" @delimiter @sentinel) @container
(tuple_construction
"(" @delimiter
")" @delimiter @sentinel) @container
(tuple_deconstruct_declaration
"(" @delimiter
")" @delimiter @sentinel) @container
(curly_construction
"{" @delimiter
":"? @delimiter
"}" @delimiter @sentinel) @container
(parenthesized
"(" @delimiter
")" @delimiter @sentinel) @container
(argument_list
"(" @delimiter
")" @delimiter @sentinel) @container
(parameter_declaration_list
"(" @delimiter
")" @delimiter @sentinel) @container
(bracket_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
(field_declaration_list
"[" @delimiter
"]" @delimiter @sentinel) @container
(generic_parameter_list
"[" @delimiter
"]" @delimiter @sentinel) @container
(cast
"[" @delimiter
"]" @delimiter
"(" @delimiter
")" @delimiter @sentinel) @container
(term_rewriting_pattern
"{" @delimiter
"}" @delimiter @sentinel) @container
(curly_expression
"{" @delimiter
"}" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/nix/ 0000775 0000000 0000000 00000000000 15066556776 0021030 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/nix/rainbow-delimiters.scm 0000664 0000000 0000000 00000001044 15066556776 0025333 0 ustar 00root root 0000000 0000000 (attrset_expression
("{" @delimiter)
("}" @delimiter @sentinel)) @container
(rec_attrset_expression
("{" @delimiter)
("}" @delimiter @sentinel)) @container
(formals
("{" @delimiter)
("}" @delimiter @sentinel)) @container
(list_expression
("[" @delimiter)
("]" @delimiter @sentinel)) @container
(parenthesized_expression
("(" @delimiter)
(")" @delimiter @sentinel)) @container
(interpolation
("${" @delimiter)
("}" @delimiter @sentinel)) @container
(inherit_from
"(" @delimiter
")" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/nu/ 0000775 0000000 0000000 00000000000 15066556776 0020654 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/nu/rainbow-delimiters.scm 0000664 0000000 0000000 00000001760 15066556776 0025164 0 ustar 00root root 0000000 0000000 (flag_capsule
"(" @delimiter
")" @delimiter @sentinel) @container
(expr_interpolated
"(" @delimiter
")" @delimiter @sentinel) @container
(expr_parenthesized
["(" "...("] @delimiter
")" @delimiter @sentinel) @container
(val_table
"[" @delimiter
"]" @delimiter @sentinel) @container
(val_list
["[" "...["] @delimiter
"]" @delimiter @sentinel) @container
(val_nothing
"(" @delimiter
")" @delimiter @sentinel) @container
(block
"{" @delimiter
"}" @delimiter @sentinel) @container
(ctrl_match
"{" @delimiter
"}" @delimiter @sentinel) @container
(val_record
["{" "...{"] @delimiter
"}" @delimiter @sentinel) @container
(val_closure
"{" @delimiter
"}" @delimiter @sentinel) @container
(collection_type
"<" @delimiter
">" @delimiter @sentinel) @container
(list_type
"<" @delimiter
">" @delimiter @sentinel) @container
(parameter_bracks
"[" @delimiter
"]" @delimiter @sentinel) @container
(parameter_pipes
"|" @delimiter
"|" @delimiter) @container
rainbow-delimiters.nvim-v0.10.0/queries/ocaml/ 0000775 0000000 0000000 00000000000 15066556776 0021325 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/ocaml/rainbow-blocks.scm 0000775 0000000 0000000 00000011521 15066556776 0024750 0 ustar 00root root 0000000 0000000 ; let ... in
(let_expression ; Line 170
(value_definition
"let" @delimiter
("rec" @delimiter)?
("and" @delimiter (let_binding))*)
"in" @delimiter @sentinel) @container
(let_expression ; Line 256
(value_definition
(let_operator) @delimiter
((let_and_operator) @delimiter _)*)
"in" @delimiter @sentinel) @container
(let_open_expression ; Line 268
"let" @delimiter
"in" @delimiter @sentinel) @container
(let_module_expression ; Line 284
"let" @delimiter
"in" @delimiter @sentinel) @container
(match_expression ; Line 182
"match" @delimiter
"with" @delimiter
("|" @delimiter
(match_case
(guard "when" @delimiter)?
"->" @delimiter))+) @container
(function_expression ; Line 272
"function" @delimiter
("|" @delimiter
(match_case
(guard "when" @delimiter)?
"->" @delimiter))+) @container
; I can't get it to collapse else if into one
(if_expression ; Line 193
"if" @delimiter
(then_clause "then" @delimiter)
(else_clause "else" @delimiter)*) @container
(for_expression ; Line 208
"for" @delimiter
"to" @delimiter
(do_clause
"do" @delimiter
"done" @delimiter)) @container
(while_expression ; Line 219
"while" @delimiter
(do_clause
"do" @delimiter
"done" @delimiter)) @container
;;; Copied over from rainbow-delimiters
(array_get_expression ; Line 8
"(" @delimiter
")" @delimiter @sentinel) @container
(coercion_expression ; Line 122
"(" @delimiter
")" @delimiter @sentinel) @container
(constructed_type ; Line 14
"(" @delimiter
")" @delimiter @sentinel) @container
(local_open_expression ; Line 27
"(" @delimiter
")" @delimiter @sentinel) @container
(module_parameter ; Line 38
"(" @delimiter
")" @delimiter @sentinel) @container
(package_expression ; Line 31
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_expression ; Line 6
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_module_expression ; Line 47
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_operator ; Line 25
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_pattern ; Line 23
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_type ; Line 12
"(" @delimiter
")" @delimiter @sentinel) @container
(object_expression ; Line 54
"(" @delimiter
")" @delimiter @sentinel) @container
(typed_pattern ; Line 18
"(" @delimiter
")" @delimiter @sentinel) @container
(typed_expression ; Line 50
"(" @delimiter
")" @delimiter @sentinel) @container
(list_expression ; Line 18
"[" @delimiter
"]" @delimiter @sentinel) @container
(list_pattern ; Line 63
"[" @delimiter
"]" @delimiter @sentinel) @container
(array_expression ; Line 68
"[|" @delimiter
"|]" @delimiter @sentinel) @container
(array_pattern ; Line 73
"[|" @delimiter
"|]" @delimiter @sentinel) @container
(attribute ; Line 84
"[@" @delimiter
"]" @delimiter @sentinel) @container
(item_attribute ; Line 90
"[@@" @delimiter
"]" @delimiter @sentinel) @container
(floating_attribute ; Line 93
"[@@@" @delimiter
"]" @delimiter @sentinel) @container
(record_pattern ; Line 104
"{" @delimiter
"}" @delimiter @sentinel) @container
(record_expression ; Line 99
"{" @delimiter
"}" @delimiter @sentinel) @container
(record_declaration ; Line 96
"{" @delimiter
"}" @delimiter @sentinel) @container
; Can't find an example
; (record_binding_pattern
; "{" @delimiter
; "}" @delimiter @sentinel) @container
(class_binding ; Line 127
"[" @delimiter
"]" @delimiter @sentinel) @container
(polymorphic_variant_type ; Line 244
"[" @delimiter
"]" @delimiter @sentinel) @container
(polymorphic_variant_type ; Line 130
"[<" @delimiter
"]" @delimiter @sentinel) @container
(polymorphic_variant_type ; Line 137
"[>" @delimiter
"]" @delimiter @sentinel) @container
(string_get_expression ; Line 77
"[" @delimiter
"]" @delimiter @sentinel) @container
(extension ; Line 140
"[%" @delimiter
"]" @delimiter @sentinel) @container
(item_extension ; Line 147
"[%%" @delimiter
"]" @delimiter @sentinel) @container
(quoted_item_extension ; Line 150
"{%%" @delimiter
"}" @delimiter @sentinel) @container
(quoted_string ; Line 81
"{" @delimiter
"}" @sentinel) @container
(bigarray_get_expression ; Line 158
"{" @delimiter
"}" @delimiter @sentinel) @container
(object_copy_expression ; Line 166
"{<" @delimiter
">}" @delimiter @sentinel) @container
(packed_module ; Line 242
"(" @delimiter
")" @delimiter @sentinel) @container
(abstract_type ; Line 248
"(" @delimiter
")" @delimiter @sentinel) @container
(type_binding ; Line 276
"(" @delimiter
")" @delimiter @sentinel) @container
(parameter ; Line 252
("?" @delimiter)?
("~" @delimiter)?
"(" @delimiter
")" @delimiter @sentinel) @container
(package_pattern ; Line 278
"(" @delimiter
")" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/ocaml/rainbow-delimiters.scm 0000775 0000000 0000000 00000007044 15066556776 0025641 0 ustar 00root root 0000000 0000000 (array_get_expression ; Line 8
"(" @delimiter
")" @delimiter @sentinel) @container
(coercion_expression ; Line 122
"(" @delimiter
")" @delimiter @sentinel) @container
(constructed_type ; Line 14
"(" @delimiter
")" @delimiter @sentinel) @container
(local_open_expression ; Line 27
"(" @delimiter
")" @delimiter @sentinel) @container
(module_parameter ; Line 38
"(" @delimiter
")" @delimiter @sentinel) @container
(package_expression ; Line 31
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_expression ; Line 6
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_module_expression ; Line 47
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_operator ; Line 25
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_pattern ; Line 23
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_type ; Line 12
"(" @delimiter
")" @delimiter @sentinel) @container
(object_expression ; Line 54
"(" @delimiter
")" @delimiter @sentinel) @container
(typed_pattern ; Line 18
"(" @delimiter
")" @delimiter @sentinel) @container
(typed_expression ; Line 50
"(" @delimiter
")" @delimiter @sentinel) @container
(list_expression ; Line 18
"[" @delimiter
"]" @delimiter @sentinel) @container
(list_pattern ; Line 63
"[" @delimiter
"]" @delimiter @sentinel) @container
(array_expression ; Line 68
"[|" @delimiter
"|]" @delimiter @sentinel) @container
(array_pattern ; Line 73
"[|" @delimiter
"|]" @delimiter @sentinel) @container
(attribute ; Line 84
"[@" @delimiter
"]" @delimiter @sentinel) @container
(item_attribute ; Line 90
"[@@" @delimiter
"]" @delimiter @sentinel) @container
(floating_attribute ; Line 93
"[@@@" @delimiter
"]" @delimiter @sentinel) @container
(record_pattern ; Line 104
"{" @delimiter
"}" @delimiter @sentinel) @container
(record_expression ; Line 99
"{" @delimiter
"}" @delimiter @sentinel) @container
(record_declaration ; Line 96
"{" @delimiter
"}" @delimiter @sentinel) @container
; Can't find an example
; (record_binding_pattern
; "{" @delimiter
; "}" @delimiter @sentinel) @container
(class_binding ; Line 127
"[" @delimiter
"]" @delimiter @sentinel) @container
(polymorphic_variant_type ; Line 244
"[" @delimiter
"]" @delimiter @sentinel) @container
(polymorphic_variant_type ; Line 130
"[<" @delimiter
"]" @delimiter @sentinel) @container
(polymorphic_variant_type ; Line 137
"[>" @delimiter
"]" @delimiter @sentinel) @container
(string_get_expression ; Line 77
"[" @delimiter
"]" @delimiter @sentinel) @container
(extension ; Line 140
"[%" @delimiter
"]" @delimiter @sentinel) @container
(item_extension ; Line 147
"[%%" @delimiter
"]" @delimiter @sentinel) @container
(quoted_item_extension ; Line 150
"{%%" @delimiter
"}" @delimiter @sentinel) @container
(quoted_string ; Line 81
"{" @delimiter
"}" @sentinel) @container
(bigarray_get_expression ; Line 158
"{" @delimiter
"}" @delimiter @sentinel) @container
(object_copy_expression ; Line 166
"{<" @delimiter
">}" @delimiter @sentinel) @container
(packed_module ; Line 242
"(" @delimiter
")" @delimiter @sentinel) @container
(abstract_type ; Line 248
"(" @delimiter
")" @delimiter @sentinel) @container
(type_binding ; Line 276
"(" @delimiter
")" @delimiter @sentinel) @container
(parameter; Line 252
("?" @delimiter)?
("~" @delimiter)?
"(" @delimiter
")" @delimiter @sentinel) @container
(package_pattern ; Line 278
"(" @delimiter
")" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/odin/ 0000775 0000000 0000000 00000000000 15066556776 0021163 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/odin/rainbow-delimiters.scm 0000664 0000000 0000000 00000003444 15066556776 0025474 0 ustar 00root root 0000000 0000000 (parameters
"(" @delimiter
")" @delimiter @sentinel) @container
(tuple_type
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(polymorphic_parameters
"(" @delimiter
")" @delimiter @sentinel) @container
(polymorphic_type
"(" @delimiter
")" @delimiter @sentinel) @container
(attribute
"(" @delimiter
")" @delimiter @sentinel) @container
(call_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(index_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
(slice_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
(block
"{" @delimiter
"}" @delimiter @sentinel) @container
(switch_statement
"{" @delimiter
"}" @delimiter @sentinel) @container
(array_type
"[" @delimiter
"]" @delimiter @sentinel) @container
(struct
("(" @delimiter
")" @delimiter)?
("[" @delimiter
"]" @delimiter)?
("{" @delimiter
"}" @delimiter @sentinel)
) @container
(map_type
"[" @delimiter
"]" @delimiter @sentinel) @container
(map
"[" @delimiter
"]" @delimiter
"{" @delimiter
"}" @delimiter @sentinel) @container
(matrix_type
"[" @delimiter
"]" @delimiter @sentinel) @container
(matrix
"[" @delimiter
"]" @delimiter
"{" @delimiter
"}" @delimiter @sentinel) @container
(bit_set_type
"[" @delimiter
"]" @delimiter @sentinel) @container
(bit_set
"[" @delimiter
"]" @delimiter
"{" @delimiter
"}" @delimiter @sentinel) @container
(struct_declaration
"{" @delimiter
"}" @delimiter @sentinel) @container
(enum_declaration
"{" @delimiter
"}" @delimiter @sentinel) @container
(union_declaration
"{" @delimiter
"}" @delimiter @sentinel) @container
(bit_field_declaration
"{" @delimiter
"}" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/perl/ 0000775 0000000 0000000 00000000000 15066556776 0021174 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/perl/rainbow-delimiters.scm 0000664 0000000 0000000 00000002646 15066556776 0025510 0 ustar 00root root 0000000 0000000 (signature
"(" @delimiter
")" @delimiter) @container
(block
"{" @delimiter
"}" @delimiter) @container
(anonymous_hash_expression
"{" @delimiter
"}" @delimiter) @container
(stub_expression
"(" @delimiter
")" @delimiter) @container
(hash_element_expression
"{" @delimiter
"}" @delimiter) @container
(array_element_expression
"[" @delimiter
"]" @delimiter) @container
(function_call_expression
"(" @delimiter
")" @delimiter) @container
(anonymous_array_expression
"[" @delimiter
"]" @delimiter) @container
(slice_expression
"[" @delimiter
"]" @delimiter) @container
(conditional_statement
"(" @delimiter
")" @delimiter) @container
(quoted_word_list
"qw"
"'" @delimiter
"'" @delimiter) @container
(quoted_regexp
"qr"
"'" @delimiter
"'" @delimiter) @container
(command_string
"qx"
"'" @delimiter
"'" @delimiter) @container
(interpolated_string_literal
"qq"
"'" @delimiter
"'" @delimiter) @container
(string_literal
"q"
"'" @delimiter
"'" @delimiter) @container
(match_regexp
"m"
"'" @delimiter
"'" @delimiter) @container
(substitution_regexp
"s"
"'" @delimiter
"'" @delimiter
"'" @delimiter
"'" @delimiter) @container
(transliteration_expression
"tr"
"'" @delimiter
"'" @delimiter
"'" @delimiter
"'" @delimiter) @container
(transliteration_expression
"y"
"'" @delimiter
"'" @delimiter
"'" @delimiter
"'" @delimiter) @container
rainbow-delimiters.nvim-v0.10.0/queries/php/ 0000775 0000000 0000000 00000000000 15066556776 0021021 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/php/rainbow-delimiters.scm 0000664 0000000 0000000 00000001207 15066556776 0025325 0 ustar 00root root 0000000 0000000 (parenthesized_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(arguments
"(" @delimiter
")" @delimiter @sentinel) @container
(formal_parameters
"(" @delimiter
")" @delimiter @sentinel) @container
(declaration_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(compound_statement
"{" @delimiter
"}" @delimiter @sentinel) @container
(encapsed_string
"{" @delimiter
"}" @delimiter @sentinel) @container
(array_creation_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
(subscript_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/python/ 0000775 0000000 0000000 00000000000 15066556776 0021553 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/python/rainbow-delimiters.scm 0000664 0000000 0000000 00000003022 15066556776 0026054 0 ustar 00root root 0000000 0000000 ;; NOTE: When updating this file update the Starlark test file as well if
;; applicable.
(list
"[" @delimiter
"]" @delimiter @sentinel) @container
(list_pattern
"[" @delimiter
"]" @delimiter @sentinel) @container
(list_comprehension
"[" @delimiter
"]" @delimiter @sentinel) @container
(dictionary
"{" @delimiter
"}" @delimiter @sentinel) @container
(dict_pattern
"{" @delimiter
"}" @delimiter @sentinel) @container
(dictionary_comprehension
"{" @delimiter
"}" @delimiter @sentinel) @container
(set
"{" @delimiter
"}" @delimiter @sentinel) @container
(set_comprehension
"{" @delimiter
"}" @delimiter @sentinel) @container
(tuple
"(" @delimiter
")" @delimiter @sentinel) @container
(tuple_pattern
"(" @delimiter
")" @delimiter @sentinel) @container
(generator_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(parameters
"(" @delimiter
")" @delimiter @sentinel) @container
(argument_list
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(subscript
"[" @delimiter
"]" @delimiter @sentinel) @container
(type_parameter
"[" @delimiter
"]" @delimiter @sentinel) @container
(import_from_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(string
(interpolation
"{" @delimiter
"}" @delimiter @sentinel) @container)
(format_expression
"{" @delimiter
"}" @delimiter @sentinel) @container
(with_clause
"(" @delimiter
")" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/query/ 0000775 0000000 0000000 00000000000 15066556776 0021377 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/query/rainbow-blocks.scm 0000664 0000000 0000000 00000001407 15066556776 0025021 0 ustar 00root root 0000000 0000000 ;; Note: These queries are very useful when looking at a large
;; tree of queries like in `InspectTree`
(named_node
"(" @delimiter
(identifier) @delimiter
")" @delimiter @sentinel) @container
(missing_node
"(" @delimiter
"MISSING" @delimiter
(identifier)? @delimiter
")" @delimiter @sentinel) @container
(grouping
"(" @delimiter
")" @delimiter @sentinel) @container
(list
"[" @delimiter
"]" @delimiter @sentinel) @container
(predicate
"(" @delimiter
")" @delimiter @sentinel) @container
(field_definition
(identifier) @delimiter @sentinel) @container
;; For more highlighting the following can be added too:
; (parameters
; (identifier) @delimiter @sentinel) @container
;
; (negated_field
; (identifier) @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/query/rainbow-delimiters.scm 0000664 0000000 0000000 00000000521 15066556776 0025701 0 ustar 00root root 0000000 0000000 (named_node
"(" @delimiter
")" @delimiter @sentinel) @container
(missing_node
"(" @delimiter
")" @delimiter @sentinel) @container
(grouping
"(" @delimiter
")" @delimiter @sentinel) @container
(list
"[" @delimiter
"]" @delimiter @sentinel) @container
(predicate
"(" @delimiter
")" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/r/ 0000775 0000000 0000000 00000000000 15066556776 0020473 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/r/rainbow-delimiters.scm 0000664 0000000 0000000 00000001123 15066556776 0024774 0 ustar 00root root 0000000 0000000 (arguments
"(" @delimiter
")" @delimiter @sentinel) @container
(arguments
"[" @delimiter
"]" @delimiter @sentinel) @container
(arguments
"[[" @delimiter
"]]" @delimiter @sentinel) @container
(if_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(for_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(while_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(function_definition
(parameters
"(" @delimiter
")" @delimiter @sentinel)) @container
(braced_expression
"{" @delimiter
"}" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/racket/ 0000775 0000000 0000000 00000000000 15066556776 0021503 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/racket/rainbow-delimiters.scm 0000664 0000000 0000000 00000000370 15066556776 0026007 0 ustar 00root root 0000000 0000000 (list
"(" @delimiter
(dot)? @delimiter
")" @delimiter @sentinel) @container
(list
"[" @delimiter
(dot)? @delimiter
"]" @delimiter @sentinel) @container
(list
"{" @delimiter
(dot)? @delimiter
"}" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/rasi/ 0000775 0000000 0000000 00000000000 15066556776 0021170 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/rasi/rainbow-delimiters.scm 0000664 0000000 0000000 00000001635 15066556776 0025501 0 ustar 00root root 0000000 0000000 (block
"{" @delimiter
"}" @delimiter @sentinel) @container
(environ_value
"$" @delimiter
"{" @delimiter
"}" @delimiter @sentinel) @container
(environ_value
"(" @delimiter
")" @delimiter @sentinel) @container
(list_value
"[" @delimiter
"]" @delimiter @sentinel) @container
(distance_calc
"(" @delimiter
")" @delimiter @sentinel) @container
(feature_query
"(" @delimiter
")" @delimiter @sentinel) @container
(reference_value
"(" @delimiter
")" @delimiter @sentinel) @container
(rgb_color
"(" @delimiter
")" @delimiter @sentinel) @container
(hsl_color
"(" @delimiter
")" @delimiter @sentinel) @container
(hwb_color
"(" @delimiter
")" @delimiter @sentinel) @container
(cmyk_color
"(" @delimiter
")" @delimiter @sentinel) @container
(url_image
"(" @delimiter
")" @delimiter @sentinel) @container
(gradient_image
"(" @delimiter
")" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/regex/ 0000775 0000000 0000000 00000000000 15066556776 0021344 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/regex/rainbow-delimiters.scm 0000664 0000000 0000000 00000000670 15066556776 0025653 0 ustar 00root root 0000000 0000000 (anonymous_capturing_group
"(" @delimiter
")" @delimiter @sentinel) @container
;;; The inversion `^` should be an opening node as well
(character_class
"[" @delimiter
"]" @delimiter @sentinel) @container
(count_quantifier
"{" @delimiter
"}" @delimiter @sentinel) @container
;;; We should probably include the character after `?` like `=` as well
(lookaround_assertion
"(?" @delimiter
")" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/rst/ 0000775 0000000 0000000 00000000000 15066556776 0021042 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/rst/rainbow-delimiters.scm 0000664 0000000 0000000 00000000324 15066556776 0025345 0 ustar 00root root 0000000 0000000 ;;; Intentionally empty. ReStructuredText can have other languages embedded
;;; and we want to let those grammars handle the highlighting. This query only
;;; exists to satisfy the requirements of this plugin.
rainbow-delimiters.nvim-v0.10.0/queries/ruby/ 0000775 0000000 0000000 00000000000 15066556776 0021213 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/ruby/rainbow-delimiters.scm 0000664 0000000 0000000 00000000540 15066556776 0025516 0 ustar 00root root 0000000 0000000 (block
"{" @delimiter
"}" @delimiter @sentinel) @container
(hash
"{" @delimiter
"}" @delimiter @sentinel) @container
(array
"[" @delimiter
"]" @delimiter @sentinel) @container
(parenthesized_statements
"(" @delimiter
")" @delimiter @sentinel) @container
(block_parameters
.
"|" @delimiter
"|" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/rust/ 0000775 0000000 0000000 00000000000 15066556776 0021227 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/rust/rainbow-delimiters.scm 0000664 0000000 0000000 00000005006 15066556776 0025534 0 ustar 00root root 0000000 0000000 (parenthesized_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(declaration_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(field_declaration_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(ordered_field_declaration_list
"(" @delimiter
")" @delimiter @sentinel) @container
(enum_variant_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(use_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(field_initializer_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(parameters
"(" @delimiter
")" @delimiter @sentinel) @container
(arguments
"(" @delimiter
")" @delimiter @sentinel) @container
(block
"{" @delimiter
"}" @delimiter @sentinel) @container
(match_block
"{" @delimiter
"}" @delimiter @sentinel) @container
(tuple_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(tuple_type
"(" @delimiter
")" @delimiter @sentinel) @container
(token_tree
"{" @delimiter
"}" @delimiter @sentinel) @container
(token_tree
"(" @delimiter
")" @delimiter @sentinel) @container
(token_tree
"[" @delimiter
"]" @delimiter @sentinel) @container
(token_tree_pattern
"(" @delimiter
")" @delimiter @sentinel) @container
(token_repetition_pattern
"$" @delimiter
"(" @delimiter
")" @delimiter @sentinel) @container
(token_repetition
"$" @delimiter
"(" @delimiter
")" @delimiter @sentinel) @container
(attribute_item
"[" @delimiter
"]" @delimiter @sentinel) @container
(inner_attribute_item
"[" @delimiter
"]" @delimiter @sentinel) @container
(type_arguments
"<" @delimiter
">" @delimiter @sentinel) @container
(type_parameters
"<" @delimiter
">" @delimiter @sentinel) @container
(closure_parameters
"|" @delimiter
(_)?
"|" @delimiter @sentinel) @container
(array_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
(array_type
"[" @delimiter
"]" @delimiter @sentinel) @container
(index_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
(tuple_struct_pattern
"(" @delimiter
")" @delimiter @sentinel) @container
(tuple_pattern
"(" @delimiter
")" @delimiter @sentinel) @container
(struct_pattern
"{" @delimiter
"}" @delimiter @sentinel) @container
(slice_pattern
"[" @delimiter
"]" @delimiter @sentinel) @container
(macro_definition
"{" @delimiter
"}" @delimiter @sentinel) @container
(visibility_modifier
"(" @delimiter
")" @delimiter @sentinel) @container
(bracketed_type
"<" @delimiter
">" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/scheme/ 0000775 0000000 0000000 00000000000 15066556776 0021476 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/scheme/rainbow-delimiters.scm 0000664 0000000 0000000 00000000175 15066556776 0026005 0 ustar 00root root 0000000 0000000 (list
"(" @delimiter
")" @delimiter @sentinel) @container
(list
"[" @delimiter
"]" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/scss/ 0000775 0000000 0000000 00000000000 15066556776 0021205 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/scss/rainbow-delimiters.scm 0000664 0000000 0000000 00000000125 15066556776 0025507 0 ustar 00root root 0000000 0000000 ; inherits: css
(parameters
"(" @delimiter
")" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/sql/ 0000775 0000000 0000000 00000000000 15066556776 0021031 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/sql/rainbow-delimiters.scm 0000664 0000000 0000000 00000000445 15066556776 0025340 0 ustar 00root root 0000000 0000000 (subquery
"(" @delimiter
")" @delimiter @sentinel) @container
(invocation
"(" @delimiter
")" @delimiter @sentinel) @container
(list
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_expression
"(" @delimiter
")" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/starlark/ 0000775 0000000 0000000 00000000000 15066556776 0022055 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/starlark/rainbow-delimiters.scm 0000664 0000000 0000000 00000003007 15066556776 0026361 0 ustar 00root root 0000000 0000000 ;; This is mostly identical to Python, without `generator_expression`.
;; NOTE: if you update queries for Python, please consider adding the changes
;; to this file as well, given that the tree-sitter's node types exist. See
;; https://github.com/amaanq/tree-sitter-starlark/blob/master/src/node-types.json
(list
"[" @delimiter
"]" @delimiter @sentinel) @container
(list_pattern
"[" @delimiter
"]" @delimiter @sentinel) @container
(list_comprehension
"[" @delimiter
"]" @delimiter @sentinel) @container
(dictionary
"{" @delimiter
"}" @delimiter @sentinel) @container
(dict_pattern
"{" @delimiter
"}" @delimiter @sentinel) @container
(dictionary_comprehension
"{" @delimiter
"}" @delimiter @sentinel) @container
(set
"{" @delimiter
"}" @delimiter @sentinel) @container
(set_comprehension
"{" @delimiter
"}" @delimiter @sentinel) @container
(tuple
"(" @delimiter
")" @delimiter @sentinel) @container
(tuple_pattern
"(" @delimiter
")" @delimiter @sentinel) @container
(parameters
"(" @delimiter
")" @delimiter @sentinel) @container
(argument_list
"(" @delimiter
")" @delimiter @sentinel) @container
(parenthesized_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(subscript
"[" @delimiter
"]" @delimiter @sentinel) @container
(type_parameter
"[" @delimiter
"]" @delimiter @sentinel) @container
(string
(interpolation
"{" @delimiter
"}" @delimiter @sentinel) @container)
(format_expression
"{" @delimiter
"}" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/svelte/ 0000775 0000000 0000000 00000000000 15066556776 0021534 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/svelte/rainbow-delimiters.scm 0000664 0000000 0000000 00000001263 15066556776 0026042 0 ustar 00root root 0000000 0000000 (script_element
(start_tag
"<" @delimiter
(tag_name) @delimiter
">" @delimiter)
(end_tag
"" @delimiter
(tag_name) @delimiter
">" @delimiter @sentinel)) @container
(style_element
(start_tag
"<" @delimiter
(tag_name) @delimiter
">" @delimiter)
(end_tag
"" @delimiter
(tag_name) @delimiter
">" @delimiter @sentinel)) @container
(element
(self_closing_tag
"<" @delimiter
(tag_name) @delimiter
"/>" @delimiter @sentinel)) @container
(element
(start_tag
"<" @delimiter
(tag_name) @delimiter
">" @delimiter)
(end_tag
"" @delimiter
(tag_name) @delimiter
">" @delimiter @sentinel)) @container
rainbow-delimiters.nvim-v0.10.0/queries/svelte/rainbow-delimiters.txt 0000664 0000000 0000000 00000002106 15066556776 0026074 0 ustar 00root root 0000000 0000000 (script_element
(start_tag
"<" @delimiter
(tag_name) @delimiter
">" @delimiter)
(end_tag
"" @delimiter
(tag_name) @delimiter
">" @delimiter @sentinel)) @container
(style_element
(start_tag
"<" @delimiter
(tag_name) @delimiter
">" @delimiter)
(end_tag
"" @delimiter
(tag_name) @delimiter
">" @delimiter @sentinel)) @container
(element
(self_closing_tag
"<" @delimiter
(tag_name) @delimiter
"/>" @delimiter @sentinel)) @container
(element
(start_tag
"<" @delimiter
(tag_name) @delimiter
">" @delimiter)
(end_tag
"" @delimiter
(tag_name) @delimiter
">" @delimiter @sentinel)) @container
(const_expr
"{" @delimiter
"@" @delimiter
(special_block_keyword) @delimiter
"}" @delimiter @sentinel) @container
(each_statement
(each_start_expr
"{" @delimiter
"#" @delimiter
(special_block_keyword) @delimiter
"}" @delimiter) @container
(each_end_expr
"{" @delimiter
"/" @delimiter
(special_block_keyword) @delimiter
"}" @delimiter @sentinel)) @container
rainbow-delimiters.nvim-v0.10.0/queries/swift/ 0000775 0000000 0000000 00000000000 15066556776 0021366 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/swift/rainbow-delimiters.scm 0000664 0000000 0000000 00000002515 15066556776 0025675 0 ustar 00root root 0000000 0000000 (class_body
"{" @delimiter
"}" @delimiter @sentinel) @container
;; Support for function declarations
(function_declaration
"(" @delimiter
")" @delimiter @sentinel) @container
;; Support for functions
(function_body
"{" @delimiter
"}" @delimiter @sentinel) @container
(value_arguments
"(" @delimiter
")" @delimiter @sentinel) @container
;; Support for closures
(lambda_literal
"{" @delimiter
"}" @delimiter @sentinel) @container
(switch_statement
"{" @delimiter
"}" @delimiter @sentinel) @container
;; Support for computed properties
(computed_property
"{" @delimiter
"}" @delimiter @sentinel) @container
;; Support for enum bodies
(enum_class_body
"{" @delimiter
"}" @delimiter @sentinel) @container
;; Support for didSet and willSet blocks
(willset_didset_block
"{" @delimiter
"}" @delimiter @sentinel) @container
(didset_clause
"{" @delimiter
"}" @delimiter @sentinel) @container
(willset_clause
"{" @delimiter
"}" @delimiter @sentinel) @container
;; Array matching
(array_literal
"[" @delimiter
"]" @delimiter @sentinel) @container
;; Dictionary matching
(dictionary_literal
"[" @delimiter
"]" @delimiter @sentinel) @container
;; Tuple matching
(tuple_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(tuple_type
"(" @delimiter
")" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/systemverilog/ 0000775 0000000 0000000 00000000000 15066556776 0023146 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/systemverilog/rainbow-blocks.scm 0000664 0000000 0000000 00000002576 15066556776 0026600 0 ustar 00root root 0000000 0000000 ; match blocks
(seq_block
"begin" @delimiter
"end" @delimiter @sentinel) @container
; match parentheses
(packed_dimension
"[" @delimiter
"]" @delimiter @sentinel) @container
(data_type
"{" @delimiter
"}" @delimiter @sentinel) @container
(parameter_port_list
"(" @delimiter
")" @delimiter @sentinel) @container
(named_port_connection
"(" @delimiter
")" @delimiter @sentinel) @container
(list_of_port_declarations
"(" @delimiter
")" @delimiter @sentinel) @container
(parameter_value_assignment
"(" @delimiter
")" @delimiter @sentinel) @container
(named_parameter_assignment
"(" @delimiter
")" @delimiter @sentinel) @container
(hierarchical_instance
"(" @delimiter
")" @delimiter @sentinel) @container
(cast
"(" @delimiter
")" @delimiter @sentinel) @container
(conditional_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(event_control
"(" @delimiter
")" @delimiter @sentinel) @container
(primary
"(" @delimiter
")" @delimiter @sentinel) @container
(constant_primary
"(" @delimiter
")" @delimiter @sentinel) @container
(concatenation
"{" @delimiter
"}" @delimiter @sentinel) @container
(constant_concatenation
"{" @delimiter
"}" @delimiter @sentinel) @container
(multiple_concatenation
"{" @delimiter
"}" @delimiter @sentinel) @container
(bit_select
"[" @delimiter
"]" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/systemverilog/rainbow-delimiters.scm 0000664 0000000 0000000 00000002415 15066556776 0027454 0 ustar 00root root 0000000 0000000 (packed_dimension
"[" @delimiter
"]" @delimiter @sentinel) @container
(data_type
"{" @delimiter
"}" @delimiter @sentinel) @container
(parameter_port_list
"(" @delimiter
")" @delimiter @sentinel) @container
(named_port_connection
"(" @delimiter
")" @delimiter @sentinel) @container
(list_of_port_declarations
"(" @delimiter
")" @delimiter @sentinel) @container
(parameter_value_assignment
"(" @delimiter
")" @delimiter @sentinel) @container
(named_parameter_assignment
"(" @delimiter
")" @delimiter @sentinel) @container
(hierarchical_instance
"(" @delimiter
")" @delimiter @sentinel) @container
(cast
"(" @delimiter
")" @delimiter @sentinel) @container
(conditional_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(event_control
"(" @delimiter
")" @delimiter @sentinel) @container
(primary
"(" @delimiter
")" @delimiter @sentinel) @container
(constant_primary
"(" @delimiter
")" @delimiter @sentinel) @container
(concatenation
"{" @delimiter
"}" @delimiter @sentinel) @container
(constant_concatenation
"{" @delimiter
"}" @delimiter @sentinel) @container
(multiple_concatenation
"{" @delimiter
"}" @delimiter @sentinel) @container
(bit_select
"[" @delimiter
"]" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/teal/ 0000775 0000000 0000000 00000000000 15066556776 0021157 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/teal/rainbow-delimiters.scm 0000664 0000000 0000000 00000000525 15066556776 0025465 0 ustar 00root root 0000000 0000000 (arguments
"(" @delimiter
")" @delimiter @sentinel) @container
(table_constructor
"{" @delimiter
"}" @delimiter @sentinel) @container
(table_entry
"[" @delimiter
"]" @delimiter @sentinel) @container
(index
"[" @delimiter
"]" @delimiter @sentinel) @container
(field
"[" @delimiter
"]" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/templ/ 0000775 0000000 0000000 00000000000 15066556776 0021353 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/templ/rainbow-delimiters.scm 0000664 0000000 0000000 00000002311 15066556776 0025654 0 ustar 00root root 0000000 0000000 ; inherits: go
;; HTML elements
(element
(tag_start
"<" @delimiter
(element_identifier) @delimiter
">" @delimiter)
(tag_end
"" @delimiter
(element_identifier) @delimiter
">" @delimiter @sentinel)) @container
(element
(self_closing_tag
"<" @delimiter
(element_identifier) @delimiter
"/>" @delimiter @sentinel)) @container
(style_element
(style_tag_start
"<" @delimiter
"style" @delimiter
">" @delimiter)
(style_tag_end
"" @delimiter
"style" @delimiter
">" @delimiter)) @container
(script_element
(script_tag_start
"<" @delimiter
"script" @delimiter
">" @delimiter)
(script_tag_end
"" @delimiter
"script" @delimiter
">" @delimiter)) @container
;; Brackets
(component_block
"{" @delimiter
"}" @delimiter @sentinel) @container
(script_block
"{" @delimiter
"}" @delimiter @sentinel) @container
(css_declaration
"{" @delimiter
"}" @delimiter @sentinel) @container
(component_switch_statement
"{" @delimiter
"}" @delimiter @sentinel) @container
(component_children_expression
"{" @delimiter
"}" @delimiter @sentinel) @container
(expression
"{" @delimiter
"}" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/terraform/ 0000775 0000000 0000000 00000000000 15066556776 0022233 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/terraform/rainbow-delimiters.scm 0000664 0000000 0000000 00000000020 15066556776 0026527 0 ustar 00root root 0000000 0000000 ; inherits: hcl
rainbow-delimiters.nvim-v0.10.0/queries/toml/ 0000775 0000000 0000000 00000000000 15066556776 0021205 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/toml/rainbow-delimiters.scm 0000664 0000000 0000000 00000000426 15066556776 0025513 0 ustar 00root root 0000000 0000000 (table
"[" @delimiter
"]" @delimiter @sentinel) @container
(array
"[" @delimiter
"]" @delimiter @sentinel) @container
(inline_table
"{" @delimiter
"}" @delimiter @sentinel) @container
(table_array_element
"[[" @delimiter
"]]" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/tsx/ 0000775 0000000 0000000 00000000000 15066556776 0021050 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/tsx/rainbow-delimiters.scm 0000664 0000000 0000000 00000001716 15066556776 0025361 0 ustar 00root root 0000000 0000000 ; inherits: typescript
(jsx_element
open_tag: (jsx_opening_element
"<" @delimiter
name: (identifier) @delimiter
">" @delimiter)
close_tag: (jsx_closing_element
"" @delimiter
name: (identifier) @delimiter
">" @delimiter @sentinel)) @container
(jsx_element
open_tag: (jsx_opening_element
"<" @delimiter
name: (member_expression) @delimiter
">" @delimiter)
close_tag: (jsx_closing_element
"" @delimiter
name: (member_expression) @delimiter
">" @delimiter @sentinel)) @container
(jsx_self_closing_element
"<" @delimiter
name: (identifier) @delimiter
"/>" @delimiter @sentinel) @container
(jsx_self_closing_element
"<" @delimiter
name: (member_expression) @delimiter
"/>" @delimiter @sentinel) @container
(jsx_expression
"{" @delimiter
"}" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/tsx/rainbow-parens.scm 0000664 0000000 0000000 00000000162 15066556776 0024502 0 ustar 00root root 0000000 0000000 ; inherits: typescript
;;; This query exists for people who only want to highlight parentheses without
;;; tags.
rainbow-delimiters.nvim-v0.10.0/queries/tsx/rainbow-tags-react.scm 0000664 0000000 0000000 00000000162 15066556776 0025244 0 ustar 00root root 0000000 0000000 ; inherits: javascript
;;; This query exists for people who only want to highlight tags without
;;; parentheses.
rainbow-delimiters.nvim-v0.10.0/queries/typescript/ 0000775 0000000 0000000 00000000000 15066556776 0022440 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/typescript/rainbow-delimiters.scm 0000664 0000000 0000000 00000001115 15066556776 0026742 0 ustar 00root root 0000000 0000000 ; inherits: javascript
(interface_body
"{" @delimiter
"}" @delimiter @sentinel) @container
(enum_body
"{" @delimiter
"}" @delimiter @sentinel) @container
(type_arguments
"<" @delimiter
">" @delimiter @sentinel) @container
(type_parameters
"<" @delimiter
">" @delimiter @sentinel) @container
(array_type
"[" @delimiter
"]" @delimiter @sentinel) @container
(lookup_type
"[" @delimiter
"]" @delimiter @sentinel) @container
(object_type
"{" @delimiter
"}" @delimiter @sentinel) @container
(tuple_type
"[" @delimiter
"]" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/typescript/rainbow-parens.scm 0000777 0000000 0000000 00000000000 15066556776 0032372 2rainbow-delimiters.scm ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/typst/ 0000775 0000000 0000000 00000000000 15066556776 0021415 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/typst/rainbow-delimiters.scm 0000664 0000000 0000000 00000000477 15066556776 0025731 0 ustar 00root root 0000000 0000000 (group
"(" @delimiter
")" @delimiter @sentinel) @container
(block
"{" @delimiter
"}" @delimiter @sentinel) @container
(content
"[" @delimiter
"]" @delimiter @sentinel) @container
(math
"$" @delimiter
"$" @delimiter @sentinel) @container
(call
"(" @delimiter
")" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/vim/ 0000775 0000000 0000000 00000000000 15066556776 0021025 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/vim/rainbow-delimiters.scm 0000664 0000000 0000000 00000005267 15066556776 0025343 0 ustar 00root root 0000000 0000000 ;;; Note: The Vim grammar places all parentheses on the same level. This means
;;; an expression like (((3))) does not have three levels of nesting, but only
;;; one. All the parentheses and the integer literal are on the same level.
;;; This makes it impossible to apply alternating highlights.
;;;
;;; For some of the patterns it is possible to make a best effort by specifying
;;; multiple mutually exclusive variants.
(list
"[" @delimiter
"]" @delimiter @sentinel) @container
(dictionnary ;; this is no typo, "dictionary" is misspelled in the parser
"{" @delimiter
(dictionnary_entry
":" @delimiter)?
"}" @delimiter @sentinel) @container
(call_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(unary_operation
"(" @delimiter
")" @delimiter @sentinel) @container
;;; ---------------------------------------------------------------------------
(binary_operation
left: ("(" @delimiter
")" @delimiter)
right: ("(" @delimiter
")" @delimiter @sentinel)) @container
(binary_operation
left: _ @_left
(#not-eq? @_left "(")
right: ("(" @delimiter
")" @delimiter @sentinel)) @container
(binary_operation
left: ("(" @delimiter
")" @delimiter @sentinel)
right: _ @_right
(#not-eq? @_right "(")) @container
;;; ---------------------------------------------------------------------------
(ternary_expression
condition: ("(" @delimiter
")" @delimiter)
left: ("(" @delimiter
")" @delimiter)
right: ("(" @delimiter
")" @delimiter @sentinel)) @container
(ternary_expression
condition: _ @_condition
(#not-eq? @_condition "(")
left: ("(" @delimiter
")" @delimiter)
right: ("(" @delimiter
")" @delimiter @sentinel)) @container
(ternary_expression
condition: ("(" @delimiter
")" @delimiter)
left: _ @_left
(#not-eq? @_left "(")
right: ("(" @delimiter
")" @delimiter @sentinel)) @container
(ternary_expression
condition: ("(" @delimiter
")" @delimiter)
left: ("(" @delimiter
")" @delimiter @sentinel)
right: _ @_right
(#not-eq? @_right "(")) @container
(ternary_expression
condition: ("(" @delimiter
")" @delimiter @sentinel)
left: _ @_left
(#not-eq? @_left "(")
right: _ @_right
(#not-eq? @_right "(")) @container
(ternary_expression
condition: _ @_condition
(#not-eq? @_condition "(")
left: ("(" @delimiter
")" @delimiter @sentinel)
right: _ @_right
(#not-eq? @_right "(")) @container
(ternary_expression
condition: _ @_condition
(#not-eq? @_condition "(")
left: _ @_left
(#not-eq? @_left "(")
right: ("(" @delimiter
")" @delimiter @sentinel)) @container
rainbow-delimiters.nvim-v0.10.0/queries/vimdoc/ 0000775 0000000 0000000 00000000000 15066556776 0021513 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/vimdoc/rainbow-delimiters.scm 0000664 0000000 0000000 00000000322 15066556776 0026014 0 ustar 00root root 0000000 0000000 ;;; Intentionally empty. Vim help files can have other languages embedded and
;;; we want to let those grammars handle the highlighting. This query only
;;; exists to satisfy the requirements of this plugin.
rainbow-delimiters.nvim-v0.10.0/queries/vue/ 0000775 0000000 0000000 00000000000 15066556776 0021031 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/vue/rainbow-delimiters.scm 0000664 0000000 0000000 00000002040 15066556776 0025331 0 ustar 00root root 0000000 0000000 ;;; A Vue file is made up of top-level tags which contain code written in other
;;; languages
(element
(start_tag
"<" @delimiter
(tag_name) @delimiter
">" @delimiter)
(end_tag
"" @delimiter
(tag_name) @delimiter
">" @delimiter @sentinel)) @container
(element
(self_closing_tag
"<" @delimiter
(tag_name) @delimiter
"/>" @delimiter @sentinel)) @container
(template_element
(start_tag
"<" @delimiter
(tag_name) @delimiter
">" @delimiter)
(end_tag
"" @delimiter
(tag_name) @delimiter
">" @delimiter @sentinel)) @container
(script_element
(start_tag
"<" @delimiter
(tag_name) @delimiter
">" @delimiter)
(end_tag
"" @delimiter
(tag_name) @delimiter
">" @delimiter @sentinel)) @container
(style_element
(start_tag
"<" @delimiter
(tag_name) @delimiter
">" @delimiter)
(end_tag
"" @delimiter
(tag_name) @delimiter
">" @delimiter @sentinel)) @container
(interpolation
"{{" @delimiter
"}}" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/wgsl/ 0000775 0000000 0000000 00000000000 15066556776 0021206 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/wgsl/rainbow-delimiters.scm 0000664 0000000 0000000 00000001627 15066556776 0025520 0 ustar 00root root 0000000 0000000 (argument_list_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(attribute
"(" @delimiter
")" @delimiter @sentinel) @container
(compound_statement
"{" @delimiter
"}" @delimiter @sentinel) @container
(function_declaration
"(" @delimiter
")" @delimiter @sentinel) @container
(for_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(loop_statement
"{" @delimiter
"}" @delimiter @sentinel) @container
(parenthesized_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(postfix_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
(struct_declaration
"{" @delimiter
"}" @delimiter @sentinel) @container
(subscript_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
(type_declaration
"<" @delimiter
">" @delimiter @sentinel) @container
(variable_qualifier
"<" @delimiter
">" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/xml/ 0000775 0000000 0000000 00000000000 15066556776 0021032 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/xml/rainbow-delimiters.scm 0000664 0000000 0000000 00000000427 15066556776 0025341 0 ustar 00root root 0000000 0000000 (element
(STag
"<" @delimiter
(Name) @delimiter
">" @delimiter)
(ETag
"" @delimiter
(Name) @delimiter
">" @delimiter @sentinel))@container
(element
(EmptyElemTag
"<" @delimiter
(Name) @delimiter
"/>" @delimiter @sentinel)) @container
rainbow-delimiters.nvim-v0.10.0/queries/yaml/ 0000775 0000000 0000000 00000000000 15066556776 0021174 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/yaml/rainbow-delimiters.scm 0000664 0000000 0000000 00000000216 15066556776 0025477 0 ustar 00root root 0000000 0000000 (flow_mapping
"{" @delimiter
"}" @delimiter @sentinel) @container
(flow_sequence
"[" @delimiter
"]" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/yuck/ 0000775 0000000 0000000 00000000000 15066556776 0021205 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/yuck/rainbow-delimiters.scm 0000664 0000000 0000000 00000000523 15066556776 0025511 0 ustar 00root root 0000000 0000000 (list
"(" @delimiter
")" @delimiter @sentinel) @container
(loop_widget
"(" @delimiter
")" @delimiter @sentinel) @container
(array
"[" @delimiter
"]" @delimiter @sentinel) @container
(string_interpolation
"${" @delimiter
"}" @delimiter @sentinel) @container
(expr
"{" @delimiter
"}" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/queries/zig/ 0000775 0000000 0000000 00000000000 15066556776 0021023 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/queries/zig/rainbow-delimiters.scm 0000664 0000000 0000000 00000005752 15066556776 0025340 0 ustar 00root root 0000000 0000000 (parameters
"(" @delimiter
")" @delimiter @sentinel) @container
(arguments
"(" @delimiter
")" @delimiter @sentinel) @container
(if_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(if_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(if_type_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(for_statement
"(" @delimiter
")" @delimiter @sentinel) @container
(for_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(while_statement
"(" @delimiter
.
condition: (_)
.
")" @delimiter @sentinel ;; keep the sentinel for fallback
(
":" @delimiter
"(" @delimiter
")" @delimiter
)?
) @container
(while_expression
"(" @delimiter
.
condition: (_)
.
")" @delimiter @sentinel ;; keep the sentinel for fallback
(
":" @delimiter
"(" @delimiter
")" @delimiter
)?
) @container
(link_section
"(" @delimiter
")" @delimiter @sentinel) @container
(calling_convention
"(" @delimiter
")" @delimiter @sentinel) @container
(asm_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(asm_input_item
"[" @delimiter
"]" @delimiter
"(" @delimiter
")" @delimiter @sentinel) @container
(asm_output_item
"[" @delimiter
"]" @delimiter
"(" @delimiter
")" @delimiter @sentinel) @container
(switch_expression
"(" @delimiter
")" @delimiter
"{" @delimiter
((switch_case
"=>" @delimiter)
_)+
"}" @delimiter @sentinel) @container
(array_type
"[" @delimiter
"]" @delimiter @sentinel) @container
(slice_type
"[" @delimiter
"]" @delimiter @sentinel) @container
(index_expression
"[" @delimiter
"]" @delimiter @sentinel) @container
(pointer_type
(
"(" @delimiter
")" @delimiter @sentinel ;; keep the sentinel for fallback
)?
(
"[" @delimiter
"]" @delimiter @sentinel ;; keep the sentinel for fallback
)?
) @container
(block
"{" @delimiter
"}" @delimiter @sentinel) @container
(initializer_list
"{" @delimiter
"}" @delimiter @sentinel) @container
(payload
. ;; Without the anchor the @delimiter will be matched three times
"|" @delimiter
"|" @delimiter @sentinel) @container
(call_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(opaque_declaration
"{" @delimiter
"}" @delimiter @sentinel) @container
(struct_declaration
(
"(" @delimiter
")" @delimiter
)?
"{" @delimiter
"}" @delimiter @sentinel) @container
(enum_declaration
(
"(" @delimiter
")" @delimiter
)?
"{" @delimiter
"}" @delimiter @sentinel) @container
(union_declaration
(
"(" @delimiter
")" @delimiter
)?
"{" @delimiter
"}" @delimiter @sentinel) @container
(parenthesized_expression
"(" @delimiter
")" @delimiter @sentinel) @container
(error_set_declaration
"{" @delimiter
"}" @delimiter @sentinel) @container
(byte_alignment
"(" @delimiter
")" @delimiter @sentinel) @container
(address_space
"(" @delimiter
")" @delimiter @sentinel) @container
rainbow-delimiters.nvim-v0.10.0/test/ 0000775 0000000 0000000 00000000000 15066556776 0017534 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/e2e/ 0000775 0000000 0000000 00000000000 15066556776 0020207 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/e2e/attaching.lua 0000664 0000000 0000000 00000004015 15066556776 0022654 0 ustar 00root root 0000000 0000000 local yd = require 'yo-dawg'
describe('Attaching a strategy to a buffer', function()
local nvim
before_each(function()
nvim = yd.start()
nvim:exec_lua([[EnsureTSParser({'lua', 'vim'})]], {})
end)
after_each(function()
yd.stop(nvim)
end)
it('Does not attach a second time if the buffer is already attached', function()
-- Write buffer to a file
local tempfile = nvim:call_function('tempname', {})
nvim:call_function('writefile', {{'print((((("Hello, world!")))))', '-- vim:ft=lua'}, tempfile})
-- Edit the buffer multiple times, this will trigger attachment
for _ = 1, 3 do
nvim:cmd({cmd = 'edit', args = {tempfile}}, {})
nvim:cmd({cmd = 'filetype', args = {'detect'}}, {})
end
assert.remote(nvim).has_rainbow()
end)
it('Performs cleanup after a buffer is deleted', function()
nvim:buf_set_lines(0, 0, -1, true, {'print((((("Hello, world!")))))', '-- vim:ft=lua'})
nvim:cmd({cmd = 'filetype', args = {'detect'}}, {})
assert.remote(nvim).has_rainbow()
-- Delete the buffer
nvim:cmd({cmd = 'bdelete', bang = true}, {})
assert.remote(nvim).not_has_rainbow()
end)
it('Detaches from the buffer and re-attached with the new language', function()
-- Switching the file type preserves the number of attachments, but
-- changes the language
for _, expected in ipairs({'lua', 'vim'}) do
nvim:buf_set_option(0, 'filetype', expected)
assert.remote(nvim).has_rainbow()
end
end)
it('Unloads a buffer without raising errors', function()
-- Create two windows with different buffers, but with same file type
nvim:buf_set_option(0, 'filetype', 'lua')
nvim:buf_set_lines(0, 0, -1, true, {'print(((("Hello world"))))', '-- vim:ft=lua'})
nvim:cmd({cmd = 'new'}, {})
nvim:buf_set_option(0, 'filetype', 'lua')
nvim:buf_set_lines(0, 0, -1, true, {'print(((("Goodbye world"))))', '-- vim:ft=lua'})
local secondbuf = nvim:call_function('bufnr', {})
nvim:cmd({cmd = 'bdelete', args = {secondbuf}, bang = true}, {})
local errmsg = nvim:get_vvar('errmsg')
assert.is.equal('', errmsg)
end)
end)
rainbow-delimiters.nvim-v0.10.0/test/e2e/buffer-manipulation.lua 0000664 0000000 0000000 00000007536 15066556776 0024674 0 ustar 00root root 0000000 0000000 local yd = require 'yo-dawg'
---Markdown document with Lua code inside a code block
local markdown_with_injected_lua = [[This is some Markdown
```lua
print(((('Hello world'))))
```
This is more markdown.]]
---Markdown document with Lua code outside a code block
local markdown_without_injected_lua = [[This is some Markdown
```lua
```
print(((('Hello world'))))
This is more markdown.]]
describe('Buffer Manipulation', function()
local nvim
before_each(function()
nvim = yd.start()
nvim:exec_lua('EnsureTSParser(...)', {{'lua', 'vim', 'markdown'}})
nvim:set_var('rainbow_delimiters', {
strategy = {
[''] = 'rainbow-delimiters.strategy.global'
}
})
end)
after_each(function()
yd.stop(nvim)
end)
it('Clears extmarks when moving line out of injected language', function()
nvim:buf_set_lines(0, 0, -2, true, vim.fn.split(markdown_with_injected_lua, '\n'))
nvim:buf_set_option(0, 'filetype', 'markdown')
nvim:exec_lua('vim.treesitter.start()', {})
assert.remote(nvim).for_language('lua').at_position(3, 5).has_extmarks()
-- Move Lua line out of code block
nvim:cmd({cmd = 'move', range = {4}, args = {5}}, {})
assert.remote(nvim).has_content(markdown_without_injected_lua)
assert.remote(nvim).for_language('lua').at_position(4, 5).Not.has_extmarks()
end)
it('Adds extmarks when moving line into injected langauge', function()
nvim:buf_set_lines(0, 0, -2, true, vim.fn.split(markdown_without_injected_lua, '\n'))
nvim:buf_set_option(0, 'filetype', 'markdown')
nvim:exec_lua('vim.treesitter.start()', {})
assert.remote(nvim).for_language('lua').at_position(4, 5).Not.has_extmarks()
-- Move Lua line out of code block
nvim:cmd({cmd = 'move', range = {5}, args = {3}}, {})
assert.remote(nvim).has_content(markdown_with_injected_lua)
assert.remote(nvim).for_language('lua').at_position(3, 5).has_extmarks()
end)
it('Preserves extmarks upon multi-line substitution', function()
-- See also https://github.com/neovim/neovim/issues/31067
pending('Bug reported: https://github.com/neovim/neovim/issues/31067')
nvim:buf_set_lines(0, 0, -2, true, {'print {', '\t{', '\t},', '\t{', '\t},', '}'})
nvim:buf_set_option(0, 'filetype', 'lua')
nvim:exec_lua('vim.treesitter.start()', {})
assert.remote(nvim).for_language('lua').at_position(1, 1).has_extmarks('RainbowDelimiterYellow')
assert.remote(nvim).for_language('lua').at_position(3, 1).has_extmarks('RainbowDelimiterYellow')
nvim:command [[%s/\v\{\n\s+/{]] -- Remove line break after opening brace
assert.remote(nvim).has_content
[[print {{},
{},
}]]
assert.remote(nvim).for_language('lua').at_position(0, 7).has_extmarks('RainbowDelimiterYellow')
assert.remote(nvim).for_language('lua').at_position(3, 1).has_extmarks('RainbowDelimiterYellow')
end)
describe('Pasting lines containing delimiters', function()
local content = [[print {
{a = 1, b = 2},
}]]
before_each(function()
nvim:buf_set_lines(0, 0, -2, true, vim.fn.split(content, '\n'))
nvim:buf_set_option(0, 'filetype', 'lua')
nvim:exec_lua('vim.treesitter.start()', {})
assert.remote(nvim).for_language('lua').at_position(1, 1).has_extmarks('RainbowDelimiterYellow')
assert.remote(nvim).for_language('lua').at_position(1, 14).has_extmarks('RainbowDelimiterYellow')
end)
it('Properly highlights after inserting one line', function()
nvim:feedkeys('ggjyyp', 'n', false)
assert.remote(nvim).for_language('lua').at_position(1, 1).has_extmarks('RainbowDelimiterYellow')
assert.remote(nvim).for_language('lua').at_position(1, 14).has_extmarks('RainbowDelimiterYellow')
end)
it('Properly highlights after inserting two lines', function()
nvim:feedkeys('ggjyy2p', 'n', false)
assert.remote(nvim).for_language('lua').at_position(1, 1).has_extmarks('RainbowDelimiterYellow')
assert.remote(nvim).for_language('lua').at_position(1, 14).has_extmarks('RainbowDelimiterYellow')
end)
end)
end)
rainbow-delimiters.nvim-v0.10.0/test/e2e/config.lua 0000664 0000000 0000000 00000014405 15066556776 0022163 0 ustar 00root root 0000000 0000000 local yd = require 'yo-dawg'
describe('User settings are respected', function()
local nvim
before_each(function()
nvim = yd.start()
end)
after_each(function()
yd.stop(nvim)
end)
describe('Strategy settings', function()
it('Resolves a string to a strategy table', function()
nvim:set_var('rainbow_delimiters', {strategy = {lua = 'rainbow-delimiters.strategy.local'}})
assert.remote(nvim).for_language('lua').has_strategy('rainbow-delimiters.strategy.local')
end)
it('Resolves a string to a strategy in Vim script', function()
nvim:exec2(
"let g:rainbow_delimiters = {'strategy': {'lua': 'rainbow-delimiters.strategy.local'}}",
{}
)
assert.remote(nvim).for_language('lua').has_strategy('rainbow-delimiters.strategy.local')
end)
it('Accepts a strategy object', function()
nvim:exec_lua(
[[
vim.g.rainbow_delimiters = {
strategy = {
lua = require('rainbow-delimiters.strategy.local')
}
}
]],
{}
)
assert.remote(nvim).for_language('lua').has_strategy('rainbow-delimiters.strategy.local')
end)
it('Applies the default strategy to all languages xx', function()
nvim:set_var('rainbow_delimiters', {strategy = {[''] = 'rainbow-delimiters.strategy.local'}})
assert.remote(nvim).for_language('lua').has_strategy('rainbow-delimiters.strategy.local')
assert.remote(nvim).for_language('vim').has_strategy('rainbow-delimiters.strategy.local')
end)
it('Overrides the strategy for individual languages', function()
nvim:set_var('rainbow_delimiters', {strategy = {lua = 'rainbow-delimiters.strategy.local'}})
assert.remote(nvim).for_language('lua').has_strategy('rainbow-delimiters.strategy.local')
assert.remote(nvim).for_language('vim').has_strategy('rainbow-delimiters.strategy.global')
end)
describe('Strategies can be thunks', function()
before_each(function()
-- Set a thunk as the strategy
nvim:exec_lua('EnsureTSParser(...)', {{'lua', 'vim'}})
nvim:exec_lua([[
vim.g.rainbow_delimiters = {
strategy = {
[""] = function() return 'rainbow-delimiters.strategy.global' end,
vim = function() return nil end
}
}]], {})
end)
it('Uses the strategy returned by the thunk', function()
nvim:buf_set_lines(0, 0, -1, true, {'print "Hello world"', '-- vim:ft=lua'})
nvim:command('filetype detect')
assert.remote(nvim).has_rainbow()
end)
it('Does nothing if the thunk returns nil', function()
nvim:buf_set_lines(0, 0, -1, true, {'echo "Hello world"', '" vim:ft=vim'})
nvim:command('filetype detect')
assert.remote(nvim).Not.has_rainbow()
end)
end)
end)
it('Overrides the query for an individual language', function()
-- Override the query for one language only
nvim:set_var('rainbow_delimiters', {query = {c = 'other-query'}})
local c_query = nvim:exec_lua('return require("rainbow-delimiters.config").query.c', {})
local lua_query = nvim:exec_lua('return require("rainbow-delimiters.config").query.lua', {})
assert.is.equal('other-query', c_query)
assert.is.equal('rainbow-delimiters', lua_query)
end)
it('Falls back to default highlighting if the highlight table is empty', function()
---The expected highlight groups in order
local hlgroups = {
'RainbowDelimiterRed',
'RainbowDelimiterYellow',
'RainbowDelimiterBlue',
'RainbowDelimiterOrange',
'RainbowDelimiterGreen',
'RainbowDelimiterViolet',
'RainbowDelimiterCyan',
}
-- Set highlight to empty list
nvim:set_var('rainbow_delimiters', {highlight = {}})
for i, expected in ipairs(hlgroups) do
local given = nvim:exec_lua('return require("rainbow-delimiters.config").highlight[...]', {i})
assert.is.equal(expected, given, string.format('Wrong highlight group at index %d', i))
end
end)
describe('White- and blacklist individual languages', function()
it('Has all languages enabled without configuration', function()
nvim:exec_lua('rbc = require("rainbow-delimiters.config")', {})
local lua_enabled = nvim:exec_lua('return rbc.enabled_for("lua")', {})
local vim_enabled = nvim:exec_lua('return rbc.enabled_for("vim")', {})
assert.is_true(lua_enabled, 'Lua should be enabled')
assert.is_true(vim_enabled, 'Vim script should be enabled')
end)
it('Has all languages enabled in blank configuration', function()
nvim:set_var('rainbow_delimiters', {})
nvim:exec_lua('rbc = require("rainbow-delimiters.config")', {})
local lua_enabled = nvim:exec_lua('return rbc.enabled_for("lua")', {})
local vim_enabled = nvim:exec_lua('return rbc.enabled_for("vim")', {})
assert.is_true(lua_enabled, 'Lua should be enabled')
assert.is_true(vim_enabled, 'Vim script should be enabled')
end)
it('Can whitelist individual file types by adding them to our configuration', function()
nvim:set_var('rainbow_delimiters', {whitelist = {'lua'}})
nvim:exec_lua('rbc = require("rainbow-delimiters.config")', {})
local lua_enabled = nvim:exec_lua('return rbc.enabled_for("lua")', {})
local vim_enabled = nvim:exec_lua('return rbc.enabled_for("vim")', {})
assert.is_true( lua_enabled, 'Lua should be enabled')
assert.is_false(vim_enabled, 'Vim script should be disabled')
end)
it('Can blacklist individual file types by adding them to our configuration', function()
nvim:set_var('rainbow_delimiters', {blacklist = {'vim'}})
nvim:exec_lua('rbc = require("rainbow-delimiters.config")', {})
local lua_enabled = nvim:exec_lua('return rbc.enabled_for("lua")', {})
local vim_enabled = nvim:exec_lua('return rbc.enabled_for("vim")', {})
assert.is_true( lua_enabled, 'Lua should be enabled')
assert.is_false(vim_enabled, 'Vim script should be disabled')
end)
end)
describe('The setup function sets configuration indirectly', function()
it('Can call the setup function', function()
nvim:exec_lua([[
require('rainbow-delimiters.setup').setup {
query = {
lua = 'rainbow-blocks'
}
}
]], {})
local lua_query = nvim:eval('g:rainbow_delimiters.query.lua')
assert.is.equal('rainbow-blocks', lua_query)
end)
it('Can call the table itset', function()
nvim:exec_lua([[
require('rainbow-delimiters.setup') {
query = {
lua = 'rainbow-blocks'
}
}
]], {})
local lua_query = nvim:eval('g:rainbow_delimiters.query.lua')
assert.is.equal('rainbow-blocks', lua_query)
end)
end)
end)
rainbow-delimiters.nvim-v0.10.0/test/e2e/public-api.lua 0000664 0000000 0000000 00000011747 15066556776 0022751 0 ustar 00root root 0000000 0000000 local yd = require 'yo-dawg'
describe('The Rainbow Delimiters public API', function()
local nvim
before_each(function()
nvim = yd.start()
nvim:exec_lua([[EnsureTSParser({'markdown', 'lua', 'vim'})]], {})
nvim:exec_lua([[rb = require 'rainbow-delimiters' ]], {})
nvim:set_var('rainbow_delimiters', {
strategy = {
[''] = 'rainbow-delimiters.strategy.global',
}
})
end)
after_each(function()
yd.stop(nvim)
end)
describe('Whether RB is enabled for a buffer at startup', function()
it('Is disabled for a buffer without file type', function()
assert.remote(nvim).not_has_rainbow()
end)
it('Is enabled for a supported language', function()
nvim:buf_set_option(0, 'filetype', 'lua')
assert.remote(nvim).has_rainbow()
end)
describe('Blacklist', function()
before_each(function()
nvim:command('let g:rainbow_delimiters.blacklist = ["markdown"]')
end)
it('Is enabled for a not blacklisted language', function()
nvim:buf_set_option(0, 'filetype', 'lua')
assert.remote(nvim).has_rainbow()
end)
it('Is disabled for a blacklisted language', function()
nvim:buf_set_option(0, 'filetype', 'markdown')
assert.remote(nvim).not_has_rainbow()
end)
it('Is disabled for a blacklisted language with injected whitelisted language', function()
nvim:buf_set_lines(0, 0, -1, true, {
'This is Markdown',
'',
'```lua',
'print(((("This is Lua"))))',
'```',
'',
'More Markdown',
})
nvim:buf_set_option(0, 'filetype', 'markdown')
assert.remote(nvim).not_has_rainbow()
end)
end)
describe('Whitelist', function()
before_each(function()
nvim:command('let g:rainbow_delimiters.whitelist = ["lua"]')
end)
it('Is disabled for a not whitelisted language', function()
nvim:buf_set_option(0, 'filetype', 'markdown')
assert.remote(nvim).not_has_rainbow()
end)
it('Is enabled for a whitelisted language', function()
nvim:buf_set_option(0, 'filetype', 'lua')
assert.remote(nvim).has_rainbow()
end)
it('Is enabled for whitelisted language with other language injected', function()
nvim:buf_set_lines(0, 0, -1, true, {
'print "This is Lua"',
'vim.cmd [[echo "This is Vim"]]',
})
nvim:buf_set_option(0, 'filetype', 'lua')
assert.remote(nvim).has_rainbow()
end)
it('Is disabled for not whitelisted language with injected whitelisted language', function()
nvim:buf_set_lines(0, 0, -1, true, {
'This is Markdown',
'',
'```lua',
'print(((("This is Lua"))))',
'```',
'',
'More Markdown',
})
nvim:buf_set_option(0, 'filetype', 'markdown')
assert.remote(nvim).not_has_rainbow()
end)
end)
end)
describe('Manual toggling', function()
it('Can be disabled for a buffer', function()
nvim:buf_set_option(0, 'filetype', 'lua')
nvim:exec_lua('rb.disable(0)', {})
assert.remote(nvim).not_has_rainbow()
end)
it('Can be turned back on', function()
nvim:buf_set_option(0, 'filetype', 'lua')
nvim:exec_lua('rb.disable(0)', {})
nvim:exec_lua('rb.enable(0)', {})
assert.remote(nvim).has_rainbow()
end)
it('Can be toggled off', function()
nvim:buf_set_option(0, 'filetype', 'lua')
nvim:exec_lua('rb.toggle(0)', {})
assert.remote(nvim).not_has_rainbow()
end)
it('Can be toggled on', function()
nvim:buf_set_option(0, 'filetype', 'lua')
nvim:exec_lua('rb.toggle(0)', {})
nvim:exec_lua('rb.toggle(0)', {})
assert.remote(nvim).has_rainbow()
end)
it('Gets disabled idempotently', function()
nvim:buf_set_option(0, 'filetype', 'lua')
nvim:exec_lua('rb.disable(0)', {})
nvim:exec_lua('rb.disable(0)', {})
assert.remote(nvim).not_has_rainbow()
end)
it('Gets enabled idempotently', function()
nvim:buf_set_option(0, 'filetype', 'lua')
nvim:exec_lua('rb.disable(0)', {})
nvim:exec_lua('rb.enable(0)', {})
nvim:exec_lua('rb.enable(0)', {})
assert.remote(nvim).has_rainbow()
end)
describe('Blacklist', function()
before_each(function()
nvim:command('let g:rainbow_delimiters.blacklist = ["markdown"]')
end)
it('Can be enabled for a blacklisted language', function()
nvim:buf_set_option(0, 'filetype', 'markdown')
nvim:exec_lua('rb.enable(0)', {})
assert.remote(nvim).has_rainbow()
end)
it('Can be toggled for a blacklisted language', function()
nvim:buf_set_option(0, 'filetype', 'markdown')
nvim:exec_lua('rb.toggle(0)', {})
assert.remote(nvim).has_rainbow()
end)
end)
describe('Whitelist', function()
before_each(function()
nvim:command('let g:rainbow_delimiters.whitelist = ["lua"]')
end)
it('Can be disabled for a whitelisted language', function()
nvim:buf_set_option(0, 'filetype', 'lua')
nvim:exec_lua('rb.disable(0)', {})
assert.remote(nvim).not_has_rainbow()
end)
it('Can be toggled for a whitelisted language', function()
nvim:buf_set_option(0, 'filetype', 'lua')
nvim:exec_lua('rb.toggle(0)', {})
assert.remote(nvim).not_has_rainbow()
end)
end)
end)
end)
rainbow-delimiters.nvim-v0.10.0/test/e2e/scrolling.lua 0000664 0000000 0000000 00000002173 15066556776 0022711 0 ustar 00root root 0000000 0000000 local yd = require 'yo-dawg'
describe('Scrolling a buffer in a window', function()
local nvim
before_each(function ()
-- Intentionally a small window so we don't have to scroll much
nvim = yd.start {
width = 40,
height = 30,
}
nvim:set_var('rainbow_delimiters', {
strategy = {
[''] = 'rainbow-delimiters.strategy.global'
}
})
end)
after_each(function()
yd.stop(nvim)
end)
describe('with a language that has macros', function()
before_each(function ()
nvim:exec_lua('EnsureTSParser(...)', {'c'})
end)
it('preserves highlighting in C', function()
local text = [[
#define U 10
int main() {
int u=U;
// blanks
]] .. string.rep('\n', 40) .. [[
return 0;
}
]]
nvim:set_option_value('filetype', 'c', {scope='local'})
nvim:exec_lua('vim.treesitter.start()', {})
nvim:buf_set_lines(0, -2, -1, true, vim.fn.split(text, '\n'))
assert.remote(nvim).for_language('c').at_position(1, 8).has_extmarks()
-- Scroll down and back up
nvim:feedkeys('G', 'nt', false)
nvim:feedkeys('gg', 'nt', false)
assert.remote(nvim).for_language('c').at_position(1, 8).has_extmarks()
end)
end)
end)
rainbow-delimiters.nvim-v0.10.0/test/e2e/selective-activation.lua 0000664 0000000 0000000 00000005310 15066556776 0025033 0 ustar 00root root 0000000 0000000 local yd = require 'yo-dawg'
describe('We can disable rainbow delimiters for certain languages', function()
local nvim
before_each(function()
nvim = yd.start()
end)
after_each(function()
yd.stop(nvim)
end)
describe('For the given language', function()
before_each(function()
nvim:buf_set_lines(0, 0, -1, true, {'print "Hello world"', '-- vim:ft=lua'})
end)
it('Does not run when blacklisted', function()
nvim:set_var('rainbow_delimiters', {
blacklist = {'lua'}}
)
nvim:command('filetype detect')
assert.remote(nvim).not_has_rainbow()
end)
it('Runs when whitelisted', function()
nvim:set_var('rainbow_delimiters', {
whitelist = {'lua'}}
)
nvim:command('filetype detect')
assert.remote(nvim).has_rainbow()
end)
end)
describe('For another language', function()
before_each(function()
nvim:buf_set_lines(0, 0, -1, true, {'echo "Hello world"', '" vim:ft=vim'})
end)
it('Runs when not blacklisted', function()
nvim:set_var('rainbow_delimiters', {
blacklist = {'lua'},
})
nvim:command('filetype detect')
assert.remote(nvim).has_rainbow()
end)
it('Does not run when not whitelisted', function()
nvim:set_var('rainbow_delimiters', {
whitelist = {'lua'},
})
nvim:command('filetype detect')
assert.remote(nvim).not_has_rainbow()
end)
end)
describe('For dynamic condition', function()
before_each(function()
nvim:buf_set_lines(0, 0, -1, true, {'print "Hello world"', '-- vim:ft=lua'})
nvim:exec_lua('always = function() return true end', {})
nvim:exec_lua('never = function() return false end', {})
end)
it('Runs when no condition is set', function()
nvim:set_var('rainbow_delimiters', {
condition = nil,
})
nvim:command('filetype detect')
assert.remote(nvim).has_rainbow()
end)
it('Runs when condition is met', function()
nvim:exec_lua('vim.g.rainbow_delimiters = {condition = always}', {})
nvim:command('filetype detect')
assert.remote(nvim).has_rainbow()
end)
it('Does not run when condition is unmet', function()
nvim:exec_lua('vim.g.rainbow_delimiters = {condition = never}', {})
nvim:command('filetype detect')
assert.remote(nvim).not_has_rainbow()
end)
it('Is ignored for blacklisted buffers', function()
nvim:exec_lua([[
vim.g.rainbow_delimiters = {
blacklist = {'lua'},
condition = always,
}
]], {})
nvim:command('filetype detect')
assert.remote(nvim).not_has_rainbow()
end)
it('Is takes prededence over the whitelist', function()
nvim:exec_lua([[
vim.g.rainbow_delimiters = {
whitelist = {'lua'},
condition = never,
}
]], {})
nvim:command('filetype detect')
assert.remote(nvim).not_has_rainbow()
end)
end)
end)
rainbow-delimiters.nvim-v0.10.0/test/e2e/strategy/ 0000775 0000000 0000000 00000000000 15066556776 0022051 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/e2e/strategy/global.lua 0000664 0000000 0000000 00000007207 15066556776 0024022 0 ustar 00root root 0000000 0000000 local yd = require 'yo-dawg'
---Convenience wrapper around `vim.api.nvim_replace_termcodes` which turns a
---string of key sequences with special keys into a regular Lua string.
---@param keys string
---@return string s A regular Lua string
local function rtc(keys)
return vim.api.nvim_replace_termcodes(keys, true, false, true)
end
describe('The global strategy', function()
local nvim
before_each(function()
nvim = yd.start()
nvim:exec_lua('EnsureTSParser(...)', {{'lua', 'vim'}})
nvim:set_var('rainbow_delimiters', {query = {}})
end)
after_each(function()
yd.stop(nvim)
end)
it('Does not reactivate when making changes', function()
nvim:buf_set_lines(0, 0, -1, true, {'print({{{{{}}}}})', '-- vim:ft=lua'})
nvim:buf_set_option(0, 'filetype', 'lua')
assert.remote(nvim).for_language('lua').at_position(0, 5).has_extmarks()
nvim:call_function('rainbow_delimiters#disable', {0})
assert.remote(nvim).for_language('lua').at_position(0, 5).Not.has_extmarks()
-- Add a new pair of curly braces
-- (jump to first column, find the first closing brace, insert new pair)
nvim:feedkeys(rtc'gg0f}i{}', 'n', false)
assert.remote(nvim).has_content('print({{{{{{}}}}}})')
assert.remote(nvim).for_language('lua').at_position(0, 5).Not.has_extmarks()
assert.remote(nvim).Not.has_rainbow()
end)
it('Ignores blacklisted injected languages', function()
nvim:exec_lua('vim.g.rainbow_delimiters.blacklist = {...}', {'vim'})
nvim:buf_set_lines(0, 0, -1, true, {
'print {{{{{}}}}}',
'vim.cmd [[',
' echo string(1 + (2 + (3 + 4)))',
']]',
'-- vim:ft=lua'
})
nvim:buf_set_option(0, 'filetype', 'lua')
-- The Lua code is highlighted, the Vim code not
assert.remote(nvim).for_language('lua').at_position(0, 6).has_extmarks()
assert.remote(nvim).for_language('vim').at_position(2, 13).Not.has_extmarks()
end)
it('Ignores non-whitelisted injected languages', function()
nvim:exec_lua('vim.g.rainbow_delimiters.whitelist = {...}', {'lua'})
nvim:buf_set_lines(0, 0, -1, true, {
'print {{{{{}}}}}',
'vim.cmd [[',
' echo string(1 + (2 + (3 + 4)))',
']]',
'-- vim:ft=lua'
})
nvim:buf_set_option(0, 'filetype', 'lua')
-- The Lua code is highlighted, the Vim code not
assert.remote(nvim).for_language('lua').at_position(0, 6).has_extmarks()
assert.remote(nvim).for_language('vim').at_position(2, 13).Not.has_extmarks()
end)
it('Applies highlighting to nested code', function()
-- See also https://github.com/HiPhish/rainbow-delimiters.nvim/pull/92
local content = [[local function foo()
return {
a = print('a'),
}
end
return foo]]
nvim:exec_lua('vim.g.rainbow_delimiters.query.lua = "rainbow-blocks"', {})
nvim:buf_set_lines(0, 0, -1, true, vim.fn.split(content, '\n'))
nvim:buf_set_option(0, 'filetype', 'lua')
-- Insert the line " b = print('b'),"
nvim:win_set_cursor(0, {3, 0})
nvim:feedkeys(rtc"ob = print('b'),", '', false)
assert.remote(nvim).for_language('lua').at_position(2, 11).has_extmarks()
assert.remote(nvim).for_language('lua').at_position(3, 11).has_extmarks()
end)
it('Preserves nested highlighting when entering insert mode', function()
-- See https://github.com/HiPhish/rainbow-delimiters.nvim/pull/121
local content = [[local tmp = {
[1] = { 1 },
[2] = {
a = print(),
},
}]]
nvim:buf_set_lines(0, 0, -1, true, vim.fn.split(content, '\n'))
nvim:buf_set_option(0, 'filetype', 'lua')
-- Make a change inside the parentheses
nvim:win_set_cursor(0, {4, 11})
nvim:feedkeys(rtc'a ', '', false)
local hl_group = require('rainbow-delimiters.config').highlight[3]
assert.remote(nvim).for_language('lua').at_position(3, 11).has_extmarks(hl_group)
end)
end)
rainbow-delimiters.nvim-v0.10.0/test/e2e/strategy/local.lua 0000664 0000000 0000000 00000002066 15066556776 0023652 0 ustar 00root root 0000000 0000000 local yd = require 'yo-dawg'
describe('The local strategy', function()
local nvim
before_each(function()
nvim = yd.start()
nvim:exec_lua('EnsureTSParser(...)', {{'lua', 'vim'}})
end)
after_each(function()
yd.stop(nvim)
end)
it('Does not reactivate when making changes', function()
nvim:buf_set_lines(0, 0, -1, true, {'print({{{{{}}}}})', '-- vim:ft=lua'})
nvim:win_set_cursor(0, {1, 5})
nvim:buf_set_option(0, 'filetype', 'lua')
assert.remote(nvim).for_language('lua').at_position(0, 5).has_extmarks()
nvim:call_function('rainbow_delimiters#disable', {0})
assert.remote(nvim).for_language('lua').at_position(0, 5).Not.has_extmarks()
-- Add a new pair of curly braces
-- (jump to first column, find the first closing brace, insert new pair)
local keys = vim.api.nvim_replace_termcodes('gg0f}i{}', true, false, true)
nvim:feedkeys(keys, 'n', false)
assert.remote(nvim).has_content('print({{{{{{}}}}}})')
assert.remote(nvim).for_language('lua').at_position(0, 5).Not.has_extmarks()
assert.remote(nvim).Not.has_rainbow()
end)
end)
rainbow-delimiters.nvim-v0.10.0/test/e2e/toggle.lua 0000664 0000000 0000000 00000004253 15066556776 0022177 0 ustar 00root root 0000000 0000000 local yd = require 'yo-dawg'
describe('We can use functions to turn rainbow delimiters off and on again.', function()
local nvim
before_each(function()
nvim = yd.start()
nvim:exec_lua('the_strategy = require("rainbow-delimiters.strategy.global")', {})
nvim:exec_lua('EnsureTSParser(...)', {'lua'})
nvim:buf_set_lines(0, 0, -1, true, {'print((((("Hello, world!")))))'})
nvim:buf_set_option(0, 'filetype', 'lua')
end)
after_each(function()
yd.stop(nvim)
end)
it('Does highlighting initially', function()
assert.remote(nvim).for_language('lua').at_position(0, 5).has_extmarks()
end)
it('Disables rainbow delimiters', function()
nvim:call_function('rainbow_delimiters#disable', {0})
assert.remote(nvim).for_language('lua').at_position(0, 5).Not.has_extmarks()
end)
it('Remains disabled when disabling twice', function()
nvim:call_function('rainbow_delimiters#disable', {0})
nvim:call_function('rainbow_delimiters#disable', {0})
assert.remote(nvim).for_language('lua').at_position(0, 5).Not.has_extmarks()
end)
it('Turns rainbow delimiters back on', function()
nvim:call_function('rainbow_delimiters#disable', {0})
nvim:call_function('rainbow_delimiters#enable', {0})
assert.remote(nvim).for_language('lua').at_position(0, 5).has_extmarks()
end)
it('Remains enabled when enabling twice', function()
nvim:call_function('rainbow_delimiters#disable', {0})
nvim:call_function('rainbow_delimiters#enable', {0})
nvim:call_function('rainbow_delimiters#enable', {0})
assert.remote(nvim).for_language('lua').at_position(0, 5).has_extmarks()
end)
it('Can be disabled after being enabled', function()
nvim:call_function('rainbow_delimiters#disable', {0})
nvim:call_function('rainbow_delimiters#enable', {0})
nvim:call_function('rainbow_delimiters#disable', {0})
assert.remote(nvim).for_language('lua').at_position(0, 5).Not.has_extmarks()
end)
it('Can be enabled after being disabled twice', function()
nvim:call_function('rainbow_delimiters#disable', {0})
nvim:call_function('rainbow_delimiters#disable', {0})
nvim:call_function('rainbow_delimiters#enable', {0})
assert.remote(nvim).for_language('lua').at_position(0, 5).has_extmarks()
end)
end)
rainbow-delimiters.nvim-v0.10.0/test/highlight/ 0000775 0000000 0000000 00000000000 15066556776 0021503 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/busted.lua 0000664 0000000 0000000 00000002611 15066556776 0023474 0 ustar 00root root 0000000 0000000 ---A dynamic test file, meaning it generates many different tests at runtime.
local yd = require 'yo-dawg'
local lib = require 'rainbow-delimiters._test.highlight'
local function verify(language, sample, query)
local lazy_spec, err = loadfile(('test/highlight/spec/%s/%s/%s.lua'):format(language, query, sample))
if not lazy_spec then
error(err)
end
local spec = lazy_spec()
local nvim = yd.start()
local success, results = pcall(lib.fetch_delimiters, nvim, language, sample, query)
yd.stop(nvim)
if not success then
error(results)
end
for lang, extmarks in pairs(spec) do
local result = results[lang]
assert.are_equal(#extmarks, #result, string.format('Length discrepancy in %s', lang))
for i, expected in ipairs(extmarks) do
local given = result[i]
for key, value in pairs(expected) do
local error_msg = ('Discrepancy at position %d, key %s'):format(i, key)
assert.are_equal(value, given[key], error_msg)
end
end
end
return true
end
for _, lang in ipairs(lib.list_languages()) do
describe(('Highlights for language #%s'):format(lang), function()
local queries = lib.list_queries(lang)
for _, query in ipairs(queries) do
describe(('for query #%s'):format(query), function()
for _, sample in ipairs(lib.list_samples(lang)) do
it(('for sample file %s'):format(sample), function()
verify(lang, sample, query)
end)
end
end)
end
end)
end
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/ 0000775 0000000 0000000 00000000000 15066556776 0023147 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/astro/ 0000775 0000000 0000000 00000000000 15066556776 0024277 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/astro/regular.astro 0000664 0000000 0000000 00000001454 15066556776 0027016 0 ustar 00root root 0000000 0000000 ---
// component import
import MainLayout from "../../layouts/MainLayout.astro";
import PostCard from "../../components/PostCard.astro";
// utils imports
import { formatBlogPosts } from "../../js/utils";
const allPosts = await Astro.glob("./*.md");
const formattedPosts = formatBlogPosts(allPosts, {});
---
New Blog Posts
{
formattedPosts.map((post) => (
))
}
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/awk/ 0000775 0000000 0000000 00000000000 15066556776 0023731 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/awk/regular.awk 0000664 0000000 0000000 00000001070 15066556776 0026074 0 ustar 00root root 0000000 0000000 BEGIN {
print "Hello world"
}
/(foo | (bar | baz))/ {
print "One of foo, bar or baz"
print (1 + (2 + (3 + 4)))
print foo[bar[baz[herp[derp]]]]
print foo(bar(baz(herp(derp))))
if (false) {
if (false) {
if (false) {
print "This never happens"
}
}
}
while (false) {
do {
for (i = 1; i < 5; i++) {
print "This never happens"
}
for (var in array) {
print "This never happens"
}
} while (false)
}
switch (expr) {
case 1:
print "One"
break
case 2:
print "Two"
break
default:
print "Something else"
}
}
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/bash/ 0000775 0000000 0000000 00000000000 15066556776 0024064 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/bash/regular.sh 0000775 0000000 0000000 00000000657 15066556776 0026074 0 ustar 00root root 0000000 0000000 #!/bin/bash
# Command substitution
echo $(basedir $(pwd))
# Variable expansion
echo ${FOO:-${BAR:-${BAZ}}}
# Test expression (using the `test` command)
if [ -d "herp/derp/" ]; then
echo "Yay"
fi
# Test expression (bashism)
if [[ -d "herp/derp/" ]]; then
echo "Yay"
fi
# Sub-shells
(true; false; (true; true; (false; true)))
person() {
array=(
[Alice]="$((2 ^ 10))"
[Bob]=2048
)
echo "${array[$1]}"
}
person "Alice"
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/c/ 0000775 0000000 0000000 00000000000 15066556776 0023371 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/c/regular.c 0000664 0000000 0000000 00000002527 15066556776 0025204 0 ustar 00root root 0000000 0000000 #include
#define PI 3.14
/* These aren't highlight correctly. A problem with the parser? */
#define TESTMACRO (-1)
#define min(X,Y) ((X) < (Y) ? (X) : (Y))
/* Declaration with parentheses, a function pointer */
static void (*callback)(int);
int c_init() { return 1; }
/* Macro type specifier */
#define Map int Foo
static Map(char *c_str) {return 4;}
typedef enum {
E1,
E2,
E3
// comment
} Myenum;
/* A function declaration */
int add(int, int);
struct Point2D {
int x;
int y;
};
/* Compound literal expression */
struct Point2D v = (struct Point2D){ 0, 0 };
/* A function definition */
int add(int x, int y) {
if (!y) {
if (1) {
if (1) {
if (1) {
return x;
}
}
}
}
while (0) {
while (0) {
while (0) {
;
}
}
}
for (int i = 0; i < 0; i++) {
for (int j = 0; j < 0; j++) {
for (int k = 0; k < 0; k++) {
;
}
}
}
return add(x + 1, y - 1);
}
float int2float(int i) {
return (float)i;
}
int main(int argc, char *argv[]) {
int a = 10, b = 5;
int result = add(a, b);
printf("The sum of %d and %d is %d", ((((a)))), b, result);
int indices[] = {0, };
int i = indices[indices[indices[indices[indices[indices[0]]]]]];
#if 0
/* A language server may mark this block semantically as a comment */
printf("The sum of %d and %d is %d", ((((a)))), b, result);
#endif
return 0;
}
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/c_sharp/ 0000775 0000000 0000000 00000000000 15066556776 0024566 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/c_sharp/HelloWorld.cs 0000664 0000000 0000000 00000000236 15066556776 0027171 0 ustar 00root root 0000000 0000000 using System;
// A version of the classic "Hello World" program
class Program {
static void Main() {
Console.WriteLine("Hello, world!");
}
}
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/c_sharp/array.cs 0000664 0000000 0000000 00000000606 15066556776 0026235 0 ustar 00root root 0000000 0000000 using System;
// Arrays and nested arrays
class Program {
static void Main() {
int[,,] array3D = new int[,,] {
{ {1}, {2} },
{ {3}, {4} },
{ {5}, {6} },
{ {7}, {8} },
};
int[] indices = new int[] {0};
int i = array3D[0, 0, 0];
var implicitArray = new[] { "" };
int j = indices[indices[indices[indices[0]]]];
}
}
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/c_sharp/attributes.cs 0000664 0000000 0000000 00000000202 15066556776 0027275 0 ustar 00root root 0000000 0000000 internal class TestAttribute : Attribute { }
[Test()]
public class Person
{
[Test()]
public string? Name { get; set; }
}
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/c_sharp/generics.cs 0000664 0000000 0000000 00000000321 15066556776 0026710 0 ustar 00root root 0000000 0000000 using System;
public class A { }
public struct B { }
public interface C : A> { }
// Nested generic parameters
class Program {
static void Main(List>> l) {
}
}
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/c_sharp/loop.cs 0000664 0000000 0000000 00000000640 15066556776 0026066 0 ustar 00root root 0000000 0000000 using System;
// Nested loops
class Program {
static int[] integers = {0, 1, 2, 3};
static void Main() {
foreach (int i in integers) {
foreach (int i in integers) {
foreach (int i in integers) {
foreach (int i in integers) {
while (false) {
Console.WriteLine("Hello, world!");
}
}
}
}
}
}
}
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/c_sharp/misc.cs 0000664 0000000 0000000 00000001712 15066556776 0026051 0 ustar 00root root 0000000 0000000 public class TestClass
{
public string? Name { get; set; }
public int[][]? MultiDimArray { get; set; }
private string MergeLines(IEnumerable> sections)
{
return string.Join(",", sections.SelectMany(t => t));
}
private void LoopTest()
{
foreach (var item in new string[0]) { }
for (int i = 0; i < 0; i++) { }
while (false) { }
do { } while (false);
}
private void Interpolation()
{
var passTitle = "123";
if (true) {
System.Console.WriteLine($"== {passTitle} ==");
}
}
private void AnonymousObject()
{
var a = new { Test = 123, };
}
private (int a, float b, (int c, float d)) TupleExpressions()
{
return (1, 2, (3, 4));
}
private (int, int) GetTupleValue()
{
return (1, 2);
}
private void TestConsumeTuple()
{
var (a, b) = GetTupleValue();
}
}
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/c_sharp/parens.cs 0000664 0000000 0000000 00000000216 15066556776 0026404 0 ustar 00root root 0000000 0000000 using System;
// Nested parenthesized expressions
class Program {
static void Main() {
var i = (((((1 + 2))) + ((((3))))));
}
}
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/c_sharp/switch.cs 0000664 0000000 0000000 00000002476 15066556776 0026427 0 ustar 00root root 0000000 0000000 public static class SwitchTest
{
private static string GenericFirstCharProcessing(
this string input,
Func firstCharProcessor
) =>
input switch
{
null => throw new ArgumentNullException(nameof(input)),
"" => throw new ArgumentException($"{nameof(input)} cannot be empty", nameof(input)),
_ => firstCharProcessor(input[0].ToString()) + input.Substring(1)
};
private static void T()
{
var defaultInt = default(int);
try { }
catch (Exception e) when (true) { }
finally { }
using (var stream = new Stream()) { }
lock (new string()) { }
var name = "test";
switch (name)
{
case "aab":
{
break;
}
case var o when (o?.Trim().Length ?? 0) == 0:
case "test":
break;
default:
break;
}
int c = (int)b; // explicit conversion from long to int
Type[] t = { typeof(int), };
sizeof(int);
int AllBits = unchecked((int)0xFFFFFFFF);
int AllBits = checked((int)0xFFFFFFFF);
Span span5 = stackalloc[] { 11, 12, 13 };
}
enum Color
{
Red,
Blue,
Green
}
}
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/clojure/ 0000775 0000000 0000000 00000000000 15066556776 0024612 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/clojure/regular.clj 0000664 0000000 0000000 00000000275 15066556776 0026751 0 ustar 00root root 0000000 0000000 (defn fn-name "docs" [a0 a1 & xz]
[
"some _text_ with parens #() #{} {} [] (#())"
'(#(identity ""))
[[[], [[]]], #(:k {}), #{{}, ""}, '((())), `({})]
]
)
(fn-name 1 2 3 4)
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/commonlisp/ 0000775 0000000 0000000 00000000000 15066556776 0025327 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/commonlisp/regular.lisp 0000664 0000000 0000000 00000000474 15066556776 0027666 0 ustar 00root root 0000000 0000000 (defun add (x y)
"A silly way to add two numbers recursively."
(if (zerop y)
x
(add (incf x)
(decf y))))
(defmacro foo (a &rest rest)
`(format t "~A~%" (list ,a ,@rest)))
;;; The LOOP macro has its own node type
(loop repeat 3
do (print "Hello world"))
'(((a . b)))
'((((a b . c))))
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/cpp/ 0000775 0000000 0000000 00000000000 15066556776 0023731 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/cpp/regular.cpp 0000664 0000000 0000000 00000002366 15066556776 0026105 0 ustar 00root root 0000000 0000000 #include
#include
#include
namespace herp {
const int derpiness = 9000;
int get_derpiness() {
return derpiness;
}
}
enum color {
RED,
GREEN,
BLUE,
};
/* A function declaration */
int add(int, int);
// Structure and class definitions
struct Point2D {
public:
int x;
int y;
};
class Point3D {
public:
int x;
int y;
int z;
};
/* A function definition */
int add(int x, int y) {
if (!y) {
if (1) {
if (1) {
if (1) {
return x;
}
}
}
}
while (0) {
while (0) {
while (0) {
;
}
}
}
for (int i = 0; i < 0; i++) {
for (int j = 0; j < 0; j++) {
for (int k = 0; k < 0; k++) {
;
}
}
}
return add(x + 1, y - 1);
}
template T myMax(T x, T y) {
return (x > y) ? x : y;
}
float int2float(int i) {
return (float)i;
}
void do_nothing_with_vector(std::vector>> v) {
return;
}
int main(int argc, char *argv[]) {
auto a {10};
auto b = (5);
auto c = new int[b];
auto result = add(a, b);
printf("The sum of %d and %d is %d", ((((a)))), b, result);
int indices[] = {0, };
auto some_lambda = [] {};
auto i = indices[indices[indices[indices[indices[indices[0]]]]]];
for (auto i : {1, 2, 3}) {
std::cout << i;
}
return 0;
}
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/css/ 0000775 0000000 0000000 00000000000 15066556776 0023737 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/css/regular.css 0000664 0000000 0000000 00000000442 15066556776 0026112 0 ustar 00root root 0000000 0000000 :root {
@media (prefers-color-scheme: dark) {
--color-bg: #3b4252;
--color-fg: #eceff4;
--color-gray: #434c5e;
--color-blue: #81a1c1;
}
}
li:has(input[type="checkbox"]) {
list-style-type: none;
}
.foo {
color: #ffffff;
}
@media (not (color)) {
.foo {
color: #ffffff;
}
}
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/cuda/ 0000775 0000000 0000000 00000000000 15066556776 0024063 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/cuda/regular.cu 0000664 0000000 0000000 00000002440 15066556776 0026055 0 ustar 00root root 0000000 0000000 #include
#include
#include
/* A function declaration */
int add(int, int);
// Structure and class definitions
struct Point2D {
public:
int x;
int y;
};
class Point3D {
public:
int x;
int y;
int z;
};
/* A function definition */
int add(int x, int y) {
if (!y) {
if (1) {
if (1) {
if (1) {
return x;
}
}
}
}
while (0) {
while (0) {
while (0) {
;
}
}
}
for (int i = 0; i < 0; i++) {
for (int j = 0; j < 0; j++) {
for (int k = 0; k < 0; k++) {
;
}
}
}
return add(x + 1, y - 1);
}
template T myMax(T x, T y) {
return (x > y) ? x : y;
}
float int2float(int i) {
return (float)i;
}
void do_nothing_with_vector(std::vector>> v) {
return;
}
__global__ void add_array(int *a, int size) {
int i = threadIdx.x + blockIdx.x * blockDim.x;
if (i < size) {
a[i] += 1;
}
}
void call_device() {
int *dev_a;
cudaMalloc(&dev_a, 10 * sizeof(int));
add_array<<<1, 10, 1>>>(dev_a, 10);
cudaFree(dev_a);
}
int main(int argc, char *argv[]) {
auto a {10};
auto b = (5);
auto result = add(a, b);
printf("The sum of %d and %d is %d", ((((a)))), b, result);
int indices[] = {0, };
auto i = indices[indices[indices[indices[indices[indices[0]]]]]];
return 0;
}
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/cue/ 0000775 0000000 0000000 00000000000 15066556776 0023723 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/cue/regular.cue 0000664 0000000 0000000 00000000604 15066556776 0026062 0 ustar 00root root 0000000 0000000 package main
import (
"strings"
)
HumanA: {
name: "Bob"
description: "A human named \(strings.ToUpper(name))"
}
_#ComplexType: (int | string) | bool
ok: _#ComplexType & 13
numList: [...int] & [ 1, 2, 3, 4 ]
elems: [Name=_]: {name: Name}
elems: {
one: {}
two: {}
}
_env: string | *"dev" @tag(env,type=string)
host: "\(_env).example.com"
environments: (_env): "\(numList[1])"
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/dart/ 0000775 0000000 0000000 00000000000 15066556776 0024101 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/dart/regular.dart 0000664 0000000 0000000 00000002635 15066556776 0026424 0 ustar 00root root 0000000 0000000 import 'package:flutter/material.dart';
class ExampleWidget extends StatelessWidget {
final String title;
final String subtitle;
final String image;
final String id;
const WidgetItem({
super.key,
required this.id,
required this.title,
required this.subtitle,
required this.image,
});
@override
Widget build(BuildContext context) {
final data = {['field'] = ""};
final theme = Theme.of(context);
return GestureDetector(
onTap: () => context.go('/example/$id'),
child: Card(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
const Expanded(
child: Image(
image: AssetImage('assets/image.jpg'),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text(
title,
style: theme.textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
decoration: TextDecoration.underline,
),
),
const SizedBox(height: 8),
Text(subtitle),
],
),
)
],
),
),
),
);
}
}
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/elixir/ 0000775 0000000 0000000 00000000000 15066556776 0024443 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/elixir/regular.exs 0000664 0000000 0000000 00000001464 15066556776 0026632 0 ustar 00root root 0000000 0000000 defmodule Regular do
@moduledoc """
A dummy test module.
"""
def first_plus_five([head | tail]) do
IO.puts "The first value is #{head}"
head + (((1 + (2 + 3))))
end
def first_plus_five({a, b}) do
IO.puts "The first value is #{a}"
a + (((1 + (2 + 3))))
end
def first_plus_five(<>) do
IO.puts "The first value is #{r}"
r + (((1 + (2 + 3))))
end
def first_plus_five(%{head => _}) do
IO.puts "The first value is #{head}"
head + (((1 + (2 + 3))))
end
defp accessLookup(map, x) do
map[map[map[map[x]]]]
end
end
# Keyword list syntactic sugar
IO.puts inspect([a: 1, b: [c: 3, d: [e: 5, f: []]]])
# Map syntactic sugar
IO.puts inspect(%{a => 1, b => %{c => 3, d => %{e => 5, f => %{}}}})
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/elm/ 0000775 0000000 0000000 00000000000 15066556776 0023724 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/elm/Regular.elm 0000664 0000000 0000000 00000002774 15066556776 0026036 0 ustar 00root root 0000000 0000000 module Regular exposing (CustomType(..))
import Browser exposing (UrlRequest(..))
import Url.Parser exposing ((>), (>))
type CustomType a
= CustomType a
type alias NestedRecordOfCustomType a =
{ a : ( Int, List (Maybe ( Int, CustomType a )) )
, b : ( Int, { c : CustomType a } )
, d : { f : { g : String } }
}
nestedTypeExpr : Int -> (Int -> Int) -> (Int -> (Int -> Int))
nestedTypeExpr x y =
\z -> y
nestedListPatternFunction : List (List ( Int, List ( Int, String ) )) -> List ( String, Int )
nestedListPatternFunction list =
List.concatMap (\( _, strings ) -> List.map (\( a, b ) -> ( b, a )) strings) (List.concat list)
unwrapCustomType : { b | c : Int } -> CustomType (CustomType { a : Int }) -> Int
unwrapCustomType { c } (CustomType (CustomType ({ a } as b))) =
(a + (c * 1)) * (a - (a + (b.a * 1)))
patternMatchNestedListOfRecords : List (List (NestedRecordOfCustomType Int)) -> Maybe (List (List (NestedRecordOfCustomType Int)))
patternMatchNestedListOfRecords list =
case [ list ] of
[ [ [ { a, b } ] ] ] ->
case ( a, b ) of
( ( 1, [ Just ( 1, ct ) ] ), ( 2, { c } ) ) ->
Just
[ [ { a = ( 1, [ Just ( 1, c ) ] )
, b = ( 2, { c = ct } )
, d = { f = { g = "test" } }
}
]
]
_ ->
Nothing
_ ->
Nothing
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/fennel/ 0000775 0000000 0000000 00000000000 15066556776 0024416 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/fennel/regular.fnl 0000664 0000000 0000000 00000003716 15066556776 0026567 0 ustar 00root root 0000000 0000000 (print (.. "foo" "bar"))
(local abcd { :a { :b { :c { :d {}}}}})
(let [one 1 two 2 tbl { : one : two}]
tbl)
;;; Destructuring a table binding
(let [{:a {:b {:c {:d d}}}} abcd]
(print d))
[0 [1 [2 [3 []]]]]
;; NOTE: the single ":" on the second line could also be a delimiter
{:a :b
: abcd}
;;; Get AST root
(fn get-root [bufnr]
;;; Get current buffer
(local bufnr (or bufnr
(vim.api.nvim_get_current_buf)))
;;; Early return if not in a Nix file
(when (not= (. vim :bo bufnr :filetype)
:nix)
(vim.notify_once "This is meant to be used with Nix files")
(lua "return nil"))
(let [parser (vim.treesitter.get_parser bufnr :nix {})
[tree] (parser:parse)]
(tree:root)))
(macro -m?> [val ...]
"Thread (maybe) a value through a list of method calls"
(assert-compile
val
"There should be an input value to the pipeline")
(var res# (gensym))
(var res `(do (var ,res# ,val)))
(each [_ [f & args] (ipairs [...])]
(table.insert
res
`(when (and (not= nil ,res#)
(not= nil (. ,res# ,f)))
(set ,res# (: ,res# ,f ,(unpack args))))))
res)
(fn add-partial [x]
(fn [y]
(fn [z] (+ x y z))))
(λ sub-partial [x]
(λ [y]
(λ [z] (- x y z))))
(let [a 1]
(let [b 2]
(let [c 3]
(+ a b c))))
(let [t {:a 4 :b 8}]
(set t.a 2) t)
(let [(a b c) (values 1 2 3)]
(+ a b c))
(match (add-partial 5 6 7)
[1 [2] 3] (print "osuhow")
12 :dont
x x)
(each [key value (pairs {"a" 1 "b" 2})]
(print key value))
(for [i 1 10]
(print i))
(var numbers [1 2 3 4 5 6])
(collect [_ x (ipairs numbers)]
(values x true))
(icollect [_ x (ipairs numbers)]
(+ x 1))
(fcollect [i 0 10 2]
(if (> i 2) (* i i)))
(accumulate [acc 0 _ x (ipairs numbers)]
(+ acc x))
(faccumulate [n 0 i 1 5] (+ n i)) ; => 15
(#(faccumulate [n 1 i 1 $] (* n i)) 5) ; => 120 (factorial!)
((hashfn (faccumulate [n 1 i 1 $] (* n i))) 5) ; => 120 (factorial!)
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/fish/ 0000775 0000000 0000000 00000000000 15066556776 0024100 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/fish/regular.fish 0000664 0000000 0000000 00000000267 15066556776 0026421 0 ustar 00root root 0000000 0000000 set -l shells "$SHELL" /bin/{zsh,bash,sh} (which nu) /usr/bin/xonsh
echo "Your first few shells is $shells[1..3]"
if set -q shells[10]
echo "You defined at least 10 shells"
end
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/fsharp/ 0000775 0000000 0000000 00000000000 15066556776 0024432 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/fsharp/regular.fs 0000664 0000000 0000000 00000003753 15066556776 0026435 0 ustar 00root root 0000000 0000000 module Regular
let no_args () =
()
let one_arg (x: int) =
x
let two_args (x: int) (y: int) =
x + y
let three_args (x: int) (y: int) (z: int) =
x + y + z
let tuple ( (x: (int * float)) ) =
x
let destructured_tuple ((a, b): int * int) =
a + b
let array (x: int array) = function
| [|x|] -> x
| [| x; y; z |] -> x + y + x
| _ -> 0
let nested_array (x: int array array) = function
| [| [| [| x |] |] |] -> x
| [| [| [| x; y; z |] |] |] -> x + y + z
| _ -> 0
let list (x: int list) = function
| [x] -> x
| [ x; y; z ] -> x + y + x
| _ -> 0
let nested_list (x: int list list) = function
| [ [ [ x ] ] ] -> x
| [ [ [ x; y; z ] ] ] -> x + y + x
| _ -> 0
let return_value =
(Some (Ok (Some (2))))
let type_argument (x: seq<'a>) =
x
let nested_type_argument (x: seq>>) =
x
type Record =
{ a: int
b: string
}
type Union =
| Tuple of (int * float)
| NestedTuple of (int * (int * (int * int)))
| TypeArgs of Result, float>
type Wrapper = Wrapper of int * int
let unwrap (Wrapper (a, b)) =
a + b
let lambda =
(fun x -> (fun (a, b) -> x))
let match_test x =
match x with
| (Some (((((Some (a))))))) -> a
| _ -> 0
let unit_args () () () =
()
let computation_expressions asyncFn (x: int) =
async {
let t =
task {
let a = 2
let b = 3
return async {
let! res = asyncFn (x)
return res + a + b
}
}
return t
}
let if_tests (x: int) =
if x <> 0 then
()
elif x < 1 then
()
else
()
type Class(a: int) =
member _.A () =
(a)
member this.Member () =
()
static member StaticMember () =
()
let main _ =
unit_args () ((((((((((())))))))))) ();
one_arg ((((((((((((1)))))))))))) |> ignore;
two_args (1) (((((((((2))))))))) |> ignore;
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/gleam/ 0000775 0000000 0000000 00000000000 15066556776 0024234 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/gleam/regular.gleam 0000664 0000000 0000000 00000002602 15066556776 0026704 0 ustar 00root root 0000000 0000000 import gleam/io.{println} // unqualified_imports
pub fn main()
{ // block
println("Hi!")
}
pub type Cobel // type_definition
(name, age) { // type_parameters
Cobel(name: Int, age: Int) // data_constructor_arguments
}
pub type Helly {
Helly(real_one: Bool)
Helena(real_one: Bool)
}
pub fn check_hair(tup: #(String, String)) { // tuple_type
let hellys = #("Helly", "Helena") // tuple
case tup {
#("Orange", "Hair") -> hellys // tuple_pattern
_ -> #("Mark S.", "Mark Scout")
}
}
pub fn is_irving_first() {
let lst = ["Mark", "Helly", "Dylan", "Irving"] // list
case lst {
["Irving", ..] -> True // list_pattern
[_, ..] -> False
[] -> False
}
}
// Couldn't think of a severance reference for a bit string. Forgive me!
pub fn bit_string_empty() {
let var = <<3:size(8)>> // bit_string_segment_option
case var {
<<>> -> True // bit_string_pattern
_ -> False
}
}
pub fn operate_on_hello(func: fn(String) -> a) { // function_parameter_types
func("hello") // arguments
}
pub fn change_cobel_age(arg: Cobel(_, _)) { // type_arguments
Cobel(..arg, age:13) // record_update
}
pub fn which_helly(my_helly) { // function_parameters
case my_helly { // case
Helly(_) -> "the numbers were scary" // record_pattern_arguments
Helena(_) -> "i'm like the head of the company"
}
}
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/glsl/ 0000775 0000000 0000000 00000000000 15066556776 0024110 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/glsl/regular.glsl 0000664 0000000 0000000 00000001424 15066556776 0026435 0 ustar 00root root 0000000 0000000 #version 450
struct A{
float a,b;
};
layout(set = 0,binding = 0)buffer B{
A v[];
};
uint C(uint, uint);
uint C(uint a, uint b){
{
{
return a+b;
}
}
}
uint V(){
return v[1].a
}
void main(){
uint t = gl_GlobalInvocationID.x;
uint a = 1;uint b = 1;
uint c = C(C(a, b), b);
if (1){
if (1){
if (1){
a = C(V(),c);
}
}
}
else if(1){
b=1;
}
while (0) {
while (0) {
while (0) {
;
}
}
}
for (uint i = 0; i < 0; i++) {
for (uint j = 0; j < 0; j++) {
for (uint k = 0; k < 0; k++) {
;
}
}
}
v[t].a = a;
v[t].b = b;
}
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/go/ 0000775 0000000 0000000 00000000000 15066556776 0023554 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/go/regular.go 0000664 0000000 0000000 00000004011 15066556776 0025540 0 ustar 00root root 0000000 0000000 package main
import (
"fmt"
"sort"
"regexp"
)
const (
TOOEXPENSIVE = 200
)
type Wine struct {
Name string
Produced int
Price float32
InStock bool
}
func (w Wine) String() string {
return fmt.Sprintf("Name: %s, Produced: %d, Cost: %0.2f", w.Name, w.Produced, w.Price)
}
type ByProduced []Wine
func (a ByProduced) Len() int { return len(a) }
func (a ByProduced) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByProduced) Less(i, j int) bool { return a[i].Produced < a[j].Produced }
func isFloat32(i interface{}) bool {
switch v := i.(type) {
case float32:
fmt.Printf("%v is a float32", i.(float32))
return true
default:
fmt.Printf("%v is not a float32", v)
return false
}
}
func SumUp[K comparable, V float32](v1 V, v2 V) V {
return v1 + (((v2)))
}
func main() {
var re = regexp.MustCompile(`x`)
wines := []Wine{
{"Cabernet Sauvignon", 1991, 200.0, true},
{"Merlot", 1939, 500.0, true},
{"Zinfandel", 1982, 120.0, false},
}
fmt.Println(len(wines[:2]))
stringArr := [4]string{"a", "b", "c", "d"}
addons := map[string]struct {
Item string
Price float32
}{
"Zinfandel": {Item: "chocolate", Price: 10.0},
"Cabernet Sauvignon": {Item: "cake", Price: 12.0},
}
var (
nonexpensive []Wine
)
LABEL:
for {
for {
for {
for {
for {
sort.Sort(ByProduced(wines))
for _, wine := range wines {
switch wprice := wine.Price; {
case wprice > TOOEXPENSIVE:
// Too expensive
default:
nonexpensive = append(nonexpensive, wine)
}
}
break LABEL
}
}
}
}
}
for _, wine := range nonexpensive {
if wine.InStock {
if wine.InStock {
if wine.InStock {
if wine.InStock {
if isFloat32(wine.Price) {
fmt.Println("I can sell you", wine)
if val, ok := addons[wine.Name]; ok {
fmt.Println("And I have a bundle with ", val.Item, " if you would like ? you can get it for ", SumUp[float32](wine.Price, val.Price))
}
}
}
}
}
}
}
}
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/groovy/ 0000775 0000000 0000000 00000000000 15066556776 0024474 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/groovy/regular.groovy 0000664 0000000 0000000 00000002615 15066556776 0027410 0 ustar 00root root 0000000 0000000 (1..<2).each { i -> // closure
def _n = (1 + 3) // parenthesized_expression
// if_statement
def x = ""
if (x == "even") {
println "Even number: $i"
} else {
println("Odd number: $i") // argument_list
}
// for_parameters
for (x=0; x<3; x++) {
print "."
}
// for_in_loop
for (y in ([1, [2, 3], 4])) {
println "y = $y"
}
}
def henlo(name="fren") // parameter_list
{
println "henlo $name"
}
{
key = "hysm"
map = [(key): "ra3d"] // map
def abcd = [a: [b: [c: [d: [:]]]]] // map nesting
_ = map["hysm"] // index
list = [0, [1, [2, [3, []]]]] // list
println "${map.hysm}" // interpolation
if ("${map.hysm}" =~ /r${/.?/}3d/) { // regex, with nesting
println "hysm is r3d"
}
}() // this immediate lambda invocation is valid groovy but produces broken AST in the default TS grammar
x = 7.23
String result
switch (x) {
case "foo": result = "found foo"
// fall through
case [4, 5, 6, 'inList']:
result = "my list"
break
case ~/[0-9]+/:
result = "numeric string"
break
case { it > 3 }: {
result = "number > 3"
break
}
default: result = "default"
}
assert result == "number > 3"
assert (result == "number > 3")
List >> _trash = [[[mazen: 5]]] // generics
return ( // return
"henlo" +
" fren"
)
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/haskell/ 0000775 0000000 0000000 00000000000 15066556776 0024572 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/haskell/regular.hs 0000664 0000000 0000000 00000002113 15066556776 0026564 0 ustar 00root root 0000000 0000000 {-# LANGUAGE RecordWildCards #-}
module ExampleModule
( ExampleRecord (..)
, someRecord
, mkRec
, mkRec2
, mkRec3
, mkRec4
) where
import Data.Maybe hiding (fromJust)
import Data.Functor ((<$>))
data ExampleRecord
= ExampleRecord
{ name :: String
, mmUnit :: Maybe (Maybe ())
}
deriving (Eq, Show)
getName :: ExampleRecord -> String
getName ExampleRecord {..} = name
someRecord :: ExampleRecord
someRecord = anotherRecord { name = "xyz" }
where anotherRecord = mkRec "" Nothing
mkRec :: String -> Maybe (Maybe a) -> ExampleRecord
mkRec name (Just (Just _)) = ExampleRecord {..}
where mmUnit = Just $ Just ()
mkRec name (Just _) = ExampleRecord {..}
where mmUnit = Just Nothing
mkRec name _ = ExampleRecord {..}
where mmUnit = Nothing
mkRec2 :: String -> String -> ExampleRecord
mkRec2 first last = mkRec (first <> " " <> last) Nothing
mkRec3 :: [Char] -> ExampleRecord
mkRec3 (a:b:c:_) = mkRec [a, b, c] Nothing
mkRec3 _ = mkRec "" Nothing
mkRec4 :: (String, String) -> ExampleRecord
mkRec4 (a, b) = mkRec (a <> b) Nothing
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/html/ 0000775 0000000 0000000 00000000000 15066556776 0024113 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/html/regular.html 0000664 0000000 0000000 00000001242 15066556776 0026441 0 ustar 00root root 0000000 0000000
Test page
)
}
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/julia/ 0000775 0000000 0000000 00000000000 15066556776 0024253 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/julia/regular.jl 0000664 0000000 0000000 00000000175 15066556776 0026246 0 ustar 00root root 0000000 0000000 a = Vector{Int}([1, 2, 3, 4, 5, 6]);
A = [
28 32
11 70
];
f(x) = abs((x-4)*(x+2))
b = [f(x) for x ∈ A]
x = (1, 2)
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/kdl/ 0000775 0000000 0000000 00000000000 15066556776 0023721 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/kdl/regular.kdl 0000664 0000000 0000000 00000000270 15066556776 0026055 0 ustar 00root root 0000000 0000000 contents {
// a key/value pair
version "^1.2"
numbers (u8)10 20 myfloat=(f32)1.5 alias="num" {
strings (uuid)"123e4567-e89b-12d3-a456-426614174000" (date)"2021-02-03"
}
}
rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/kotlin/ 0000775 0000000 0000000 00000000000 15066556776 0024447 5 ustar 00root root 0000000 0000000 rainbow-delimiters.nvim-v0.10.0/test/highlight/samples/kotlin/Test.kt 0000664 0000000 0000000 00000004344 15066556776 0025733 0 ustar 00root root 0000000 0000000 // Define a simple class with a primary constructor
class Person(private val name: String, private val age: Int, private val t: T) {
// Secondary constructor
constructor(name: String) : this(name, 0)
class Hello {
class Goodbye {
}
}
init {
println("New person created with name $name")
}
// Member function
fun greet() {
println("Hello, my name is $name and I am $age years old.")
}
}
// Extension function
fun String.exclaim() = "$this!"
// Top-level function
fun calculateFactorial(n: Int): Int {
return if (n == 1) n else n * calculateFactorial(n - 1)
}
// Main function - entry point of the program
fun main() {
val person = Person