[Regression] fff.nvim forces preview highlighting
I don't think this is a good change.
Reason: This forces preview highlighting on the user. Neovim's philosophy allows the user to configure syntax highlighting on ftplugin events. For example, I may want to conditionally enable tree-sitter highlighting depending on the file size in languages with slow parsers or inefficient queries. With tree-sitter highlighting enabled unconditionally, preview scratch buffers can really slow down the UI.
Before this change, fff.nvim already set all the right properties to prevent side-effects like starting LSP clients.
If this is about lazy-loading plugins:
See :h lua-plugin-lazy.
If a plugin is misbehaving in a scratch buffer because it emits a filetype event, that should be fixed in the plugin (e.g. it can check the buftype property).
There is nothing in :h filetype that states that scratch/preview buffers cannot have a filetype. Another example of buffers that have filetypes are fugitive.vim diffs.
Originally posted by @mrcjkb in https://github.com/dmtrKovalenko/fff.nvim/issues/335#issuecomment-4228354689
Solution: Revert #335 and fix the misbehaving plugin instead.
Did you fact any prsctical problem. What do you mean “forces highlighting”
Did you fact any prsctical problem. What do you mean “forces highlighting”
The change in #335 automatically calls vim.treesitter.start.
I now have no way to disable tree-sitter based syntax highlighting in the preview buffers.
Yes, I have faced practical problems with slow parsers/inefficient queries (or highlighting in large files) significantly lagging the UI, which is why I rely on ftplugin scripts to conditionally call vim.treesitter.start.
[triage-bot] REPRODUCED:
Reproduced on origin/main. Branch: triage-bot/issue-367.
PR #335 unconditionally calls vim.treesitter.start(bufnr, lang) in attach_preview_highlighter() (lua/fff/file_picker/preview.lua:24). Removes user control over treesitter highlighting in preview buffers. Users rely on ftplugin scripts to conditionally start treesitter based on file size / parser performance.
Before #335: setting filetype triggered ftplugin event, user controlled treesitter start. After #335: treesitter forced on, ignoring user ftplugin logic. Causes UI lag with slow parsers/large files.
Revert approach: restore filetype setting without forced treesitter start. Buffer already protected via buftype=nofile. Plugins should check buftype in ftplugin (standard practice, see fugitive.vim, telescope). Misbehaving plugins need fix upstream, not fff forcing highlighting off.
Working on fix on triage-bot/issue-367.
Closing this as I no longer use fff.nvim. If it bothers someone else, they can re-open :).
Edit: Oh, nvm I thought gustav-fff was an external contributor.