2
2
3
3
A tiny Neovim plugin that adds subtle animations to various operations.
4
4
5
+ ** Do not forget to enable animations on operations you want to animate ! A lot of operations are disabled by default.**
6
+
5
7
![ Neovim version] ( https://img.shields.io/badge/Neovim-0.10+-blueviolet.svg )
6
8
![ License] ( https://img.shields.io/badge/license-MIT-blue.svg )
7
9
@@ -21,19 +23,22 @@ https://github.com/user-attachments/assets/6bc98a8f-8b7e-4b57-958a-74ad5372612f
21
23
22
24
### Undo/Redo support
23
25
![ tiny_glimmer_demo_undo_redo] ( https://github.com/user-attachments/assets/6e980884-b425-42d2-a179-6c6126196bd5 )
26
+ - Smooth animations for various operations:
27
+ - Yank and paste
28
+ - Search navigation
29
+ - Undo/redo operations
30
+ - Custom operations support
31
+
32
+ Built-in animation styles:
33
+ - ` fade ` : Smooth fade in/out transition
34
+ - ` reverse_fade ` : Reverse fade effect with outBack easing
35
+ - ` bounce ` : Bouncing highlight effect
36
+ - ` left_to_right ` : Linear left-to-right sweep
37
+ - ` pulse ` : Pulsating highlight
38
+ - ` rainbow ` : Rainbow color transition
39
+ - ` custom ` : Define your own animation logic
24
40
25
41
26
-
27
- - Smooth animations for yank operations
28
- - Multiple animation styles:
29
- - ` fade ` : Simple fade in/out effect
30
- - ` reverse_fade ` : Reverse fade in/out effect
31
- - ` bounce ` : Bouncing transition
32
- - ` left_to_right ` : Linear left-to-right animation
33
- - ` pulse ` : Pulsating highlight effect
34
- - ` rainbow ` : Rainbow transition
35
- - ` custom ` : Custom animation that you can define
36
-
37
42
## 📋 Requirements
38
43
39
44
- Neovim >= 0.10
@@ -71,13 +76,13 @@ require('tiny-glimmer').setup({
71
76
-- Disable this if you wants to debug highlighting issues
72
77
disable_warnings = true ,
73
78
74
- refresh_interval_ms = 6 ,
79
+ refresh_interval_ms = 8 ,
75
80
76
81
overwrite = {
77
82
-- Automatically map keys to overwrite operations
78
83
-- If set to false, you will need to call the API functions to trigger the animations
79
84
-- WARN: You should disable this if you have already mapped these keys
80
- -- or if you want to use the API functions to trigger the animations
85
+ -- or if you want to use the API functions to trigger the animations
81
86
auto_map = true ,
82
87
83
88
-- For search and paste, you can easily modify the animation to suit your needs
@@ -97,14 +102,18 @@ require('tiny-glimmer').setup({
97
102
--
98
103
-- All "mapping" can be set in 2 ways:
99
104
-- 1. A string with the key you want to map
100
- -- Example:
101
- -- paste_mapping = "p"
105
+ -- Example:
106
+ -- paste_mapping = "p"
102
107
-- 2. A table with the key you want to map and its actions
103
- -- Example:
104
- -- paste_mapping = {
105
- -- lhs = "p"
106
- -- rhs = "<Plug>(YankyPutAfter)"
107
- -- }
108
+ -- Example:
109
+ -- paste_mapping = {
110
+ -- lhs = "p"
111
+ -- rhs = "<Plug>(YankyPutAfter)"
112
+ -- }
113
+ yank = {
114
+ enabled = true ,
115
+ default_animation = " fade" ,
116
+ },
108
117
search = {
109
118
enabled = false ,
110
119
default_animation = " pulse" ,
@@ -115,12 +124,8 @@ require('tiny-glimmer').setup({
115
124
-- Keys to navigate to the previous match
116
125
prev_mapping = " Nzzzv" ,
117
126
},
118
- yank = {
119
- enabled = true ,
120
- default_animation = " fade" ,
121
- },
122
127
paste = {
123
- enabled = false ,
128
+ enabled = true ,
124
129
default_animation = " reverse_fade" ,
125
130
126
131
-- Keys to paste
@@ -162,7 +167,6 @@ require('tiny-glimmer').setup({
162
167
},
163
168
},
164
169
165
-
166
170
support = {
167
171
-- Enable support for gbprod/substitute.nvim
168
172
-- You can use it like so:
@@ -180,7 +184,6 @@ require('tiny-glimmer').setup({
180
184
},
181
185
},
182
186
183
-
184
187
-- Animations for other operations
185
188
presets = {
186
189
-- Enable animation on cursorline when an event in `on_events` is triggered
@@ -205,41 +208,57 @@ require('tiny-glimmer').setup({
205
208
-- Only use if you have a transparent background
206
209
-- It will override the highlight group background color for `to_color` in all animations
207
210
transparency_color = nil ,
211
+ -- Animation configurations
208
212
animations = {
209
213
fade = {
210
214
max_duration = 400 ,
211
215
min_duration = 300 ,
212
216
easing = " outQuad" ,
213
217
chars_for_max_duration = 10 ,
218
+ from_color = " Visual" , -- Highlight group or hex color
219
+ to_color = " Normal" , -- Same as above
214
220
},
215
221
reverse_fade = {
216
222
max_duration = 380 ,
217
223
min_duration = 300 ,
218
224
easing = " outBack" ,
219
225
chars_for_max_duration = 10 ,
226
+ from_color = " Visual" ,
227
+ to_color = " Normal" ,
220
228
},
221
229
bounce = {
222
230
max_duration = 500 ,
223
231
min_duration = 400 ,
224
232
chars_for_max_duration = 20 ,
225
233
oscillation_count = 1 ,
234
+ from_color = " Visual" ,
235
+ to_color = " Normal" ,
226
236
},
227
237
left_to_right = {
228
238
max_duration = 350 ,
229
239
min_duration = 350 ,
230
240
min_progress = 0.85 ,
231
241
chars_for_max_duration = 25 ,
232
242
lingering_time = 50 ,
243
+ from_color = " Visual" ,
244
+ to_color = " Normal" ,
233
245
},
234
246
pulse = {
235
247
max_duration = 600 ,
236
248
min_duration = 400 ,
237
249
chars_for_max_duration = 15 ,
238
250
pulse_count = 2 ,
239
251
intensity = 1.2 ,
252
+ from_color = " Visual" ,
253
+ to_color = " Normal" ,
254
+ },
255
+ rainbow = {
256
+ max_duration = 600 ,
257
+ min_duration = 350 ,
258
+ chars_for_max_duration = 20 ,
240
259
},
241
260
242
- -- You can add as many animations as you want
261
+ -- You can add as many animations as you want
243
262
custom = {
244
263
-- You can also add as many custom options as you want
245
264
-- Only `max_duration` and `chars_for_max_duration` is required
@@ -351,25 +370,14 @@ Each animation type has its own configuration options:
351
370
352
371
- ` :TinyGlimmer enable ` - Enable animations
353
372
- ` :TinyGlimmer disable ` - Disable animations
354
- - ` :TinyGlimmer fade ` - Switch to fade animation
355
- - ` :TinyGlimmer reverse_fade ` - Switch to reverse fade animation
356
- - ` :TinyGlimmer bounce ` - Switch to bounce animation
357
- - ` :TinyGlimmer left_to_right ` - Switch to left-to-right animation
358
- - ` :TinyGlimmer pulse ` - Switch to pulse animation
359
- - ` :TinyGlimmer rainbow ` - Switch to rainbow animation
360
- - ` :TinyGlimmer custom ` - Switch to your custom animation
373
+ - ` :TinyGlimmer <animation> ` - Switch animation style
374
+ - Supported: fade, reverse_fade, bounce, left_to_right, pulse, rainbow, custom
361
375
362
376
## 🛠️ API
363
-
364
377
``` lua
365
- -- Enable animations
366
- require (' tiny-glimmer' ).enable ()
367
-
368
- -- Disable animations
369
- require (' tiny-glimmer' ).disable ()
370
-
371
- -- Toggle animations
372
- require (' tiny-glimmer' ).toggle ()
378
+ require (' tiny-glimmer' ).enable () -- Enable animations
379
+ require (' tiny-glimmer' ).disable () -- Disable animations
380
+ require (' tiny-glimmer' ).toggle () -- Toggle animations
373
381
374
382
--- Change highlight
375
383
--- @param animation_name string | string[] The animation name. Can be a string or a table of strings.
@@ -391,66 +399,24 @@ require('tiny-glimmer').search_under_cursor() -- Same as `*`
391
399
-- When overwrite.paste.enabled is true
392
400
require (' tiny-glimmer' ).paste () -- Same as `p`
393
401
require (' tiny-glimmer' ).Paste () -- Same as `P`
394
- ```
395
402
396
- ### Keymaps
397
- > [ !INFO]
398
- > If you have ` overwrite.auto_map ` set to ` true ` , you don't need to set these keymaps.
399
-
400
- Configuration example with overwrites enabled:
401
- ``` lua
402
- {
403
- " rachartier/tiny-glimmer.nvim" ,
404
- event = " VeryLazy" ,
405
- keys = {
406
- {
407
- " n" ,
408
- function ()
409
- require (" tiny-glimmer" ).search_next ()
410
- end ,
411
- { noremap = true , silent = true },
412
- },
413
- {
414
- " N" ,
415
- function ()
416
- require (" tiny-glimmer" ).search_prev ()
417
- end ,
418
- { noremap = true , silent = true },
419
- },
420
- {
421
- " p" ,
422
- function ()
423
- require (" tiny-glimmer" ).paste ()
424
- end ,
425
- { noremap = true , silent = true },
426
- },
427
- {
428
- " P" ,
429
- function ()
430
- require (" tiny-glimmer" ).Paste ()
431
- end ,
432
- { noremap = true , silent = true },
433
- },
434
- {
435
- " *" ,
436
- function ()
437
- require (" tiny-glimmer" ).search_under_cursor ()
438
- end ,
439
- { noremap = true , silent = true },
440
- }
441
- },
442
- opts = {},
443
- }
403
+ -- Undo operations (requires undo.enabled = true)
404
+ require (' tiny-glimmer' ).undo () -- Undo changes
405
+ require (' tiny-glimmer' ).redo () -- Redo changes
444
406
```
407
+
445
408
## ❓FAQ
446
409
447
410
### Why is there two animations playing at the same time?
448
411
You should disable your own ` TextYankPost ` autocmd that calls ` vim.highlight.on_yank `
449
412
413
+ ### Transparent background issues?
414
+ Set the ` transparency_color ` option to your desired background color.
450
415
451
416
## Thanks
452
417
453
- - [ EmmanuelOga/easing] ( https://github.com/EmmanuelOga ) for the easing functions
418
+ - [ EmmanuelOga/easing] ( https://github.com/EmmanuelOga ) - Easing function implementations
419
+ - [ tzachar/highlight-undo.nvim] ( https://github.com/tzachar/highlight-undo.nvim ) - Inspiration for hijack function
454
420
455
421
## 📝 License
456
422
0 commit comments