mirror of
https://github.com/HiPhish/rainbow-delimiters.nvim.git
synced 2024-09-08 02:25:48 +02:00
Add highlight priority setting
This commit is contained in:
parent
a2da59bdac
commit
fdd507455a
9 changed files with 117 additions and 3 deletions
|
@ -15,6 +15,7 @@ Unreleased
|
|||
Added
|
||||
=====
|
||||
|
||||
- Ability to set highlight priority
|
||||
- Cue support
|
||||
- Luadoc support
|
||||
- Nim support
|
||||
|
@ -30,6 +31,12 @@ Fixed
|
|||
- Missing `switch_body` pattern for Javascript and Typescript
|
||||
- Missing `rec_attrset_expression` and `inherit_from` patterns for Nix
|
||||
|
||||
Changed
|
||||
=======
|
||||
|
||||
- Default highlight priority is 110 instead of 210, which is between
|
||||
Tree-sitter and LSP semantic tokens
|
||||
|
||||
|
||||
[0.1.0] - 2023-11-12
|
||||
####################
|
||||
|
|
|
@ -34,4 +34,5 @@ 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`
|
||||
|
|
13
README.rst
13
README.rst
|
@ -28,8 +28,9 @@ for each language you want to use rainbow delimiters with.
|
|||
Setup
|
||||
=====
|
||||
|
||||
Configuration is done by setting entries in the Vim script dictionary
|
||||
`g:rainbow_delimiters`. Here is an example configuration:
|
||||
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
|
||||
|
||||
|
@ -42,6 +43,10 @@ Configuration is done by setting entries in the Vim script dictionary
|
|||
\ '': 'rainbow-delimiters',
|
||||
\ 'lua': 'rainbow-blocks',
|
||||
\ },
|
||||
\ 'priority': {
|
||||
\ '': 110,
|
||||
\ 'lua': 210,
|
||||
\ },
|
||||
\ 'highlight': [
|
||||
\ 'RainbowDelimiterRed',
|
||||
\ 'RainbowDelimiterYellow',
|
||||
|
@ -70,6 +75,10 @@ The equivalent code in Lua:
|
|||
[''] = 'rainbow-delimiters',
|
||||
lua = 'rainbow-blocks',
|
||||
},
|
||||
priority = {
|
||||
[''] = 110,
|
||||
lua = 210,
|
||||
},
|
||||
highlight = {
|
||||
'RainbowDelimiterRed',
|
||||
'RainbowDelimiterYellow',
|
||||
|
|
|
@ -58,6 +58,12 @@ keys are recognized:
|
|||
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|.
|
||||
|
@ -90,6 +96,10 @@ Here is an example configuration:
|
|||
\ '': 'rainbow-delimiters',
|
||||
\ 'lua': 'rainbow-blocks',
|
||||
\ },
|
||||
\ 'priority': {
|
||||
\ '': 110,
|
||||
\ 'lua': 210,
|
||||
\ },
|
||||
\ 'highlight': [
|
||||
\ 'RainbowDelimiterRed',
|
||||
\ 'RainbowDelimiterYellow',
|
||||
|
@ -118,6 +128,10 @@ Alternatively, the same configuration in Lua:
|
|||
[''] = 'rainbow-delimiters',
|
||||
lua = 'rainbow-blocks',
|
||||
},
|
||||
priority = {
|
||||
[''] = 110,
|
||||
lua = 210,
|
||||
},
|
||||
highlight = {
|
||||
'RainbowDelimiterRed',
|
||||
'RainbowDelimiterYellow',
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
---@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
|
||||
|
@ -162,6 +164,70 @@
|
|||
---User defined language, not part of rainbow_delimiters support
|
||||
---@field [string] string?
|
||||
|
||||
---@class rainbow_delimiters.config.priorities
|
||||
---@field [''] (integer | fun(): integer?)?
|
||||
---@field astro (integer | fun(): integer?)?
|
||||
---@field bash (integer | fun(): integer?)?
|
||||
---@field c (integer | fun(): integer?)?
|
||||
---@field c_sharp (integer | fun(): integer?)?
|
||||
---@field clojure (integer | fun(): integer?)?
|
||||
---@field commonlisp (integer | fun(): integer?)?
|
||||
---@field cpp (integer | fun(): integer?)?
|
||||
---@field css (integer | fun(): integer?)?
|
||||
---@field cuda (integer | fun(): integer?)?
|
||||
---@field cue (integer | fun(): integer?)?
|
||||
---@field dart (integer | fun(): integer?)?
|
||||
---@field elixir (integer | fun(): integer?)?
|
||||
---@field elm (integer | fun(): integer?)?
|
||||
---@field fennel (integer | fun(): integer?)?
|
||||
---@field fish (integer | fun(): integer?)?
|
||||
---@field go (integer | fun(): integer?)?
|
||||
---@field haskell (integer | fun(): integer?)?
|
||||
---@field hcl (integer | fun(): integer?)?
|
||||
---@field html (integer | fun(): integer?)?
|
||||
---@field janet_simple (integer | fun(): integer?)?
|
||||
---@field java (integer | fun(): integer?)?
|
||||
---@field javascript (integer | fun(): integer?)?
|
||||
---@field json (integer | fun(): integer?)?
|
||||
---@field json5 (integer | fun(): integer?)?
|
||||
---@field jsonc (integer | fun(): integer?)?
|
||||
---@field jsonnet (integer | fun(): integer?)?
|
||||
---@field julia (integer | fun(): integer?)?
|
||||
---@field kotlin (integer | fun(): integer?)?
|
||||
---@field latex (integer | fun(): integer?)?
|
||||
---@field lua (integer | fun(): integer?)?
|
||||
---@field luadoc (integer | fun(): integer?)?
|
||||
---@field make (integer | fun(): integer?)?
|
||||
---@field markdown (integer | fun(): integer?)?
|
||||
---@field nim (integer | fun(): integer?)?
|
||||
---@field nix (integer | fun(): integer?)?
|
||||
---@field perl (integer | fun(): integer?)?
|
||||
---@field php (integer | fun(): integer?)?
|
||||
---@field python (integer | fun(): integer?)?
|
||||
---@field query (integer | fun(): integer?)?
|
||||
---@field r (integer | fun(): integer?)?
|
||||
---@field racket (integer | fun(): integer?)?
|
||||
---@field regex (integer | fun(): integer?)?
|
||||
---@field rst (integer | fun(): integer?)?
|
||||
---@field ruby (integer | fun(): integer?)?
|
||||
---@field rust (integer | fun(): integer?)?
|
||||
---@field scheme (integer | fun(): integer?)?
|
||||
---@field scss (integer | fun(): integer?)?
|
||||
---@field sql (integer | fun(): integer?)?
|
||||
---@field templ (integer | fun(): integer?)?
|
||||
---@field toml (integer | fun(): integer?)?
|
||||
---@field tsx (integer | fun(): integer?)?
|
||||
---@field typescript (integer | fun(): integer?)?
|
||||
---@field verilog (integer | fun(): integer?)?
|
||||
---@field vim (integer | fun(): integer?)?
|
||||
---@field vimdoc (integer | fun(): integer?)?
|
||||
---@field vue (integer | fun(): integer?)?
|
||||
---@field yaml (integer | fun(): integer?)?
|
||||
---@field zig (integer | fun(): integer?)?
|
||||
---User defined language, not part of rainbow_delimiters support
|
||||
---@field [integer] (integer | fun(): integer?)?
|
||||
|
||||
|
||||
---@alias rainbow_delimiters.language
|
||||
---| 'astro'
|
||||
---| 'bash'
|
||||
|
|
|
@ -52,6 +52,11 @@ local M = {
|
|||
return get_nested(table, 'strategy', key)
|
||||
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)
|
||||
|
|
|
@ -26,6 +26,9 @@ local M = {
|
|||
strategy = {
|
||||
[''] = require 'rainbow-delimiters.strategy.global',
|
||||
},
|
||||
priority = {
|
||||
[''] = 110,
|
||||
},
|
||||
---Event logging settings
|
||||
log = {
|
||||
---Log level of the module, see `:h log_levels`.
|
||||
|
@ -61,6 +64,11 @@ setmetatable(M.strategy, {
|
|||
__index = get_with_fallback,
|
||||
})
|
||||
|
||||
setmetatable(M.priority, {
|
||||
__index = get_with_fallback,
|
||||
})
|
||||
|
||||
|
||||
return M
|
||||
|
||||
-- vim:tw=79:ts=4:sw=4:noet:
|
||||
|
|
|
@ -91,7 +91,7 @@ function M.highlight(bufnr, lang, node, hlgroup)
|
|||
local opts = {
|
||||
regtype = 'c',
|
||||
inclusive = true,
|
||||
priority = 210,
|
||||
priority = config.priority[lang],
|
||||
}
|
||||
|
||||
local nsid = M.nsids[lang]
|
||||
|
|
|
@ -52,5 +52,9 @@ int main(int argc, char *argv[]) {
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue