fix: restore user control over treesitter in preview (#367)#508
Open
gustav-fff wants to merge 1 commit into
Open
fix: restore user control over treesitter in preview (#367)#508gustav-fff wants to merge 1 commit into
gustav-fff wants to merge 1 commit into
Conversation
Refs #367 PR #335 forced treesitter start in preview buffers, removing user control. Users rely on ftplugin scripts to conditionally start treesitter based on file size / parser performance. With forced vim.treesitter.start, large files or slow parsers lag UI. Fix: restore filetype setting without forced treesitter. Buffer already protected via buftype=nofile. Plugins should check buftype in ftplugin (standard neovim practice, see fugitive, telescope). Misbehaving plugins need upstream fix, not fff forcing highlighting off. Changed: - Removed attach_preview_highlighter() function (22 lines) - Restored direct filetype setting at 4 call sites - Clear buffer now explicit treesitter stop + filetype/syntax reset Automated triage via gustav-fff bot.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #367
Root cause
PR #335 introduced
attach_preview_highlighter()which unconditionally callsvim.treesitter.start(bufnr, lang)at lua/fff/file_picker/preview.lua:24. Users lost control over treesitter highlighting in preview buffers. Before #335, setting filetype triggered ftplugin events where users conditionally started treesitter based on file size/parser performance. After #335, treesitter forced on regardless, causing UI lag with slow parsers or large files.Fix
Removed
attach_preview_highlighter()function (22 lines). Restored direct filetype setting without forced treesitter start at 4 call sites (lines 274, 532, 651, 838). Buffer already protected viabuftype=nofile. Plugins must checkbuftypein ftplugin to avoid loading in scratch buffers (standard neovim practice per:h filetype). Misbehaving plugins (like Merlin from #335) should be fixed upstream to checkbuftype, not worked around by forcing highlighting off in fff.Steps to reproduce
Pre-fix (current main):
Create test ftplugin to observe treesitter control:
Start neovim in test directory with lua files:
cd /path/to/repo/with/lua/files nvimOpen fff picker on a large lua file (>500 lines):
Expected (user ftplugin controls treesitter): "Skipping treesitter for large file" message, no treesitter highlighting in preview.
Actual (on main): Treesitter highlighting applied regardless, ftplugin message never fires. Preview lags on large file.
Post-fix (this PR):
Repeat steps. Expected behavior: ftplugin runs, "Skipping treesitter" fires, no lag on large file preview.
How verified
make test: 213 Rust unit tests pass, 23 Lua tests pass, 52 bun tests pass. Core functionality preserved.cargo clippy --workspace --features zlob -- -D warnings: clean, no warnings.vim.bo.filetypepopulated), butvim.treesitter.startno longer forced. User ftplugin scripts now control treesitter activation.Automated triage via gustav-fff bot.