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

Show context of top line of window instead of cursor #77

Closed
michaelbeaumont opened this issue Nov 1, 2021 · 0 comments · Fixed by #120
Closed

Show context of top line of window instead of cursor #77

michaelbeaumont opened this issue Nov 1, 2021 · 0 comments · Fixed by #120
Labels
enhancement New feature or request

Comments

@michaelbeaumont
Copy link

While using this plugin, it occurred to me that it's actually rather counter intuitive that the context can appear and disappear depending on the cursor location.

Imagine the first two lines below are context.

func A() { // first virtual line of context
  if x { // second virtual line of context
    // there's more code in the `if x` block above not shown in the window
    // this is the end of the `if x` block
  }

  if y {
    // more code
  }
}

It doesn't really matter to me where the cursor is when I'm reading this code, I just want to see that the code at the top of the window belongs to the if x block, which belongs to func A block. The context I'm looking for is only a function of what is and isn't visible on the screen.

As is, if I move my cursor to the if y block, the if x context would disappear.

Could we add an option to just use the topmost visible line of the buffer instead of the cursor position?

lewis6991 added a commit that referenced this issue May 24, 2022
Choices:
    - 'cursor' (default): current behaviour, context is determined by
      cursor position
    - 'topline': context is determined by the top of the window

Resolves #77
@lewis6991 lewis6991 added the enhancement New feature or request label May 24, 2022
saecki pushed a commit to saecki/nvim-treesitter-context that referenced this issue Jun 9, 2022
Choices:
    - 'cursor' (default): current behaviour, context is determined by
      cursor position
    - 'topline': context is determined by the top of the window

Resolves nvim-treesitter#77
lewis6991 added a commit that referenced this issue Jun 10, 2022
Choices:
    - 'cursor' (default): current behaviour, context is determined by
      cursor position
    - 'topline': context is determined by the top of the window

Resolves #77
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

Successfully merging a pull request may close this issue.

2 participants