@@ -182,8 +182,8 @@ local handle_file_preview = function(filepath, bufnr, stat, opts)
182182 end
183183 end
184184
185+ local mb_filesize = stat .size / bytes_to_megabytes
185186 if opts .preview .filesize_limit then
186- local mb_filesize = math.floor (stat .size / bytes_to_megabytes )
187187 if mb_filesize > opts .preview .filesize_limit then
188188 if type (opts .preview .filesize_hook ) == " function" then
189189 opts .preview .filesize_hook (filepath , bufnr , opts )
@@ -228,7 +228,10 @@ local handle_file_preview = function(filepath, bufnr, stat, opts)
228228 if opts .callback then
229229 opts .callback (bufnr )
230230 end
231- putils .highlighter (bufnr , opts .ft , opts )
231+
232+ if not (opts .preview .highlight_limit and mb_filesize > opts .preview .highlight_limit ) then
233+ putils .highlighter (bufnr , opts .ft , opts )
234+ end
232235 else
233236 if type (opts .preview .timeout_hook ) == " function" then
234237 opts .preview .timeout_hook (filepath , bufnr , opts )
@@ -243,12 +246,14 @@ end
243246
244247local PREVIEW_TIMEOUT_MS = 250
245248local PREVIEW_FILESIZE_MB = 25
249+ local PREVIEW_HIGHLIGHT_MB = 1
246250
247251previewers .file_maker = function (filepath , bufnr , opts )
248252 opts = vim .F .if_nil (opts , {})
249253 opts .preview = vim .F .if_nil (opts .preview , {})
250254 opts .preview .timeout = vim .F .if_nil (opts .preview .timeout , PREVIEW_TIMEOUT_MS )
251255 opts .preview .filesize_limit = vim .F .if_nil (opts .preview .filesize_limit , PREVIEW_FILESIZE_MB )
256+ opts .preview .highlight_limit = vim .F .if_nil (opts .preview .highlight_limit , PREVIEW_HIGHLIGHT_MB )
252257 opts .preview .msg_bg_fillchar = vim .F .if_nil (opts .preview .msg_bg_fillchar , " ╱" )
253258 opts .preview .treesitter = vim .F .if_nil (opts .preview .treesitter , true )
254259 if opts .use_ft_detect == nil then
0 commit comments