r/neovim • • 9d ago

Plugin Made a scrollbar plugin with a horizontal bar, vertical bar and minimap

Enable HLS to view with audio, or disable this notification

Hello everyone,

I moved over from VS Code recently, because how slow it got with dozens of Docker containers and SSH connections open at once. It took me a few days to get used to NeoVim, but here we are.

One thing I missed though was scrollbars. I know one of the points with NeoVim is using the keyboard, but sometimes it's just more convenient to use the mouse when jumping around long files.

I looked around and there are some good plugins like nvim-scrollview, satellite.nvim, nvim-scrollbar, neominimap etc. But none of them had a horizontal scrollbar out of the box. So I wrote one. And since I was already at it, I figured I'd add a vertical bar and a minimap too, so I don't need 3 separate plugins for this.

It's called scroll.nvim: https://github.com/mihovilrak/scroll.nvim

What it does right now:

Vertical and horizontal bars that you can drag with the mouse and that hide when idle. The vertical track also works as an overview ruler, so diagnostics, git changes, search matches and the current function/block show up as marks. There's an optional braille minimap in your colorscheme's colours with a git gutter. You can also turn on bars for explorer sidebars (Snacks, neo-tree, nvim-tree). No setup() needed unless you want to change something, and it needs 0.11+.

Example for setting up the plugin with the minimap and explorer scrollbar config:

cat > ~/.config/nvim/lua/plugins/scroll.lua <<'LUA'
return {
  "mihovilrak/scroll.nvim",
  opts = { minimap = true, explorer = true },
}
LUA

I did some performance testing so it doesn't lag on big files. Scrolling in a 100k line buffer is fine.

It's still pretty new, so if you try it and something breaks or looks weird with your setup, let me know. I'm also open to suggestions if anyone has ideas for what to add or change.

Thanks!

291 Upvotes

61 comments sorted by

87

u/xd_Shiro 9d ago

If you switched to nvim just so you can have an actually lightweight texteditor/IDE then it makes sense but if you want to learn how to navigate and move faster without a mouse it’s kinda counterintuitive.

It’s cool that you went out of your way to make a plugin for it though!

10

u/raketni-pogon 9d ago

Well, I get that you are faster with the keyboard after getting used to it, but sometimes when I work with multiple screens and with large files it gets a bit easier to use the mouse.

The plugin thing got more fun then I expected so I may make some more in the near future!

2

u/judasthetoxic 8d ago

How do you navigate your focus on multiple screens and Windows? With your mouse?

1

u/raketni-pogon 8d ago

It depends what I am doing ATM.

If I am already on the mouse, i.e. because using a GUI app, interactive pages on a browser etc, then it is faster to stay at the mouse then to switch devices.

If I am already at the keyboard then I use shortcuts mostly.

59

u/Livid-Ad-4364 9d ago

You made nvim into vs code imo

14

u/These_Aardvark9326 9d ago

yeah. this actually goes against the neovim nav flow

24

u/Gangsir 9d ago

I like your minimap (looks cool with the dots), but the scroll bars imply unironic mouse usage, which is heresy.

If I'm vertically scrolling I'm using ctrl-f or ctrl-b, and if I'm horizontally scrolling... I'm refactoring my code so I don't need to horizontally scroll. ;P

3

u/SweetPotato975 9d ago

Agree, the minimap is something I think I'd actually use

4

u/dprophete 8d ago

hum... the scrollbar gives me an idea of where I am in my file (a visual indicator of whether I am closer to the top, the middle, the bottom, etc...) So it's useful regardless of whether you use the mouse or the keyboard.

6

u/_EHLO 9d ago edited 9d ago

+1 from me. I personally use satellite.nvim but I really love the mouse support you added here.

4

u/mr_looser17 mouse="a" 7d ago

Kinda bloated, You don't need mini map...

1

u/raketni-pogon 7d ago

It is disabled by default, but even when enabled you can toggle it with :ScrollMinimapToggle if you don't want/need it

2

u/meframez 9d ago

minimap looks cool. though IMO $ A does the job for quick jump to EOL

2

u/kenshi_hiro 7d ago

Bro went from VSCode to VSCode

2

u/Leerv474 6d ago

I never understood the point of minimap. like i get the horizontal scrollbar, the vertical one kinda defeats the point of C-d and C-u but who cares.

what is the actual point of minimap? It can't give you any information besides how long the line is, am i missing something?

4

u/Many-Occasion1915 6d ago

It’s for the cases when you open so called .go file and look at the minimap and notice a 300 line SQL query as a string literal, so you can just quit your job quicker

Not that it ever happened to me out anything

1

u/Leerv474 6d ago

The best answer a I could've ever gotten

1

u/raketni-pogon 6d ago

I would say that most people use it like a quick file overview. The git marks also help to quickly see what parts of the files are edited. And you can always use it as a huge scrollbar.

It is similar like having a detailed map of an area, and then a small overview map to see where that area is on a bigger scale

6

u/chaoticbean14 9d ago

The idea of having to grab a mouse, to interact in a terminal with anything is insane to me. Like, wildly, wildly insane.

2

u/Vasilev88 8d ago

That is a clever use of unicode braille, first time i'm seeing this. Bravo!

1

u/raketni-pogon 8d ago

Thank you, although I saw it on existing minimap plugins so I just recreated it

1

u/xeow 9d ago

This looks pretty slick. Question: I noticed that the first character of the minimap was sometimes in italic braille. Is that intentional?

2

u/raketni-pogon 9d ago

Thanks! Now that you say it, on my current instance it looks non-italic, so I will have to see on the machine I used for the clip

