[mini.files] configurability of max lines shown in file preview #1695
Replies: 2 comments 3 replies
-
Hi!
To answer this specific question first. The README of all modules has the following info: "All contributions (issues, pull requests, discussions, etc.) are done inside of 'mini.nvim'." To answer about adding At the moment I don't think it is a hugely useful config to have. And as 'mini.files' already has quite complex config and significant module size, it is very unlikely it will be added to 'mini.files'. I'd assume that the primary use case of this is to limit the window height. For this, there is a way to customize each of window's config by following the structure of this example. The only problem here is to determine if the window is for the preview buffer. The |
Beta Was this translation helpful? Give feedback.
-
Resolving #1455 (which I moved up the TODO list after this question/suggestion, by the way) gives information about the path displayed in the buffer in the buffer's name itself. Here is a more or less reliable way to implement "read more lines for file previews to be able to scroll them with mouse on rare occasion": vim.api.nvim_create_autocmd('User', {
pattern = 'MiniFilesBufferUpdate',
callback = function(args)
-- Compute path and proceed if it is for the file preview
local buf_id = args.data.buf_id
local path = vim.api.nvim_buf_get_name(buf_id):match('^minifiles://%d+/(.*)$')
-- NOTE: it might be good to also check if the path is for text buffer,
-- but that is left as homework (there is approach in 'mini.files' code).
if path == nil or vim.fn.isdirectory(path) == 1 then return end
-- Ensure more file content to allow scrolling with mouse
local has_lines, read_res = pcall(vim.fn.readfile, path, '', 10 * vim.o.lines)
-- - Make sure that lines don't contain '\n' (might happen in binary files).
local lines = has_lines and vim.split(table.concat(read_res, '\n'), '\n') or {}
vim.api.nvim_buf_set_lines(buf_id, 0, -1, false, lines)
end,
}) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey, thanks for
mini.nvim
. It has truly sped up my workflow!I've forked
mini.files
and added an option to configure max lines of file preview. However, I'm unable to make a PR tomini.files
repo as a non-collaborator.Is there a way I can do it?
Beta Was this translation helpful? Give feedback.
All reactions