declancm / cinnamon.nvim Goto Github PK
View Code? Open in Web Editor NEWSmooth scrolling for ANY command ๐คฏ. A Neovim plugin written in Lua!
License: MIT License
Smooth scrolling for ANY command ๐คฏ. A Neovim plugin written in Lua!
License: MIT License
Hey! I've been playing around with the plugin and it feels really nice and snappy, thanks!
One problem I have is that if the scrolling happens over a large number of lines, then the animation can take quite a while to finish. For example, with a default_delay
of 3ms, it looks fine when scrolling with <C-d>
or similar, but using gg
or other methods to go 100 lines downwards takes quite a while. 0.5ms or 1ms feels like a better number for such cases.
But it's not really possible to configure "if scrolling is over 20 lines, use 3ms, if over 90, use 0.5ms, etc.".
I'm thinking that a solution might be to have a "total delay" so that I could say that the total scrolling time should be 60ms and then the plugin would calculate the per-line delay automatically. Also, it could even skip scrolling every other line in some extreme cases (although I'm not sure how smooth that would look like ๐). With such a solution, we might be able to set the scroll_limit
to a very high number and still have snappy scrolling (or even not have a limit at all).
What do you think of such an idea?
I found this in init.lua
utils.create_keymap({ 'n', 'x' }, 'gg', "<Cmd>lua Scroll('gg', 0, 0, 5)<CR>")
utils.create_keymap({ 'n', 'x' }, 'G', "<Cmd>lua Scroll('G', 0, 1, 5)<CR>")
Is it possible for gg and G to use default delay like others?
Hi, is it possible to get smooth scroll also for gj
and gk
?
The following MWE works:
local root = vim.fn.fnamemodify("./.repro", ":p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)
local plugins = {
{
'declancm/cinnamon.nvim',
opts = {}
}
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
vim.keymap.set('n', 'j', [[<Cmd>lua Scroll("j", 1, 1)<CR>]])
vim.keymap.set('n', 'k', [[<Cmd>lua Scroll("k", 1, 1)<CR>]])
vim.keymap.set('n', 'gj', [[<Cmd>lua Scroll("gj", 1, 1)<CR>]])
vim.keymap.set('n', 'gk', [[<Cmd>lua Scroll("gk", 1, 1)<CR>]])
However, while j
and k
work fine, gj
and gk
are very slow on larger lines (or lines with inlay hints)
Hi, I've noticed some artifacts when enabling scroll with "j" and "k", often a second cursor blinks somewhere near the text. See the video. Whenever i disable the scroll the behavior goes away.
Tried to see if there's a pattern, my guess is something related to the virtual text. When inlay hints are disabled, the blinking goes away.
Also, when going up into virtual text the cursor scrolls the text in order to reach the real text, I'm not sure if it's intended but reporting it in case it's related to the previous bug.
Let me know if i can provide more information.
Hi. I have encountered a weird issue where cinnamon will not scroll if I am on the top 2 lines and the bottom 2 lines.
If I go to the topmost line on my screen and try <Page-up>
it would instead just send my cursor to the 2nd line and not scroll.
Is this intended? Or am I doing something wrong?
My setup is
require("cinnamon").setup({
extra_keymaps = true,
default_delay = 15,
scroll_limit = 150
})
First of all, thank you for a very cool plugin! I tried other similar plugins, but none of them can map j and k effectively, which I use a lot (I map J = 10j
and K = 10k
for vertical movement instead of <C-d
and <C-u
).
So far, so good. Just one thing I feel a bit "missing" is the ability to scroll through folds (and still smooth!). Currently, it feels slow and sticky when going through folds. I would really appreciate it if this issue could be solved.
Thanks again, and have a good day ๐
Using extra_keymaps
works fine when using gg
to go to the top of the file and using 300G
to go to line 300. However, I am used to use 300gg
to jump to line 300. With cinnamon and extra_keymaps
the cursor is moved to the first line instead.
using neovim version v0.10.0
I don't have trouble with that, I just want to say that!!!
Thank you for doing that, hh :)
Need to move from using 'j' and 'k' for line movement during the scroll animation to 'gj' and 'gk' and change some of the logic. This will improve scroll animations on wrapped text
Hi, thanks for the plugin it's really awesome!
I was migrating my config to the new one, and i love my commands centered, i've read the docs and replicated the half page up/down, but i can't make it work.
this is my current config:
{
"declancm/cinnamon.nvim",
config = function()
require("cinnamon").setup {
keymaps = { extra = true }, -- Enable the 'extra' keymaps
}
local scroll = require("cinnamon").scroll
-- Centered scrolling:
vim.keymap.set("n", "<C-U>", scroll("<C-U>zz", {}))
vim.keymap.set("n", "<C-D>", scroll "<C-D>zz")
end,
}
But i get this error:
Tried wrapping the function in function () ... end, the error goes away but the scrolling isn't centered.
If i can bring any additional information let me know :)
First of all this plugin is amazing really love this. Now the problem is that I would like the plugin when scrolling with n, N in the search results to print the number of results and what number of results I am in, for example 17/36
Is there a setting / function to toggle the smooth scrolling? I would like to toggle the smooth scrolling on my need. Thank's!
When I use muren on a lengthy file in a global scope for example, it keeps scrolling from top down on every keystroke
So I know cinnamon scrolls with [count]G, but is it possible to have it scroll with relative line jumps as well, i.e. [count]j or [count]k?
I was also curious if it is possible to integrate cinnamon with a plugin like Leap (https://github.com/ggandor/leap.nvim)
Leap is always activated (like Sneak) with 's', 'S', 'gs', and 'gS'. And then you can hop around the page. Is there a way to integrate a plugin like this to have smooth scrolling from cinnamon?
Thanks.
Hi,
So I want to preface this by saying that I realise that I can remap the mouse scroll wheel commands, and I've been doing that for years with various smooth scroll plugins.
So why does this need a different solution?
<c-u>
and <c-d>
are too aggressive for a touch bad where depending on how much force you use you could end up scrolling a huge amount which was unintended.<c-e>
and <c-y>
are too small and adding a count helps slightly, but currently in this plugins once you hit the top or bottom plus/minus the scroll off the cursor line begins to jitter wildly.mousescroll
option and use that to control how much scrolling happens?There might be other ways to handle this, but I wonder if a dedicated command might not give a better result. One that can be sufficiently granular for mouse scrolling? Perhaps not, I have never properly looked into this sort of thing so no idea what's possible.
Hi, thanks for such great plugin!
{
default_keymaps = true,
extra_keymaps = true,
extended_keymaps = true,
always_scroll = true,
scroll_limit = 64,
}
I don't want my jump list to collect all the 'n' motions, so this is what i had in Vim:
nnoremap n :execute "keepjumps norm! " . v:count1 . "nzz"
nnoremap N :execute "keepjumps norm! " . v:count1 . "Nzz"
Would be nice to control which motions in this plugin are or are not passed to the jumplist.
Nice plugin ๐
It would be perfect if you could add the functionality for the cursor to hide when scrolling. This would make the scrolling experience more enjoyable.
Hi,
I've noticed when using hide_cursor = true
that my cursor is hidden but, it is never put back when the scrolling is completed. I faced a similar issue using neoscroll
a while back which the author eventually fix so, cribbing that solution might be applicable here.
Thanks for the awesome plugin! One small issue, I use cmdheight=0
and when pressing C-d/u, statusline and lualine flashes which is impossible to not see. Hoping there's a solution, thanks.
Hello,
Thanks for this great plugin !
Sill, how can we use a count before a command ? (ex: 42G
goes right at the bottom even if there are more than 42 lines, where G is mapped this way: keymap('n', 'G', "<Cmd>lua Cinnamon.Scroll('G', 0, 0, 3)<CR>", opts)
)
Regards.
I have noticed that these less mainstream jumps do not smooth scroll when called with Scroll
it seems to happen with any call to Scroll(). I would visit a long file and hold down the key (ctrl d/u) in my case. Sometimes I would reach the end of the file, but I could get it crashing every time.
below are my plugin setup options using lazy.nvim:
{
'declancm/cinnamon.nvim',
opts = {
default_delay = 1,
extra_keymaps = true,
},
},
This would help with integration with other plugins, for example hlslens.nvim
.
after upgrade nvim 0.9.5 -> 0.10
the pagedown is working, but pageup is not working correctly
Hi.
First I have to say thank you for your plugin.
I saw an issue last time I wanted to select a code block in visual block mode without the prepend whitespace. If in cinnamon the extra_keymaps
are set to true
, it's not possible to select to end of the line by pressing $
. With extra_keymaps
set to false
, the text are selected as expected.
To understand what i mean, see the two screenrecordings:
Without extra keymaps:
With extra keymaps:
As you can see, it's not possible to select the text up to the end of the line if extra_keymaps
are enabled. I hope you can fix this.
Thank you again.
calling the setup function in /plugin
seems not really useful to me.
Users should call the setup function.
Normally this wouldn't be a big deal but in this case it creates keymaps before I call the setup function where I disable default keymaps.
When I have only one window open moves smooth and is responsive, but once I open a window splitted vertically the cursor slow down a lot.
This is my configuration:
require("cinnamon").setup({
-- KEYMAPS:
default_keymaps = true, -- Create default keymaps.
extra_keymaps = true, -- Create extra keymaps.
extended_keymaps = true, -- Create extended keymaps.
override_keymaps = false, -- The plugin keymaps will override any existing keymaps.
-- OPTIONS:
always_scroll = true, -- Scroll the cursor even when the window hasn't scrolled.
centered = false, -- Keep cursor centered in window when using window scrolling.
default_delay = 10, -- The default delay (in ms) between each line when scrolling.
hide_cursor = false, -- Hide the cursor while scrolling. Requires enabling termguicolors!
horizontal_scroll = true, -- Enable smooth horizontal scrolling when view shifts left or right.
max_length = 200, -- Maximum length (in ms) of a command. The line delay will be
-- re-calculated. Setting to -1 will disable this option.
scroll_limit = 100, -- Max number of lines moved before scrolling is skipped. Setting
-- to -1 will disable this option.
})
This bug occurs with any types of buffer, even empty ones.
Please add an example in the readme so people can see how it looks after installint and configure this plugin
Good day to you!
is it possible to do window horizontal scrolling?
Thank you!
For example, the file is very long, and with this plugin enabled, press 'G' will trigger animated scrolling and bring view to the bottom, which is very nice.
I wonder if it would stop the scrolling once I press a key like <ESC>
, so i can stop at somewhere, so I don't have to keep pressing <C-d>
or 'j' to scroll to a place.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.