From 28c3ff61930700f66e6865179cfade5dc78b5d1f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 27 Jul 2024 15:00:32 +0800 Subject: [PATCH] perf(shell): add `center-float` position --- autoload/SpaceVim/layers/shell.vim | 14 ++++++++++++++ docs/cn/layers/shell.md | 2 +- docs/layers/shell.md | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/autoload/SpaceVim/layers/shell.vim b/autoload/SpaceVim/layers/shell.vim index 1def30724..00858990b 100644 --- a/autoload/SpaceVim/layers/shell.vim +++ b/autoload/SpaceVim/layers/shell.vim @@ -200,6 +200,20 @@ function! s:open_default_shell(open_with_file_cwd) abort \ }) exe win_id2win(s:term_win_id) . 'wincmd w' + elseif s:default_position ==# 'center-float' && exists('*nvim_open_win') + let s:term_win_id = nvim_open_win(bufnr('%'), v:true, + \ { + \ 'relative': 'editor', + \ 'width' : &columns - 10, + \ 'height' : &lines - 10, + \ 'row': 5, + \ 'border' : 'single', + \ 'col': 5 + \ }) + + exe win_id2win(s:term_win_id) . 'wincmd w' + + call nvim_set_option_value('winhighlight', 'NormalFloat:Normal,FloatBorder:WinSeparator', { 'win' : s:term_win_id}) else " no terminal window found. Open a new window let cmd = s:default_position ==# 'float' ? diff --git a/docs/cn/layers/shell.md b/docs/cn/layers/shell.md index 5cbb5b493..2d92b3831 100644 --- a/docs/cn/layers/shell.md +++ b/docs/cn/layers/shell.md @@ -44,7 +44,7 @@ The default shell is quickly accessible via a the default shortcut key `SPC '`. ### 设置终端打开位置及高度 在启用该模块时,可以通过 `default_position` 这一模块选项来指定终端打开的位置, -目前可以选的值为:`top`, `bottom`, `left`, `right`, `float` or `full`,默认的值为 `top`。 +目前可以选的值为:`top`, `bottom`, `left`, `right`, `float`, `center-float` or `full`,默认的值为 `top`。 同时,可以通过 `default_height` 这一模块选项指定终端打开的高度,默认值为 30。 diff --git a/docs/layers/shell.md b/docs/layers/shell.md index c834a44b6..9e8afefdf 100644 --- a/docs/layers/shell.md +++ b/docs/layers/shell.md @@ -46,7 +46,7 @@ The default shell is quickly accessible via a the default shortcut key `SPC '`. ### Default shell position and height It is possible to choose where the shell should pop up by setting the -variable `default_position` to either `top`, `bottom`, `left`, `right`, `float` +variable `default_position` to either `top`, `bottom`, `left`, `right`, `float`, `center-float` or `full`. Default value is `top`. It is also possible to set the default height in percents with the variable `default_height`. Default value is 30.