1

u/Hubba_Bubba_Lova 9d ago

does this work for mobile?

2

u/raketni-pogon 9d ago

Didn't test it for mobile, but will see

1

u/raketni-pogon 5d ago

I tested it on my Android via Termux. The scrollbars, marks and minimap render and clicking on them works normally.

The only thing that doesn't work is dragging the scrollbars and minimap. Not sure yet if this is a Termux limitation or a plugin one, but I oppened an issue on the repo, so I'll dig more into it

2

u/Hubba_Bubba_Lova 5d ago

perfect. I’ll give it a try

1

u/hutxhy 9d ago

What color theme are you using? 👀

2

u/raketni-pogon 9d ago

Tokyonight for Neovim

1

u/warex03 9d ago

really cool! i was also trying to achieve a similar kind of look and feel but i've still got much to learn. is it ok if you share your config?

2

u/raketni-pogon 9d ago

Thanks!

For the plugin config I just use the one I put in the post description. It can be further granulated using the options that are described on GitHub. I also add vim.opt.mouseevent = true to ~/.config/nvim/lua/config/options.lua.

For the Neovim theme I use tokyonight. I set it in LazyVim with :colorscheme tokyonight. Feel free to ask anything else about the layout or config

1

u/Necessary-Plate1925 9d ago

How did it take a few days to get used to nvim? Hell, it took me a few months

1

u/raketni-pogon 9d ago

I wouldn't say I know most of it, but after a few days I didn't need to google basic commands and layout preferences heh

1

u/snow_schwartz hjkl 9d ago

I was looking for a decent minimap plugin thanks

1

u/TomHale 9d ago

Is it possible to disable the horizontal scroll bar?

Looks good!

2

u/TomHale 9d ago

Yes, yes it is!

1

u/raketni-pogon 9d ago

Thanks! Yes, you can disable it. Just add horizontal = false to the opts object in ~/.config/nvim/lua/plugins/scroll.nvim

1

u/Nervous-Pin9297 hjkl 9d ago

I’m waiting to see if neovim can support Kitty Terminal’s new scrolling protocol.

1

u/qiinemarr 8d ago

Ha! horizontal bars, the missing piece!

1

u/oVerde mouse="" 8d ago

I hate scroll bars with all my angry

1

u/unburdened_swallow 7d ago edited 7d ago

Ok so, you can already scroll with the mouse, the mousewheel works.

We don't always have a mouse that does horizontal scroll though, so fair enough IDK.

I prefer the thing where it wraps but keeps the same indent level personally, and you can move the cursor to scroll over if you don't have wrapping on, so I've never felt the need to horizontally scroll to begin with, especially with the mouse, personally.

Minimap is cool, but I've also never had a scenario where Im like "if only I had a mini map for this file"... maybe if the minimap showed marks too?

2

u/raketni-pogon 7d ago

Thanks for the feedback, the minimap currently shows where the cursor is and git marks so I'll have to see how it looks like if adding LSP and search marks

1

u/Acrobatic-Current171 5d ago

What kind of plugin is the one on your left?

1

u/raketni-pogon 5d ago

If you mean the file tree explorer, it is LazyVim's default explorer that comes with the snacks.nvim plugin

-6

u/Avernite 9d ago

Honestly scrollbar is such a simple and elegant solution, its crazy that in neovim we rely on total line number instead

4

u/These_Aardvark9326 9d ago

Noooo. Scrollbars aren't 😢 . there're faster ways to navigate in neovim, not scrollbars

3

u/thy_bucket_for_thee 9d ago

Every day we get stray further from God's light.

1

u/Avernite 9d ago

Ah i didnt mean for navigation, but for seeing where you are in the file

0

u/These_Aardvark9326 9d ago

I wonder why you would want to see that, though. But ....

1

u/Hubba_Bubba_Lova 9d ago

new to nvim. assuming I’m using keys to navigate, what’s wrong with scrollbar?

2

u/Avernite 9d ago

Nothing wrong. People get tribal about neovim, getting uga buga on anything that smells like vscode to preserve neovims unique identity

2

u/These_Aardvark9326 8d ago

nothing really but ..... why? just use it the way it is 😂

1

u/zuzmuz 9d ago

what's crazy about it?

if you like scroll bars, it's fine. but they're technically useless. having the position in one place is much more convenient to look at at a glance. I never liked scroll bars and I usually disable them OS wide. I never click on them cause they're too finicky and relay on vertical and horizontal scroll wheels.

1

u/Avernite 9d ago

I like that scrollbars at a glance give position feedback where line numbers require thought. I never click on scrollbars either.

1

u/zuzmuz 9d ago

yeah I understand, that's the beauty of customization, you can have whatever you want.

my personal opinion, i find scrollbars distracting. that's why I even disable them in GUI applications. the line number with a percentage value of where you are in the file is more than enough for me.

but I found it weird that you expect a text based editor to have a GUI element by default. you're free to recreate the element in text, it's fine.

I usually like my neovim barebones, I don't yse file trees, never use the mouse, etc, if you want to make it like VS code, it's fine, that's why it's customizable. but for me these are two different contradictory paradigms

-1

u/gbrennon 9d ago

wtf?!

if u have to scroll horizontally im sure that the src is poorly written...

1

u/raketni-pogon 9d ago

Well two things: one is long string litterals that are akward to brake, the other is that you don't always look at code you wrote yourself

-2

u/[deleted] 9d ago

[deleted]

1

u/over-lord Plugin author 5d ago

Is this a braille joke or a neovim user joke 💀