diff --git a/autoload/SpaceVim/layers/core/statusline.vim b/autoload/SpaceVim/layers/core/statusline.vim index 2a2691f8f..75460bccf 100644 --- a/autoload/SpaceVim/layers/core/statusline.vim +++ b/autoload/SpaceVim/layers/core/statusline.vim @@ -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 diff --git a/autoload/SpaceVim/layers/core/tabline.vim b/autoload/SpaceVim/layers/core/tabline.vim index d8f6e647b..c661ac4d2 100644 --- a/autoload/SpaceVim/layers/core/tabline.vim +++ b/autoload/SpaceVim/layers/core/tabline.vim @@ -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 diff --git a/autoload/SpaceVim/layers/shell.vim b/autoload/SpaceVim/layers/shell.vim index 1a996049c..897dc3d9f 100644 --- a/autoload/SpaceVim/layers/shell.vim +++ b/autoload/SpaceVim/layers/shell.vim @@ -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 :wincmd l' @@ -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('') | 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