Skip to content

share: A smoother version when working with floating window #63

@nyngwang

Description

@nyngwang

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

  1. I only want to enable minimap for floating windows so that it can work with NeoZoom.lua
  2. 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
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions