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

exclude_func for users to discern when the scrollbar renders #9

Closed
wants to merge 1 commit into from

Conversation

levouh
Copy link

@levouh levouh commented Jan 7, 2022

There might be some issues here with the fact that we are using the current window/buffer (#8 and #6) so leaving this as a draft for now as fixes might need to come before this.

Closes #7

@levouh levouh marked this pull request as draft January 7, 2022 15:03
@levouh
Copy link
Author

levouh commented Jan 7, 2022

This is a little bit confusing (at least as I think about it) to have a function that returns "if the scrollbar should not be drawn". Perhaps it would be a better idea to have the option mirror the name of the function; just should_render which returns true to draw the window and false to not.

@tbung
Copy link
Contributor

tbung commented Jan 7, 2022

I think exclude_func works well with exclude_filetype and exclude_buftype, but if it is named like that it should probably return false by default, because it does not exclude, it should then be switched in should_render.

@petertriho
Copy link
Owner

I'm not sure if it'll be better/worse but something like render_callback, and just a bare return if we don't want to render could work as well

@levouh
Copy link
Author

levouh commented Jan 8, 2022

I assume you mean passing a function that the user can just call if they want to draw the scrollbar @petertriho? I changed it to return whether or not the scrollbar should be drawn, rather than the double negative that existed before that makes it a bit confusing.

@petertriho
Copy link
Owner

petertriho commented Jan 8, 2022

What I mean is something like

M.render = function()
       vim.api.nvim_buf_clear_namespace(0, NAMESPACE, 0, -1)
       config.render_callback(config)

		.... etc
end

config.render_callback = function()
       if vim.tbl_contains(config.excluded_filetypes, vim.bo.filetype) then
            return
       end
end

But the currently discussed should_render way works too. Might be easier/cleaner with the should_render so we can implement both excluded_filestypes and included_filestypes (probably should change these to exclude_filetypes, include_filestypes, exclude_buftypes and include_buftypes

@levouh
Copy link
Author

levouh commented Jan 9, 2022

I actually think the implementation to show/hide this works in the same manner as @tbung mentioned. I can just set show = false and then setup autocommands to show the scrollbar when I want it shown.

Let me know if you still want to add something like this and I can take a stab at doing it here.

@levouh levouh closed this Jan 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature request] Add function to allow custom ignoring from the user
3 participants