Isrothy / neominimap.nvim

Yet another minimap plugin for Neovim
MIT License
169 stars 3 forks source link

fix: deal with short windows and border formats #73

Closed delphinus closed 2 months ago

delphinus commented 2 months ago

1. deal with short windows

This PR fixes errors that occur when the target windows are too short to draw the minimap window with borders. For example, the height of the window is 2 and window_border is the default value: "single", it shows an error below. 1198041 fixes this.

Error executing vim.schedule lua callback: .../share/nvim/lazy/neominimap.nvim/lua/neominimap/util.lua:12: 'height' key must be a positive Integer
stack traceback:
        [C]: in function 'f'
        .../share/nvim/lazy/neominimap.nvim/lua/neominimap/util.lua:12: in function <.../share/nvim/lazy/neominimap.nvim/lua/neominimap/util.lua:9>
        ...hare/nvim/lazy/neominimap.nvim/lua/neominimap/window.lua:217: in function 'create_minimap_window'
        ...hare/nvim/lazy/neominimap.nvim/lua/neominimap/window.lua:387: in function 'refresh_minimap_window'
        ...hare/nvim/lazy/neominimap.nvim/lua/neominimap/window.lua:433: in function 'refresh_all_minimap_windows'
        ...m/lazy/neominimap.nvim/lua/neominimap/command/global.lua:19: in function <...m/lazy/neominimap.nvim/lua/neominimap/command/global.lua:16>

2. deal with rare border formats

Formats nvim_open_win accepts as border option are below.

  1. string: "single", "shadow" and so on.
  2. string[]: a table of characters
  3. [string, string][]: a table of tuples containing a character and a highlight group

2.1. string[]: a table of characters

This takes 8, 4, 2 and 1 character(s).

border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }
border = { "+", "─", "+", "│" }
border = { "+", "─" }
border = { "x" }

2.2. [string, string][]: a table of tuples containing a character and a highlight group

And each character may be a tuple.

-- This draw "x" with CurSearch highlight group.
border = { { "x", "CurSearch" } }
Isrothy commented 2 months ago

Thanks for your contribution! I appreciate the effort, but I have a different approach in mind for this feature. I’ll implement it my way, but feel free to provide any feedback or suggestions after it’s done.