mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 00:20:05 +08:00
pref(terminal): improve terminal support
This commit is contained in:
parent
d5cf952778
commit
3678bf51f6
@ -434,6 +434,8 @@ function! SpaceVim#layers#core#statusline#get(...) abort
|
|||||||
\ . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#'
|
\ . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#'
|
||||||
\ . s:lsep
|
\ . s:lsep
|
||||||
\ . '%#SpaceVim_statusline_b# Terminal %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . 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', ''))
|
if !empty(get(b:, '_spacevim_shell', ''))
|
||||||
let st .= '%#SpaceVim_statusline_c# %{b:_spacevim_shell} %#SpaceVim_statusline_c_SpaceVim_statusline_z#' . s:lsep
|
let st .= '%#SpaceVim_statusline_c# %{b:_spacevim_shell} %#SpaceVim_statusline_c_SpaceVim_statusline_z#' . s:lsep
|
||||||
endif
|
endif
|
||||||
|
@ -111,6 +111,8 @@ function! s:tabname(bufnr) abort
|
|||||||
let name = bufname(a:bufnr)
|
let name = bufname(a:bufnr)
|
||||||
if name ==# '\[Vader\]'
|
if name ==# '\[Vader\]'
|
||||||
let fn = '[Vader]'
|
let fn = '[Vader]'
|
||||||
|
elseif name =~# 'term://.*'
|
||||||
|
let fn = 'Terminal'
|
||||||
else
|
else
|
||||||
let fn = fnamemodify(name, ':t')
|
let fn = fnamemodify(name, ':t')
|
||||||
endif
|
endif
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
let s:SYSTEM = SpaceVim#api#import('system')
|
let s:SYSTEM = SpaceVim#api#import('system')
|
||||||
let s:FLOAT = SpaceVim#api#import('neovim#floating')
|
let s:FLOAT = SpaceVim#api#import('neovim#floating')
|
||||||
|
let s:WIN = SpaceVim#api#import('vim#window')
|
||||||
|
|
||||||
function! SpaceVim#layers#shell#plugins() abort
|
function! SpaceVim#layers#shell#plugins() abort
|
||||||
let plugins = []
|
let plugins = []
|
||||||
@ -43,20 +44,20 @@ function! SpaceVim#layers#shell#config() abort
|
|||||||
\ . string(function('s:open_default_shell')) . ', [0])',
|
\ . string(function('s:open_default_shell')) . ', [0])',
|
||||||
\ ['open-shell',
|
\ ['open-shell',
|
||||||
\ [
|
\ [
|
||||||
\ "[SPC '] is to open or jump to default shell window",
|
\ "[SPC '] is to open or jump to default shell window",
|
||||||
\ '',
|
\ '',
|
||||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||||
\ ]
|
\ ]
|
||||||
\ ], 1)
|
\ ], 1)
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ["\""], 'call call('
|
call SpaceVim#mapping#space#def('nnoremap', ["\""], 'call call('
|
||||||
\ . string(function('s:open_default_shell')) . ', [1])',
|
\ . string(function('s:open_default_shell')) . ', [1])',
|
||||||
\ ['open-shell-in-buffer-dir',
|
\ ['open-shell-in-buffer-dir',
|
||||||
\ [
|
\ [
|
||||||
\ "[SPC \"] is to open or jump to default shell window with the current file's pwd",
|
\ "[SPC \"] is to open or jump to default shell window with the current file's pwd",
|
||||||
\ '',
|
\ '',
|
||||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||||
\ ]
|
\ ]
|
||||||
\ ], 1)
|
\ ], 1)
|
||||||
|
|
||||||
if has('nvim') || exists(':tnoremap') == 2
|
if has('nvim') || exists(':tnoremap') == 2
|
||||||
exe 'tnoremap <silent><C-Right> <C-\><C-n>:<C-u>wincmd l<CR>'
|
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
|
augroup spacevim_layer_shell
|
||||||
au!
|
au!
|
||||||
au WinEnter,BufWinEnter term://* startinsert
|
au WinEnter,BufWinEnter term://* startinsert
|
||||||
|
au TermOpen * call s:on_term_open()
|
||||||
if has('timers')
|
if has('timers')
|
||||||
au TermClose * let g:_spacevim_termclose_abuf = expand('<abuf>') | call timer_start(5, 'SpaceVim#mapping#close_term_buffer')
|
au TermClose * let g:_spacevim_termclose_abuf = expand('<abuf>') | call timer_start(5, 'SpaceVim#mapping#close_term_buffer')
|
||||||
else
|
else
|
||||||
@ -88,6 +90,12 @@ function! SpaceVim#layers#shell#config() abort
|
|||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! s:on_term_open() abort
|
||||||
|
startinsert
|
||||||
|
let &l:statusline = SpaceVim#layers#core#statusline#get(1)
|
||||||
|
endfunction
|
||||||
|
|
||||||
" FIXME:
|
" FIXME:
|
||||||
func! SpaceVim#layers#shell#terminal() abort
|
func! SpaceVim#layers#shell#terminal() abort
|
||||||
let line = getline('.')
|
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')
|
if s:default_position ==# 'float' && exists('*nvim_open_win')
|
||||||
let s:term_win_id = s:FLOAT.open_win(bufnr('%'), v:true,
|
let s:term_win_id = s:FLOAT.open_win(bufnr('%'), v:true,
|
||||||
\ {
|
\ {
|
||||||
\ 'relative': 'editor',
|
\ 'relative': 'editor',
|
||||||
\ 'width' : &columns,
|
\ 'width' : &columns,
|
||||||
\ 'height' : &lines * s:default_height / 100,
|
\ 'height' : &lines * s:default_height / 100,
|
||||||
\ 'row': 0,
|
\ 'row': 0,
|
||||||
\ 'col': &lines - (&lines * s:default_height / 100) - 2
|
\ 'col': &lines - (&lines * s:default_height / 100) - 2
|
||||||
\ })
|
\ })
|
||||||
|
|
||||||
exe win_id2win(s:term_win_id) . 'wincmd w'
|
exe win_id2win(s:term_win_id) . 'wincmd w'
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user