175
175
--- window's buffer already showing notifications). It should have the same
176
176
--- structure as in |nvim_open_win()|. It has the following default values
177
177
--- which show notifications in the upper right corner with upper limit on width:
178
- --- - `width` is chosen to fit buffer content but not more than 38.2% of 'columns'.
178
+ --- - `width` is chosen to fit buffer content but at most `window.max_width_share`
179
+ --- share of 'columns'.
179
180
--- To have higher maximum width, use function in `config.window` which computes
180
181
--- dimensions inside of it (based on buffer content).
181
182
--- - `height` is chosen to fit buffer content with enabled 'wrap' (assuming
184
185
--- - `border` is "single".
185
186
--- - `zindex` is 999 to be as much on top as reasonably possible.
186
187
---
188
+ --- `window.max_width_share` defines maximum window width as a share of 'columns'.
189
+ --- Should be a number between 0 (not included) and 1.
190
+ --- Default: 0.382.
191
+ ---
187
192
--- `window.winblend` defines 'winblend' value for notification window.
188
193
--- Default: 25.
189
194
MiniNotify .config = {
@@ -212,6 +217,9 @@ MiniNotify.config = {
212
217
-- Floating window config
213
218
config = {},
214
219
220
+ -- Maximum window width as share (between 0 and 1) of available columns
221
+ max_width_share = 0.382 ,
222
+
215
223
-- Value of 'winblend' option
216
224
winblend = 25 ,
217
225
},
@@ -553,6 +561,7 @@ H.setup_config = function(config)
553
561
[' lsp_progress.enable' ] = { config .lsp_progress .enable , ' boolean' },
554
562
[' lsp_progress.duration_last' ] = { config .lsp_progress .duration_last , ' number' },
555
563
[' window.config' ] = { config .window .config , is_table_or_callable , ' table or callable' },
564
+ [' window.max_width_share' ] = { config .window .max_width_share , ' number' },
556
565
[' window.winblend' ] = { config .window .winblend , ' number' },
557
566
})
558
567
@@ -692,7 +701,7 @@ H.buffer_refresh = function(buf_id, notif_arr)
692
701
end
693
702
end
694
703
695
- H .buffer_default_dimensions = function (buf_id )
704
+ H .buffer_default_dimensions = function (buf_id , max_width_share )
696
705
local line_widths = vim .tbl_map (vim .fn .strdisplaywidth , vim .api .nvim_buf_get_lines (buf_id , 0 , - 1 , true ))
697
706
698
707
-- Compute width so as to fit all lines
@@ -701,7 +710,9 @@ H.buffer_default_dimensions = function(buf_id)
701
710
width = math.max (width , l_w )
702
711
end
703
712
-- - Limit from above for better visuals
704
- width = math.min (width , math.floor (0.382 * vim .o .columns ))
713
+ max_width_share = math.min (math.max (max_width_share , 0 ), 1 )
714
+ local max_width = math.max (math.floor (max_width_share * vim .o .columns ), 1 )
715
+ width = math.min (width , max_width )
705
716
706
717
-- Compute height based on the width so as to fit all lines with 'wrap' on
707
718
local height = 0
@@ -734,14 +745,15 @@ H.window_compute_config = function(buf_id, is_for_open)
734
745
local max_height = vim .o .lines - vim .o .cmdheight - (has_tabline and 1 or 0 ) - (has_statusline and 1 or 0 )
735
746
local max_width = vim .o .columns
736
747
748
+ local config_win = H .get_config ().window
737
749
local default_config = { relative = ' editor' , style = ' minimal' , noautocmd = is_for_open , zindex = 999 }
738
750
default_config .anchor , default_config .col , default_config .row = ' NE' , vim .o .columns , has_tabline and 1 or 0
739
- default_config .width , default_config .height = H .buffer_default_dimensions (buf_id )
751
+ default_config .width , default_config .height = H .buffer_default_dimensions (buf_id , config_win . max_width_share )
740
752
default_config .border = ' single'
741
753
-- Don't allow focus to not disrupt window navigation
742
754
default_config .focusable = false
743
755
744
- local win_config = H . get_config (). window .config
756
+ local win_config = config_win .config
745
757
if vim .is_callable (win_config ) then win_config = win_config (buf_id ) end
746
758
local config = vim .tbl_deep_extend (' force' , default_config , win_config or {})
747
759
0 commit comments