I just removed my custom autocmds for a smoother version to auto-enable minimap on floating windows, since one of the floating windows I'm working with has its content covered by it.
But it's still worth sharing with people what I did before I will actually forget it.
The problem
I only want to enable minimap for floating windows so that it can work with NeoZoom.lua
the current method auto_enable = true will first show the minimap in the middle of the screen before it's moved to the right of the floating window.
the demo of problem 2. can be seen in the same demo of #62.
Solution
create the autocmds yourself with the usage of vim.schedule_wrap. (I actually tried to use it in my PR for #61, but unfortunately, I didn't find the cause/culprit line(s) of problem 2.)
expand
```lua
vim.api.nvim_create_autocmd({
'TermEnter', 'TermOpen',
'BufLeave'
}, {
group = curfile_augroup,
callback = function ()
require('codewindow').close_minimap()
end
})
vim.api.nvim_create_autocmd({ 'BufEnter' }, {
group = curfile_augroup,
callback = vim.schedule_wrap(function ()
if vim.api.nvim_win_get_config(0).relative == 'editor' then
require('codewindow').open_minimap()
end
end)
})
```
What should/could be done?
I believe problem 1. (enable only for floating windows) can be provided by an option and 2. (directly move the minimap to the right) should be the default behavior of auto_enable = true.
I just removed my custom
autocmd
s for a smoother version to auto-enable minimap on floating windows, since one of the floating windows I'm working with has its content covered by it.But it's still worth sharing with people what I did before I will actually forget it.
The problem
auto_enable = true
will first show the minimap in the middle of the screen before it's moved to the right of the floating window.the demo of problem 2. can be seen in the same demo of #62.
Solution
create the
autocmd
s yourself with the usage ofvim.schedule_wrap
. (I actually tried to use it in my PR for #61, but unfortunately, I didn't find the cause/culprit line(s) of problem 2.)expand
```lua vim.api.nvim_create_autocmd({ 'TermEnter', 'TermOpen', 'BufLeave' }, { group = curfile_augroup, callback = function () require('codewindow').close_minimap() end }) vim.api.nvim_create_autocmd({ 'BufEnter' }, { group = curfile_augroup, callback = vim.schedule_wrap(function () if vim.api.nvim_win_get_config(0).relative == 'editor' then require('codewindow').open_minimap() end end) }) ```What should/could be done?
I believe problem 1. (enable only for floating windows) can be provided by an option and 2. (directly move the minimap to the right) should be the default behavior of
auto_enable = true
.