Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No vertical compression #195

Open
fontanf opened this issue Feb 10, 2024 · 3 comments
Open

No vertical compression #195

fontanf opened this issue Feb 10, 2024 · 3 comments

Comments

@fontanf
Copy link

fontanf commented Feb 10, 2024

Hi,

Is it possible to have an option to disable vertical compression in the minimap? That would mean that the minimap would show 4 times more lines that the ones on the screen instead of the whole file.

@ZNielsen
Copy link
Collaborator

That sounds doable, but there are definitely some assumptions that would need to be turned into settings. I think code-minimap would be able to output the proper text by changing the vertical compression argument. Then we might need an autocmd to take care of automatically scrolling the minimal window to keep the section of the file we are in on screen.

This isn't something I have a personal interest in adding, so I'll leave it to you. I'm more than happy to provide some help if you need it though.

@fontanf
Copy link
Author

fontanf commented Feb 11, 2024

Thanks for the quick answer and for the indications. Indeed, if I set vscale to 1 here, I can get the minimap without vertical compression, but it's not well synchronized with the buffer. I'm not familiar with vim plugin writing, so I would be thankful if you have some additional leads to fix this. Otherwise, I'll continue investigating on my end

@ZNielsen
Copy link
Collaborator

Probably the best way to do this would be to hook into the existing autocmd functions that handle when the viewport into the buffer changes (window enter, window scroll, etc. ex: source_win_scroll()) and calculate what percent down the buffer the window is, then center the minimap buffer/window at that percentage. Actually if the scaling is 1:1 you may not even need to calculate percentage; just syncing up which line number of the buffer is at the top of the window might do the trick (divide by 4, or whatever the compression in the minimap ends up being).

Some vim functions that look useful:

  • line('w0') - first line visible in current window
  • setpos() - put the cursor somewhere

vim's built in :help will get you the details for those functions (e.g. :help setpos)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants