1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-13 02:05:40 +08:00

Add float terminal windows support (#3377)

This commit is contained in:
Wang Shidong 2020-02-24 18:18:53 +08:00 committed by GitHub
parent 77f8392f86
commit 64b2199683
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 9 deletions

View File

@ -23,6 +23,7 @@
" <
let s:SYSTEM = SpaceVim#api#import('system')
let s:FLOAT = SpaceVim#api#import('neovim#floating')
function! SpaceVim#layers#shell#plugins() abort
let plugins = []
@ -122,7 +123,7 @@ endfunction
function! SpaceVim#layers#shell#get_options() abort
return ['default_shell', 'default_position', 'default_height']
return ['default_shell', 'default_position', 'default_height',]
endfunction
@ -169,12 +170,25 @@ function! s:open_default_shell(open_with_file_cwd) abort
\ 'botright split' :
\ s:default_position ==# 'right' ?
\ 'rightbelow vsplit' : 'leftabove vsplit'
exe cmd
let w:shell_layer_win = 1
let lines = &lines * s:default_height / 100
if lines < winheight(0) && (s:default_position ==# 'top' || s:default_position ==# 'bottom')
exe 'resize ' . lines
if s:default_position == 'float'
let s:term_win_id = s:FLOAT.open_win(bufnr('%'), v:true,
\ {
\ 'relative': 'editor',
\ 'width' : &columns,
\ 'height' : &lines * s:default_height / 100,
\ 'row': 0,
\ 'col': &lines - (&lines * s:default_height / 100) - 2
\ })
exe win_id2win(s:term_win_id) . 'wincmd w'
else
exe cmd
let lines = &lines * s:default_height / 100
if lines < winheight(0) && (s:default_position ==# 'top' || s:default_position ==# 'bottom')
exe 'resize ' . lines
endif
endif
let w:shell_layer_win = 1
for open_terminal in s:open_terminals_buffers
if bufexists(open_terminal)
if getbufvar(open_terminal, '_spacevim_shell_cwd') ==# l:path

View File

@ -44,7 +44,7 @@ The default shell is quickly accessible via a the default shortcut key `SPC '`.
### 设置终端打开位置及高度
在启用该模块时,可以通过 `default_position` 这一模块选项来指定终端打开的位置,
目前可以选的值为:`top`, `bottom`, `left`, `right`, or `full`,默认的值为 `top`
目前可以选的值为:`top`, `bottom`, `left`, `right`, `float` or `full`,默认的值为 `top`
同时,可以通过 `default_height` 这一模块选项指定终端打开的高度,默认值为 30。

View File

@ -13,6 +13,7 @@ description: "This layer provide shell support in SpaceVim"
- [Default shell](#default-shell)
- [Default shell position and height](#default-shell-position-and-height)
- [Key bindings](#key-bindings)
- [Additional key bindings on Windows](#additional-key-bindings-on-windows)
<!-- vim-markdown-toc -->
@ -45,8 +46,8 @@ 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`, or
`full`. Default value is `top`. It is also possible to set the default height
variable `default_position` to either `top`, `bottom`, `left`, `right`, `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.
```toml