kevinhwang91 / nvim-hlslens

Hlsearch Lens for Neovim
BSD 3-Clause "New" or "Revised" License
748 stars 10 forks source link

Option to add callback to lens instead of override_lens #22

Closed petertriho closed 2 years ago

petertriho commented 2 years ago

Is your feature request related to a problem? Please describe. Not really, but would like to make it cleaner to integrate with my own plugin.

Describe the solution you'd like I was wondering if it would be possible for you to add something like "lens_callback" (similar to override_lens) but instead of overriding, it just calls the function instead

kevinhwang91 commented 2 years ago

Do you want to get the position range after the index is built?

petertriho commented 2 years ago

Yes, that's the intention. Pretty much just want the list of positions after a search

kevinhwang91 commented 2 years ago

Please try dev branch. And add

    require('hlslens').setup({
        build_position_cb = function(plist, bufnr, changedtick, pattern)    
            require('scrollbar').search_handler.show(plist.start_pos)
        end
    })

If you have no problem, I will improve the documentation.

petertriho commented 2 years ago

Works perfectly, thank you! I'll update my docs as well when you merge it into the main branch

kevinhwang91 commented 2 years ago

Merged.

Only fire once if the index is built instead of moving the cursor, please note.

changedtick or pattern is changed, the index will refresh and fire this callback.