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

feat: add option to show the context with the **folded** current buffer #374

Closed
wants to merge 2 commits into from

Conversation

atusy
Copy link

@atusy atusy commented Dec 25, 2023

By using the folded current buffer, the content (including extmark!) is automatically synced among the edit window and the context window.

This allows label-based motion plugins (e.g., nvim-treehopper, flash.nvim, treemonkey.nvim) to show the label on the context without hacks.
See example below.

2023-12-25 21-10-06 mkv

@lewis6991
Copy link
Member

Sorry this isn't something I want to support, at least in this way.

@lewis6991 lewis6991 closed this Dec 25, 2023
@atusy
Copy link
Author

atusy commented Dec 25, 2023

hmmm... alright...

@lewis6991
Copy link
Member

lewis6991 commented Dec 25, 2023

Looking at this a bit more closely, I think a similar implementation that I'd be more open to would be to create a separate window per context and setting the bufnr as you've done here. Then as you've pointed out this would sync all the extmarks.

I'm not a fan of any of the fold stuff, at least for now.

If neovim/neovim#20750 gets merged, we could leverage that here so we only need one floating window.

@atusy
Copy link
Author

atusy commented Dec 26, 2023

Thank you for the comments.

If neovim/neovim#20750 gets merged, we could leverage that here so we only need one floating window.

This sounds good.
For now, I get context from treesitter-context directly from my plugin, and explicitly adds extmarks.

https://github.com/atusy/treemonkey.nvim/blob/4226ea69f6b84673eafdfe0ce5f1eafb1d648a1f/lua/treemonkey.lua?plain=1#L92-L104

Just to add a context, I liked the folding because users have oppotunity to customize foldtext.
For example, we can show context line like local function foo(a, b) from the following buffer.

local function foo(
  a,
  b
)
  local res = {a, b}  -- window's topline at here
  return res  -- cursor at here
end

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.

2 participants