-
Notifications
You must be signed in to change notification settings - Fork 179
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
Feature: nvim-treesitter-context
in previewer [DONE]
#1552
Comments
To enable ```lua require("fzf-lua").setup({ previewer = { builtin = { treesitter = { context = true} } } }) ```
To enable ```lua require("fzf-lua").setup({ previewer = { builtin = { treesitter = { context = true} } } }) ```
To enable ```lua require("fzf-lua").setup({ previewer = { builtin = { treesitter = { context = true} } } }) ```
To enable ```lua require("fzf-lua").setup({ previewer = { builtin = { treesitter = { context = true} } } }) ```
To enable ```lua require("fzf-lua").setup({ previewers = { builtin = { treesitter = { context = true} } } }) ```
@xzbdmw I think I nailed it, no need to configure I couldn't figure out one thing, when first calling Add this to your setup call to enable (modifying the params of the "builtin" previewer): require("fzf-lua").setup({
previewers = { builtin = { treesitter = { context = true} } }
}) Or individually: :FzfLua live_grep previewer.treesitter.context=true Let me know what you think? |
Yes, it works for me, the reason you need some defer probably is that it is throttled(not that sure, it seems calling open() directly bypass the throttle mechanism), but schedule may not be enough, since the default throttle time is 150ms , a more reliable/hacky way is calling update() multiple times with |
I used |
Ok, I know the problem, when you call Comment out OptionSet and WinResized turned out to solve the defer hack. While attach is a local variable, it seems we have no workaround for that, using |
I tried using I didn't look explore the treesitter-context code deeply, what are the chances that a single call to I also added 2 more treesitter-context life-cycle options which IMHO are much nicer when it comes to the preview window, this makes it so there's less clutter when the context contains inner conditions and other nonsense, I believe what most users would care about is the calling function: max_lines = 1, -- How many lines the window should span. Values <= 0 mean no limit.
trim_scope = 'inner', -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer' |
If OptionSet/WinSrolled is guaranteed to triggered first, then it is scheduled to close any unattached window, after that, fzf-lua calls update, also scheduled, avoid the potential closing, there is no problem; on the flip side, if fzflua calls update() first, it will be closed by a later OptionSet/WinSrolled trigger, that's why it must be deferred by a schedule now. The order is not clear to me though. |
Perhaps we can leave one defer call with a timeout of 0 (equivalent to a single vim.schedule) and also enable this option by default - this will be the only way to get true feedback :) If the single call fails, we can restore to multiple timely delayed calls. |
Yeah, I think it can be enabled by default, maybe defer_fn(10)? The race possibility is going to decrease a lot. |
You’re probably right, although I’d still prefer to have a call with 0 delay so it appears to display instantaneously, I’ve compromised on 2 calls with delays of 0, 20ms respectively and enabled by default. |
this is a new function added a month ago,
For languages like java or rust, method lives inside |
I thought about it too, but I believe someone updating fzf-lua will also update treesitter-context.
I will make the I’m going to give this a while to collect feedback and make the changes, I’m pretty sure users will also want the toggle keybind. |
New default treesitter previewer opts: ```lua require("fzf-lua").setup({ previewers = { builtin = { treesitter = { context = { max_lines = 1, trim_scope = "inner" } } } } }) ``` Also updated README.md with optional plugin deps for markdown.
The defaults are: context = { max_lines = 1, trim_scope = "inner" } Set Can also setup temporarily in one call, e.g.: :FzfLua live_grep previewer.treesitter.context={max_lines=2,trim_scope="outer"} |
Customizable via `keymap.builtin` as action `toggle-preview-ts-ctx` Ref: #1552
c40666b added a new action Unless I'm missing something this feature is pretty much complete. |
c40666b removed the |
Unintentional, while searching for keymap in profiles (due to adding of F7) I changed the profile keymap to inherit from defaults (thus deleting all defaults), this was one a mistake. |
Thanks @ibhagwan :D |
nvim-treesitter-context
in previewernvim-treesitter-context
in previewer [DONE]
With the addition of |
Have you RTFM'd?
Feature Request
Ref: #1485, #1509
Enabled by default with the below options
Can also be set per call:
Or with
lua
:The text was updated successfully, but these errors were encountered: