Coder Social home page Coder Social logo

Comments (9)

wookayin avatar wookayin commented on May 27, 2024

Also, the position and the height of a scrollbar is determined by the actual line number (not fully aware of folding). This makes the movement of the scrollbar not uniform and very awkward (it suddenly makes a huge jump) around folded lines.

UPDATE: NVM, sorry. This is configurable as let g:scrollview_mode = 'virtual'.

from nvim-scrollview.

dstein64 avatar dstein64 commented on May 27, 2024

Thanks @wookayin!

In addition to the 'virtual' option for scrollview_mode, which you mentioned above, the 'flexible' mode also accounts for folds.

If there were autocmd events that corresponded to fold opening and closing, the plugin would be able to refresh the scrollbars when those events are triggered, but as far as I know there are no such events.

This problem is now documented under :help scrollview-issues (057ec56), along with the following proposed workaround, which could be used with zM and zR (based on your comment above):

  • Remap the problematic fold command key sequences accordingly, depending on the fold commands you use.
nnoremap <silent> zo zo:silent! ScrollViewRefresh<cr>
nnoremap <silent> zc zc:silent! ScrollViewRefresh<cr>

from nvim-scrollview.

wookayin avatar wookayin commented on May 27, 2024

Thanks. We would need an autocmd event for fold updates for this. As a side note, how about providing <Plug> mappings to make custom keymaps much easier?

from nvim-scrollview.

dstein64 avatar dstein64 commented on May 27, 2024

"As a side note, how about providing mappings to make custom keymaps much easier?"

My interpretation is that the request is so that something like:

nnoremap <silent> zM zM:silent! ScrollViewRefresh<cr>

can be replaced with:

nmap <silent> zM zM<Plug>ScrollViewRefresh

(where I changed nnoremap to nmap, since a recursive mapping is required to expand <Plug>ScrollViewRefresh)

That example would have zM on the right-hand-side, so this would presumably cause an infinite recursion, as the right-hand-side includes the left-hand-side. However, in my experiments there is no infinite recursion, for reasons that aren't clear to me (my expectation is that zM on the right-hand-side would infinitely expand, since the mapping is recursive). I didn't see anything in Vim's documentation on any special-case handling that would prevent an infinite recursion in this type of scenario (e.g., some handling to prevent expansion if the right-hand-side begins with the left-hand-side).

@wookayin, can you provide more details on the usage you are thinking of?

from nvim-scrollview.

dstein64 avatar dstein64 commented on May 27, 2024

@wookayin, I've added the following <Plug> mappings (64de102). Thanks for the idea!

Left-hand-side Right-hand-side
<Plug>(ScrollViewDisable) <cmd>ScrollViewDisable<cr>
<Plug>(ScrollViewEnable) <cmd>ScrollViewEnable<cr>
<Plug>(ScrollViewRefresh) <cmd>ScrollViewRefresh<cr>

Instead of:

nnoremap <silent> zM zM:silent! ScrollViewRefresh<cr>

it's now possible to use:

nmap zM zM<Plug>(ScrollViewRefresh)

My earlier confusion about why this doesn't result in an infinite recursion was resolved by an answer to a question I asked on vi.stackexchange.com. As documented in :help recursive_mapping, there is an exception to recursive expansion when the right-hand-side starts with the left-hand-side.

from nvim-scrollview.

wookayin avatar wookayin commented on May 27, 2024

Thank you @dstein64! That was exactly I was figuring. For now, I will need to use this keymap-based workaround to trigger the refresh command for folding-related actions.

from nvim-scrollview.

wookayin avatar wookayin commented on May 27, 2024

Upstream neovim issue for "fold" update events: neovim/neovim#8538

from nvim-scrollview.

dstein64 avatar dstein64 commented on May 27, 2024

As of 79797a0, an assortment of workarounds are automatically applied, including refreshing the scrollbars after z fold commands (currently excluding zf in normal mode). This doesn't fully address the issue, as : fold commands (e.g., :fold) and zf in normal mode could still lead to the scrollbars being out-of-sync.

The workarounds can be disabled with let g:scrollview_auto_workarounds = 0.

from nvim-scrollview.

dstein64 avatar dstein64 commented on May 27, 2024

"This doesn't fully address the issue, as : fold commands (e.g., :fold) and zf in normal mode could still lead to the scrollbars being out-of-sync."

Scrollbars are now refreshed after zf is used in normal mode.

: fold commands will still result in scrollbars temporarily out-of-sync (until the next refresh).

from nvim-scrollview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.