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

Get number of currently visible context lines #242

Closed
JulesNP opened this issue Apr 21, 2023 · 6 comments
Closed

Get number of currently visible context lines #242

JulesNP opened this issue Apr 21, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@JulesNP
Copy link

JulesNP commented Apr 21, 2023

Is there currently a way to programmatically obtain the number of visible treesitter-context lines?

For context, in my Neovim config I currently have an auto-command which only enables 'scrolloff' when the cursor is on the top half of the screen, ideally I'd like to also dynamically change the number of 'scrolloff' lines based on how many treesitter-context lines are visible:

vim.api.nvim_create_autocmd("CursorMoved", {
    group = vim.api.nvim_create_augroup("ToggleScrolloff", { clear = true }),
    pattern = "*",
    callback = function()
        if vim.fn.winline() * 2 >= vim.api.nvim_win_get_height(0) then
            vim.o.scrolloff = 0
        else
            vim.o.scrolloff = 5 -- Would replace this with number of currently visible treesitter-context lines
        end
    end,
})
@lewis6991 lewis6991 added the enhancement New feature or request label Aug 27, 2023
@RaafatTurki
Copy link

any update on this?

this number is easily obtainable by doing vim.api.nvim_get_height(context_winid) if context_winid is accesible

I suggest making it and gutter_winid a part of the render.lua exported module such as

M.context_winid
M.gutter_winid

@lewis6991
Copy link
Member

No updates. This is not planned.

@lewis6991 lewis6991 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 11, 2023
@RaafatTurki
Copy link

ahaa, would a PR be welcomed?

@lewis6991
Copy link
Member

No. I do not wish to support and maintain exposing windows IDs in the API.

@RaafatTurki
Copy link

Understandable, I've mentioned exposing the winid to easily make all win related info accessible.

How about the more specific approach mentioned in the issue title, being able to know the geometry of the ctx window is crucial in making it play nice w other plugins.

@bassamsdata
Copy link

highlighting the important of a solution—other plugins occupy the upper space, particularly the tree-sitter-context area, preventing content relocation below.
z-index isn't an option since the two contents need to remain together.

just to note that i'm providing this context without pushing the request.
check the image below for a clearer view of our current situation.
Screenshot 2023-12-04 at 2 24 56 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants