Skip to content

Commit be44376

Browse files
authored
Merge branch 'skywind3000:master' into master
2 parents 941ce80 + f3e8f78 commit be44376

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,13 @@ Available options:
254254
| g:navigator_max_height | max_height | `20` | maximum horizontal window height |
255255
| g:navigator_min_height | min_height | `5` | minimal horizontal window height |
256256
| g:navigator_max_width | max_width | `60` | maxmum vertical window width |
257-
| g:navigator_max_width | max_width | `20` | minimal vertical window width |
257+
| g:navigator_min_width | min_width | `20` | minimal vertical window width |
258258
| g:navigator_popup | popup | `0` | set to 1 to use popup or floatwin if available |
259259
| g:navigator_popup_position | popup_position | `'bottom'` | can be set to `'bottom'`, `'top'`, and `'center'` |
260260
| g:navigator_popup_width | popup_width | `'60%'` | centered popup window width |
261-
| g:navigator_popup_height | popup_height | `'40%'` | centered popup window height |
261+
| g:navigator_popup_height | popup_height | `'20%'` | centered popup window height |
262262
| g:navigator_popup_border | popup_border | `1` | centered popup window border, set to 0 for borderless window, and 2-4 for unicode border |
263-
| g:navigator_char_display | popup_border | `{}` | change display char like `{'<bar>': '\|', '<bslash>': '\'}` |
263+
| g:navigator_char_display | char_display | `{}` | change display char like `{'<bar>': '\|', '<bslash>': '\'}` |
264264

265265
Global options can be directly defined like:
266266

@@ -275,8 +275,8 @@ let g:my_keymap.config = {
275275
\ 'icon_separator': '→',
276276
\ 'popup': 1,
277277
\ 'popup_position': 'center',
278-
\ 'popup_width': 40,
279-
\ 'popup_height': 5,
278+
\ 'popup_width': '60%',
279+
\ 'popup_height': '20%',
280280
\ }
281281
```
282282

autoload/navigator/config.vim

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,26 @@ function! navigator#config#init(opts) abort
332332
endif
333333
endif
334334
endif
335+
let opts.min_width = navigator#config#get(opts, 'min_width')
336+
let opts.max_width = navigator#config#get(opts, 'max_width')
337+
let opts.min_height = navigator#config#get(opts, 'min_height')
338+
let opts.max_height = navigator#config#get(opts, 'max_height')
339+
let opts.min_width = navigator#config#atoi(opts.min_width, &columns)
340+
let opts.max_width = navigator#config#atoi(opts.max_width, &columns)
341+
let opts.min_height = navigator#config#atoi(opts.min_height, &lines)
342+
let opts.max_height = navigator#config#atoi(opts.max_height, &lines)
343+
if opts.min_width > opts.max_width
344+
let opts.min_width = opts.max_width
345+
endif
346+
if opts.min_height > opts.max_height
347+
let opts.min_height = opts.max_height
348+
endif
349+
if opts.popup_position == 'center' && opts.popup != 0
350+
let opts.min_width = opts.popup_width
351+
let opts.max_width = opts.popup_width
352+
let opts.min_height = opts.popup_height
353+
let opts.max_height = opts.popup_height
354+
endif
335355
return opts
336356
endfunc
337357

autoload/navigator/layout.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ function! s:layout_horizon(ctx, opts) abort
4040
endif
4141
let min_height = navigator#config#get(a:opts, 'min_height')
4242
let max_height = navigator#config#get(a:opts, 'max_height')
43+
if min_height > max_height
44+
let min_height = max_height
45+
endif
4346
let ypad = padding[1] + padding[3]
4447
let min_height -= ypad
4548
let max_height -= ypad
@@ -79,6 +82,9 @@ function! s:layout_vertical(ctx, opts) abort
7982
let ctx.pg_size = ctx.pg_height
8083
let min_width = navigator#config#get(a:opts, 'min_width')
8184
let max_width = navigator#config#get(a:opts, 'max_width')
85+
if min_width > max_width
86+
let min_width = max_width
87+
endif
8288
let ctx.cx = (ctx.cx < min_width)? min_width : ctx.cx
8389
let ctx.cx = (ctx.cx > max_width)? max_width : ctx.cx
8490
let ctx.pages = []

0 commit comments

Comments
 (0)