Closed ntyunyayev closed 6 months ago
Hi, Nikita!
Thanks for using 'mini.files'!
I was wondering if adding an option to automatically display line numbers for mini.files buffers was possible. I believe that it would make navigation easier.
It is already possible. Customizing windows is expected to be done inside dedicated events. Here is an example from help page. Note that 'number' window option is a bit special (it is disabled on every window update due to 'minimal'
style of floating windows), so it should be set in every MiniFilesWindowUpdate
event and not MiniFilesWindowOpen
.
Here is an example of full working config:
require('mini.files').setup()
vim.api.nvim_create_autocmd('User', {
pattern = 'MiniFilesWindowUpdate',
callback = function(args) vim.wo[args.data.win_id].number = true end,
})
Thank you very much for your quick answer. I tried to play around with the events, but it had some behavior I did not understand: line numbers were not always displayed.
There seem to be similar issues with your solution on my setup. Going to the child directory ("l") works pretty well, but the line number is not always shown, especially when the terminal running nvim is not in full screen. Going to the parent directory ("h") does not work: the line numbers are not shown on new buffers. They are only shown once I reach the root directory. At this point, all the buffers are updated with the line number.
Adding
vim.api.nvim_create_autocmd('User', {
pattern = 'MiniFilesWindowUpdate',
callback = function(args) vim.wo.number = true end,
})
Solves some of the issues when going to the parent directory, but in both cases, when the screen is too small to fit all the buffers, the line numbers are not always shown when navigating with h/l.
I tried with both stable and main, and I observed the same behavior.
Adding ... Solves some of the issues when going to the parent directory, but in both cases, when the screen is too small to fit all the buffers, the line numbers are not always shown when navigating with h/l.
That autocommand should be added in order to display line numbers.
However, I can indeed reproduce the issue with it not always being set. Apparently, there are cases when MiniFilesWindowUpdate
is not triggered but should. I'll look into it.
Thank you :)
This should be now resolved on latest main
branch.
The reason for this was quite technical: MiniFilesWindowUpdate
event was triggered before window got its target buffer assigned to it. Which was not good, so thanks for inadvertently finding this!
As 'number' is a window-local option (which are notoriously convoluted as to how they work), it got overridden after buffer was assigned to the window. But now (when event gets triggered after window gets its buffer) setup from this comment seems to work for me completely.
Thank you again for taking the time to fix it. You are very quick :d. Indeed, it works perfectly with your suggestion :)
Contributing guidelines
Module(s)
mini.files
Description
Hi,
Thank you for your work. I just started using mini.files, and I am loving it. I was wondering if adding an option to automatically display line numbers for mini.files buffers was possible. I believe that it would make navigation easier.
Best regards,
Nikita