Skip to content

Commit

Permalink
perf(shell): add center-float position
Browse files Browse the repository at this point in the history
  • Loading branch information
wsdjeg committed Jul 27, 2024
1 parent 26e7f66 commit 28c3ff6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions autoload/SpaceVim/layers/shell.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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' ?
Expand Down
2 changes: 1 addition & 1 deletion docs/cn/layers/shell.md
Original file line number Diff line number Diff line change
Expand Up @@ -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。

Expand Down
2 changes: 1 addition & 1 deletion docs/layers/shell.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit 28c3ff6

Please sign in to comment.