1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 13:10:04 +08:00

pref(terminal): improve terminal support

This commit is contained in:
wsdjeg 2022-04-14 16:22:27 +08:00
parent d5cf952778
commit 3678bf51f6
3 changed files with 28 additions and 16 deletions

View File

@ -434,6 +434,8 @@ function! SpaceVim#layers#core#statusline#get(...) abort
\ . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#'
\ . s:lsep
\ . '%#SpaceVim_statusline_b# Terminal %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep
\ . '%#SpaceVim_statusline_c# '
\ . matchstr(bufname(), '\d\+:\zs.*')
if !empty(get(b:, '_spacevim_shell', ''))
let st .= '%#SpaceVim_statusline_c# %{b:_spacevim_shell} %#SpaceVim_statusline_c_SpaceVim_statusline_z#' . s:lsep
endif

View File

@ -111,6 +111,8 @@ function! s:tabname(bufnr) abort
let name = bufname(a:bufnr)
if name ==# '\[Vader\]'
let fn = '[Vader]'
elseif name =~# 'term://.*'
let fn = 'Terminal'
else
let fn = fnamemodify(name, ':t')
endif

View File

@ -26,6 +26,7 @@
let s:SYSTEM = SpaceVim#api#import('system')
let s:FLOAT = SpaceVim#api#import('neovim#floating')
let s:WIN = SpaceVim#api#import('vim#window')
function! SpaceVim#layers#shell#plugins() abort
let plugins = []
@ -43,20 +44,20 @@ function! SpaceVim#layers#shell#config() abort
\ . string(function('s:open_default_shell')) . ', [0])',
\ ['open-shell',
\ [
\ "[SPC '] is to open or jump to default shell window",
\ '',
\ 'Definition: ' . s:file . ':' . s:lnum,
\ ]
\ ], 1)
\ "[SPC '] is to open or jump to default shell window",
\ '',
\ 'Definition: ' . s:file . ':' . s:lnum,
\ ]
\ ], 1)
call SpaceVim#mapping#space#def('nnoremap', ["\""], 'call call('
\ . string(function('s:open_default_shell')) . ', [1])',
\ ['open-shell-in-buffer-dir',
\ [
\ "[SPC \"] is to open or jump to default shell window with the current file's pwd",
\ '',
\ 'Definition: ' . s:file . ':' . s:lnum,
\ ]
\ ], 1)
\ "[SPC \"] is to open or jump to default shell window with the current file's pwd",
\ '',
\ 'Definition: ' . s:file . ':' . s:lnum,
\ ]
\ ], 1)
if has('nvim') || exists(':tnoremap') == 2
exe 'tnoremap <silent><C-Right> <C-\><C-n>:<C-u>wincmd l<CR>'
@ -78,6 +79,7 @@ function! SpaceVim#layers#shell#config() abort
augroup spacevim_layer_shell
au!
au WinEnter,BufWinEnter term://* startinsert
au TermOpen * call s:on_term_open()
if has('timers')
au TermClose * let g:_spacevim_termclose_abuf = expand('<abuf>') | call timer_start(5, 'SpaceVim#mapping#close_term_buffer')
else
@ -88,6 +90,12 @@ function! SpaceVim#layers#shell#config() abort
endfunction
function! s:on_term_open() abort
startinsert
let &l:statusline = SpaceVim#layers#core#statusline#get(1)
endfunction
" FIXME:
func! SpaceVim#layers#shell#terminal() abort
let line = getline('.')
@ -179,12 +187,12 @@ function! s:open_default_shell(open_with_file_cwd) abort
if s:default_position ==# 'float' && exists('*nvim_open_win')
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
\ })
\ '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