├── LICENSE
├── README.md
├── doc
└── mini-hipatterns.txt
└── lua
└── mini
└── hipatterns.lua
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Evgeni Chasnovski
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ### Highlight patterns in text
4 |
5 | See more details in [Features](#features) and [Documentation](doc/mini-hipatterns.txt).
6 |
7 | ---
8 |
9 | > [!NOTE]
10 | > This was previously hosted at a personal `echasnovski` GitHub account. It was transferred to a dedicated organization to improve long term project stability. See more details [here](https://github.com/nvim-mini/mini.nvim/discussions/1970).
11 |
12 | ⦿ This is a part of [mini.nvim](https://nvim-mini.org/mini.nvim) library. Please use [this link](https://nvim-mini.org/mini.nvim/readmes/mini-hipatterns) if you want to mention this module.
13 |
14 | ⦿ All contributions (issues, pull requests, discussions, etc.) are done inside of 'mini.nvim'.
15 |
16 | ⦿ See [whole library documentation](https://nvim-mini.org/mini.nvim/doc/mini-nvim) to learn about general design principles, disable/configuration recipes, and more.
17 |
18 | ⦿ See [MiniMax](https://nvim-mini.org/MiniMax) for a full config example that uses this module.
19 |
20 | ---
21 |
22 | If you want to help this project grow but don't know where to start, check out [contributing guides of 'mini.nvim'](https://nvim-mini.org/mini.nvim/CONTRIBUTING) or leave a Github star for 'mini.nvim' project and/or any its standalone Git repositories.
23 |
24 | ## Demo
25 |
26 |
27 | https://github.com/nvim-mini/mini.nvim/assets/24854248/130374e2-4e6c-43cf-af33-43d816b4fa32
28 |
29 | ## Features
30 |
31 | - Highlight text with configurable patterns and highlight groups (can be string or callable).
32 |
33 | - Highlighting is updated asynchronously with configurable debounce delay.
34 |
35 | - Function to get matches in a buffer.
36 |
37 | See `:h MiniHipatterns-examples` for examples of common use cases.
38 |
39 | Notes:
40 |
41 | - It does not define any highlighters by default. Add to `config.highlighters` to have a visible effect.
42 |
43 | ## Example usage
44 |
45 | ```lua
46 | local hipatterns = require('mini.hipatterns')
47 | hipatterns.setup({
48 | highlighters = {
49 | -- Highlight standalone 'FIXME', 'HACK', 'TODO', 'NOTE'
50 | fixme = { pattern = '%f[%w]()FIXME()%f[%W]', group = 'MiniHipatternsFixme' },
51 | hack = { pattern = '%f[%w]()HACK()%f[%W]', group = 'MiniHipatternsHack' },
52 | todo = { pattern = '%f[%w]()TODO()%f[%W]', group = 'MiniHipatternsTodo' },
53 | note = { pattern = '%f[%w]()NOTE()%f[%W]', group = 'MiniHipatternsNote' },
54 |
55 | -- Highlight hex color strings (`#rrggbb`) using that color
56 | hex_color = hipatterns.gen_highlighter.hex_color(),
57 | },
58 | })
59 | ```
60 |
61 | ## Installation
62 |
63 | This plugin can be installed as part of 'mini.nvim' library (**recommended**) or as a standalone Git repository.
64 |
65 | There are two branches to install from:
66 |
67 | - `main` (default, **recommended**) will have latest development version of plugin. All changes since last stable release should be perceived as being in beta testing phase (meaning they already passed alpha-testing and are moderately settled).
68 | - `stable` will be updated only upon releases with code tested during public beta-testing phase in `main` branch.
69 |
70 | Here are code snippets for some common installation methods (use only one):
71 |
72 |
73 | With mini.deps
74 |
75 | - 'mini.nvim' library:
76 |
77 | | Branch | Code snippet |
78 | |--------|-----------------------------------------------|
79 | | Main | *Follow recommended ‘mini.deps’ installation* |
80 | | Stable | *Follow recommended ‘mini.deps’ installation* |
81 |
82 | - Standalone plugin:
83 |
84 | | Branch | Code snippet |
85 | |--------|----------------------------------------------------------------------|
86 | | Main | `add(‘nvim-mini/mini.hipatterns’)` |
87 | | Stable | `add({ source = ‘nvim-mini/mini.hipatterns’, checkout = ‘stable’ })` |
88 |
89 |
90 |
91 |
92 | With folke/lazy.nvim
93 |
94 | - 'mini.nvim' library:
95 |
96 | | Branch | Code snippet |
97 | |--------|-----------------------------------------------|
98 | | Main | `{ 'nvim-mini/mini.nvim', version = false },` |
99 | | Stable | `{ 'nvim-mini/mini.nvim', version = '*' },` |
100 |
101 | - Standalone plugin:
102 |
103 | | Branch | Code snippet |
104 | |--------|-----------------------------------------------------|
105 | | Main | `{ 'nvim-mini/mini.hipatterns', version = false },` |
106 | | Stable | `{ 'nvim-mini/mini.hipatterns', version = '*' },` |
107 |
108 |
109 |
110 |
111 | With junegunn/vim-plug
112 |
113 | - 'mini.nvim' library:
114 |
115 | | Branch | Code snippet |
116 | |--------|------------------------------------------------------|
117 | | Main | `Plug 'nvim-mini/mini.nvim'` |
118 | | Stable | `Plug 'nvim-mini/mini.nvim', { 'branch': 'stable' }` |
119 |
120 | - Standalone plugin:
121 |
122 | | Branch | Code snippet |
123 | |--------|------------------------------------------------------------|
124 | | Main | `Plug 'nvim-mini/mini.hipatterns'` |
125 | | Stable | `Plug 'nvim-mini/mini.hipatterns', { 'branch': 'stable' }` |
126 |
127 |
128 |
129 | **Important**: don't forget to call `require('mini.hipatterns').setup()` with non-empty `highlighters` to auto-enable highlighting in all normal buffers.
130 |
131 | **Note**: if you are on Windows, there might be problems with too long file paths (like `error: unable to create file : Filename too long`). Try doing one of the following:
132 |
133 | - Enable corresponding git global config value: `git config --system core.longpaths true`. Then try to reinstall.
134 | - Install plugin in other place with shorter path.
135 |
136 | ## Default config
137 |
138 | ```lua
139 | -- No need to copy this inside `setup()`. Will be used automatically.
140 | {
141 | -- Table with highlighters (see |MiniHipatterns.config| for more details).
142 | -- Nothing is defined by default. Add manually for visible effect.
143 | highlighters = {},
144 |
145 | -- Delays (in ms) defining asynchronous highlighting process
146 | delay = {
147 | -- How much to wait for update after every text change
148 | text_change = 200,
149 |
150 | -- How much to wait for update after window scroll
151 | scroll = 50,
152 | },
153 |
154 | }
155 | ```
156 |
157 | ## Similar plugins
158 |
159 | - [folke/todo-comments.nvim](https://github.com/folke/todo-comments.nvim)
160 | - [folke/paint.nvim](https://github.com/folke/paint.nvim)
161 | - [NvChad/nvim-colorizer.lua](https://github.com/NvChad/nvim-colorizer.lua)
162 | - [uga-rosa/ccc.nvim](https://github.com/uga-rosa/ccc.nvim)
163 |
--------------------------------------------------------------------------------
/doc/mini-hipatterns.txt:
--------------------------------------------------------------------------------
1 | *mini.hipatterns* Highlight patterns in text
2 |
3 | MIT License Copyright (c) 2023 Evgeni Chasnovski
4 |
5 | ------------------------------------------------------------------------------
6 | *MiniHipatterns*
7 | Features:
8 | - Highlight text with configurable patterns and highlight groups (can be
9 | string or callable).
10 |
11 | - Highlighting is updated asynchronously with configurable debounce delay.
12 |
13 | - Function to get matches in a buffer (see |MiniHipatterns.get_matches()|).
14 |
15 | See |MiniHipatterns-examples| for common configuration examples.
16 |
17 | Notes:
18 | - It does not define any highlighters by default. Add to `config.highlighters`
19 | to have a visible effect.
20 |
21 | - Sometimes (especially during frequent buffer updates on same line numbers)
22 | highlighting can be outdated or not applied when it should be. This is due
23 | to asynchronous nature of updates reacting to text changes (via
24 | `on_lines` of |nvim_buf_attach()|).
25 | To make them up to date, use one of the following:
26 | - Scroll window (for example, with |CTRL-E| / |CTRL-Y|). This will ensure
27 | up to date highlighting inside window view.
28 | - Hide and show buffer.
29 | - Execute `:edit` (if you enabled highlighting with |MiniHipatterns.setup()|).
30 | - Manually call |MiniHipatterns.update()|.
31 |
32 | - If you experience flicker when typing near highlighted pattern in Insert
33 | mode, it might be due to `delay` configuration of |mini.completion| or
34 | using built-in completion.
35 | For better experience with 'mini.completion', make sure that its
36 | `delay.completion` is less than this module's `delay.text_change` (which
37 | it is by default).
38 | The reason for this is (currently unresolvable) limitations of Neovim's
39 | built-in completion implementation.
40 |
41 | # Setup ~
42 |
43 | Setting up highlights can be done in two ways:
44 | - Manually for every buffer with `require('mini.hipatterns').enable()`.
45 | This will enable highlighting only in one particular buffer until it is
46 | unloaded (which also includes calling `:edit` on current file).
47 |
48 | - Globally with `require('mini.hipatterns').setup({})` (replace `{}` with
49 | your `config` table). This will auto-enable highlighting in "normal"
50 | buffers (see 'buftype'). Use |MiniHipatterns.enable()| to manually enable
51 | in other buffers.
52 | It will also create global Lua table `MiniHipatterns` which you can use
53 | for scripting or manually (with `:lua MiniHipatterns.*`).
54 |
55 | See |MiniHipatterns.config| for `config` structure and default values.
56 |
57 | You can override runtime config settings (like highlighters and delays)
58 | locally to buffer inside `vim.b.minihipatterns_config` which should have
59 | same structure as `MiniHipatterns.config`.
60 | See |mini.nvim-buffer-local-config| for more details.
61 |
62 | # Comparisons ~
63 |
64 | - [folke/todo-comments](https://github.com/folke/todo-comments):
65 | - Oriented for "TODO", "NOTE", "FIXME" like patterns, while this module
66 | can work with any Lua patterns and computable highlight groups.
67 | - Has functionality beyond text highlighting (sign placing,
68 | "telescope.nvim" extension, etc.), while this module only focuses on
69 | highlighting text.
70 | - [folke/paint.nvim](https://github.com/folke/paint.nvim):
71 | - Mostly similar to this module, but with slightly less functionality,
72 | such as computed pattern and highlight group, asynchronous delay, etc.
73 | - [NvChad/nvim-colorizer.lua](https://github.com/NvChad/nvim-colorizer.lua):
74 | - Oriented for color highlighting, while this module can work with any
75 | Lua patterns and computable highlight groups.
76 | - Has more built-in color spaces to highlight, while this module out of
77 | the box provides only hex color highlighting
78 | (see |MiniHipatterns.gen_highlighter.hex_color()|). Other types are
79 | also possible to implement.
80 | - [uga-rosa/ccc.nvim](https://github.com/uga-rosa/ccc.nvim):
81 | - Has more than color highlighting functionality, which is compared to
82 | this module in the same way as 'NvChad/nvim-colorizer.lua'.
83 |
84 | # Highlight groups ~
85 |
86 | - `MiniHipatternsFixme` - suggested group to use for `FIXME`-like patterns.
87 | - `MiniHipatternsHack` - suggested group to use for `HACK`-like patterns.
88 | - `MiniHipatternsTodo` - suggested group to use for `TODO`-like patterns.
89 | - `MiniHipatternsNote` - suggested group to use for `NOTE`-like patterns.
90 |
91 | To change any highlight group, set it directly with |nvim_set_hl()|.
92 |
93 | # Disabling ~
94 |
95 | This module can be disabled in three ways:
96 | - Globally: set `vim.g.minihipatterns_disable` to `true`.
97 | - Locally for buffer permanently: set `vim.b.minihipatterns_disable` to `true`.
98 | - Locally for buffer temporarily (until next auto-enabling event if set up
99 | with |MiniHipatterns.setup()|): call |MiniHipatterns.disable()|.
100 |
101 | Considering high number of different scenarios and customization
102 | intentions, writing exact rules for disabling module's functionality is
103 | left to user. See |mini.nvim-disabling-recipes| for common recipes.
104 |
105 | ------------------------------------------------------------------------------
106 | *MiniHipatterns-examples*
107 | # Common configuration examples ~
108 |
109 | - Special words used to convey different level of attention: >lua
110 |
111 | require('mini.hipatterns').setup({
112 | highlighters = {
113 | fixme = { pattern = 'FIXME', group = 'MiniHipatternsFixme' },
114 | hack = { pattern = 'HACK', group = 'MiniHipatternsHack' },
115 | todo = { pattern = 'TODO', group = 'MiniHipatternsTodo' },
116 | note = { pattern = 'NOTE', group = 'MiniHipatternsNote' },
117 | }
118 | })
119 | <
120 | - To match only when pattern appears as a standalone word, use frontier
121 | patterns `%f`. For example, instead of `'TODO'` pattern use
122 | `'%f[%w]()TODO()%f[%W]'`. In this case, for example, 'TODOING' or 'MYTODO'
123 | won't match, but 'TODO' and 'TODO:' will.
124 |
125 | - Color hex (like `#rrggbb`) highlighting: >lua
126 |
127 | local hipatterns = require('mini.hipatterns')
128 | hipatterns.setup({
129 | highlighters = {
130 | hex_color = hipatterns.gen_highlighter.hex_color(),
131 | }
132 | })
133 | <
134 | You can customize which part of hex color is highlighted by using `style`
135 | field of input options. See |MiniHipatterns.gen_highlighter.hex_color()|.
136 |
137 | - Colored words: >lua
138 |
139 | local words = { red = '#ff0000', green = '#00ff00', blue = '#0000ff' }
140 | local word_color_group = function(_, match)
141 | local hex = words[match]
142 | if hex == nil then return nil end
143 | return MiniHipatterns.compute_hex_color_group(hex, 'bg')
144 | end
145 |
146 | local hipatterns = require('mini.hipatterns')
147 | hipatterns.setup({
148 | highlighters = {
149 | word_color = { pattern = '%S+', group = word_color_group },
150 | },
151 | })
152 | <
153 | - Trailing whitespace (if don't want to use more specific |mini.trailspace|): >lua
154 |
155 | { pattern = '%f[%s]%s*$', group = 'Error' }
156 | <
157 | - Censor certain sensitive information: >lua
158 |
159 | local censor_extmark_opts = function(_, match, _)
160 | local mask = string.rep('x', vim.fn.strchars(match))
161 | return {
162 | virt_text = { { mask, 'Comment' } }, virt_text_pos = 'overlay',
163 | priority = 200, right_gravity = false,
164 | }
165 | end
166 |
167 | require('mini.hipatterns').setup({
168 | highlighters = {
169 | censor = {
170 | pattern = 'password: ()%S+()',
171 | group = '',
172 | extmark_opts = censor_extmark_opts,
173 | },
174 | },
175 | })
176 | <
177 | - Enable only in certain filetypes. There are at least these ways to do it:
178 | - (Suggested) With `vim.b.minihipatterns_config` in |filetype-plugin|.
179 | Basically, create "after/ftplugin/.lua" file in your config
180 | directory (see |$XDG_CONFIG_HOME|) and define `vim.b.minihipatterns_config`
181 | there with filetype specific highlighters.
182 |
183 | This assumes `require('mini.hipatterns').setup()` call.
184 |
185 | For example, to highlight keywords in EmmyLua comments in Lua files,
186 | create "after/ftplugin/lua.lua" with the following content: >lua
187 |
188 | vim.b.minihipatterns_config = {
189 | highlighters = {
190 | emmylua = { pattern = '^%s*%-%-%-()@%w+()', group = 'Special' }
191 | }
192 | }
193 | <
194 | - Use callable `pattern` with condition. For example: >lua
195 |
196 | require('mini.hipatterns').setup({
197 | highlighters = {
198 | emmylua = {
199 | pattern = function(buf_id)
200 | if vim.bo[buf_id].filetype ~= 'lua' then return nil end
201 | return '^%s*%-%-%-()@%w+()'
202 | end,
203 | group = 'Special',
204 | },
205 | },
206 | })
207 | <
208 | - Disable only in certain filetypes. Enable with |MiniHipatterns.setup()|
209 | and set `vim.b.minihipatterns_disable` buffer-local variable to `true` for
210 | buffer you want disabled. See |mini.nvim-disabling-recipes| for more examples.
211 |
212 | ------------------------------------------------------------------------------
213 | *MiniHipatterns.setup()*
214 | `MiniHipatterns.setup`({config})
215 | Module setup
216 |
217 | Parameters ~
218 | {config} `(table|nil)` Module config table. See |MiniHipatterns.config|.
219 |
220 | Usage ~
221 | >lua
222 | require('mini.hipatterns').setup({}) -- replace {} with your config table
223 | -- needs `highlighters` field present
224 | <
225 | ------------------------------------------------------------------------------
226 | *MiniHipatterns.config*
227 | `MiniHipatterns.config`
228 | Defaults ~
229 | >lua
230 | MiniHipatterns.config = {
231 | -- Table with highlighters (see |MiniHipatterns.config| for more details).
232 | -- Nothing is defined by default. Add manually for visible effect.
233 | highlighters = {},
234 |
235 | -- Delays (in ms) defining asynchronous highlighting process
236 | delay = {
237 | -- How much to wait for update after every text change
238 | text_change = 200,
239 |
240 | -- How much to wait for update after window scroll
241 | scroll = 50,
242 | },
243 | }
244 | <
245 | # Highlighters ~
246 |
247 | `highlighters` table defines which patterns will be highlighted by placing
248 | |extmark| at the match start. It might or might not have explicitly named
249 | fields, but having them is recommended and is required for proper use of
250 | `vim.b.minihipatterns_config` as buffer-local config. By default it is
251 | empty expecting user definition.
252 |
253 | Each entry defines single highlighter as a table with the following fields:
254 | - `(string|function|table)` - Lua pattern to highlight. Can be
255 | either string, callable returning the string, or an array of those.
256 | If string:
257 | - It can have submatch delimited by placing `()` on start and end, NOT
258 | by surrounding it with parenthesis (results in an error containing
259 | `number expected, got string`). Example: `xx()abcd()xx` will match
260 | `abcd` only if `xx` is placed before and after it.
261 |
262 | If callable:
263 | - It will be called for every enabled buffer with its identifier as input.
264 | Should return single string pattern or `nil` (meaning this particular
265 | highlighter will not work in this particular buffer).
266 |
267 | If array:
268 | - Each element is matched and highlighted with the same highlight group.
269 |
270 | Note: matching does not result in overlapping (sub)matches (similarly
271 | to how |cpo-c| works). For example, with line `xxxxxxx`:
272 | - Pattern `xxx` matches columns 1-3, 4-6.
273 | - Pattern `()xx()x` matches columns 1-2, 3-4, 5-6.
274 | - Pattern `x()xx()` matches columns 2-3, 5-6.
275 | - Pattern `x()x()x` matches columns 2-2, 4-4, 6-6.
276 |
277 | - `(string|function)` - name of highlight group to use. Can be either
278 | string or callable returning the string.
279 | If callable:
280 | - It will be called for every pattern match with the following arguments:
281 | - `buf_id` - buffer identifier.
282 | - `match` - string pattern match to be highlighted.
283 | - `data` - extra table with information about the match.
284 | It has at least these fields:
285 | - - string with full pattern match.
286 | - - match line number (1-indexed).
287 | - - match starting byte column (1-indexed).
288 | - - match ending byte column (1-indexed, inclusive).
289 |
290 | - It can return `nil` meaning this particular match will not be highlighted.
291 |
292 | - `(table|function|nil)` - optional extra options
293 | for |nvim_buf_set_extmark()|. If callable, will be called in the same way
294 | as callable (`data` will also contain `hl_group` key with
295 | value) and should return a table with all options for extmark (including
296 | `end_row`, `end_col`, `hl_group`, and `priority`).
297 |
298 | See "Common use cases" section for the examples.
299 |
300 | # Delay ~
301 |
302 | `delay` is a table defining delays in milliseconds used for asynchronous
303 | highlighting process.
304 |
305 | `delay.text_change` is used to delay highlighting updates by accumulating
306 | them (in debounce fashion). Smaller values will lead to faster response but
307 | more frequent updates. Bigger - slower response but less frequent updates.
308 |
309 | `delay.scroll` is used to delay updating highlights in current window view
310 | during scrolling (see |WinScrolled| event). These updates are present to
311 | ensure up to date highlighting after scroll.
312 |
313 | ------------------------------------------------------------------------------
314 | *MiniHipatterns.enable()*
315 | `MiniHipatterns.enable`({buf_id}, {config})
316 | Enable highlighting in buffer
317 |
318 | Notes:
319 | - With default config it will highlight nothing, as there are no default
320 | highlighters.
321 |
322 | - Buffer highlighting is enabled until buffer is unloaded from memory
323 | or |MiniHipatterns.disable()| on this buffer is called.
324 |
325 | - `:edit` disables this, as it is mostly equivalent to closing and opening
326 | buffer. In order for highlighting to persist after `:edit`, call
327 | |MiniHipatterns.setup()|.
328 |
329 | Parameters ~
330 | {buf_id} `(number|nil)` Buffer identifier in which to enable highlighting.
331 | Default: 0 for current buffer.
332 | {config} `(table|nil)` Optional buffer-local config. Should have the same
333 | structure as |MiniHipatterns.config|. Values will be taken in this order:
334 | - From this `config` argument (if supplied).
335 | - From buffer-local config in `vim.b.minihipatterns_config` (if present).
336 | - From global config (if |MiniHipatterns.setup()| was called).
337 | - From default values.
338 |
339 | ------------------------------------------------------------------------------
340 | *MiniHipatterns.disable()*
341 | `MiniHipatterns.disable`({buf_id})
342 | Disable highlighting in buffer
343 |
344 | Note that if |MiniHipatterns.setup()| was called, the effect is present
345 | until the next auto-enabling event. To permanently disable highlighting in
346 | buffer, set `vim.b.minihipatterns_disable` to `true`
347 |
348 | Parameters ~
349 | {buf_id} `(number|nil)` Buffer identifier in which to enable highlighting.
350 | Default: 0 for current buffer.
351 |
352 | ------------------------------------------------------------------------------
353 | *MiniHipatterns.toggle()*
354 | `MiniHipatterns.toggle`({buf_id}, {config})
355 | Toggle highlighting in buffer
356 |
357 | Call |MiniHipatterns.disable()| if enabled; |MiniHipatterns.enable()| otherwise.
358 |
359 | Parameters ~
360 | {buf_id} `(number|nil)` Buffer identifier in which to enable highlighting.
361 | Default: 0 for current buffer.
362 | {config} `(table|nil)` Forwarded to |MiniHipatterns.enable()|.
363 |
364 | ------------------------------------------------------------------------------
365 | *MiniHipatterns.update()*
366 | `MiniHipatterns.update`({buf_id}, {from_line}, {to_line})
367 | Update highlighting in range
368 |
369 | Works only in buffer with enabled highlighting. Effect takes immediately
370 | without delay.
371 |
372 | Parameters ~
373 | {buf_id} `(number|nil)` Buffer identifier in which to enable highlighting.
374 | Default: 0 for current buffer.
375 | {from_line} `(number|nil)` Start line from which to update (1-indexed).
376 | {to_line} `(number|nil)` End line from which to update (1-indexed, inclusive).
377 |
378 | ------------------------------------------------------------------------------
379 | *MiniHipatterns.get_enabled_buffers()*
380 | `MiniHipatterns.get_enabled_buffers`()
381 | Get an array of enabled buffers
382 |
383 | Return ~
384 | `(table)` Array of buffer identifiers with enabled highlighting.
385 |
386 | ------------------------------------------------------------------------------
387 | *MiniHipatterns.get_matches()*
388 | `MiniHipatterns.get_matches`({buf_id}, {highlighters})
389 | Get buffer matches
390 |
391 | Parameters ~
392 | {buf_id} `(number|nil)` Buffer identifier for which to return matches.
393 | Default: `nil` for current buffer.
394 | {highlighters} `(table|nil)` Array of highlighter identifiers (as in
395 | `highlighters` field of |MiniHipatterns.config|) for which to return matches.
396 | Default: all available highlighters (ordered by string representation).
397 |
398 | Return ~
399 | `(table)` Array of buffer matches which are tables with following fields:
400 | - `(number)` - buffer identifier of a match.
401 | - `(any)` - highlighter identifier which produced the match.
402 | - `(number)` - line number of the match start (starts with 1).
403 | - `(number)` - column number of the match start (starts with 1).
404 | - `(number|nil)` - line number of the match end (starts with 1).
405 | - `(number|nil)` - column number next to the match end
406 | (implements end-exclusive region; starts with 1).
407 | - `(string|nil)` - name of match's highlight group.
408 |
409 | Matches are ordered first by supplied `highlighters`, then by line and
410 | column of match start.
411 |
412 | ------------------------------------------------------------------------------
413 | *MiniHipatterns.gen_highlighter*
414 | `MiniHipatterns.gen_highlighter`
415 | Generate builtin highlighters
416 |
417 | This is a table with function elements. Call to actually get highlighter.
418 |
419 | ------------------------------------------------------------------------------
420 | *MiniHipatterns.gen_highlighter.hex_color()*
421 | `MiniHipatterns.gen_highlighter.hex_color`({opts})
422 | Highlight hex color string
423 |
424 | This will match color hex string in format `#rrggbb` and highlight it
425 | according to `opts.style` displaying matched color.
426 |
427 | Highlight group is computed using |MiniHipatterns.compute_hex_color_group()|,
428 | so all its usage notes apply here.
429 |
430 | Parameters ~
431 | {opts} `(table|nil)` Options. Possible fields:
432 | -