mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 17:40:06 +08:00
Improve shell layer
This commit is contained in:
parent
d0d1d729b2
commit
e68fb5f706
@ -5,14 +5,18 @@
|
||||
|
||||
""
|
||||
" Load the {layer} you want. For all the layers SpaceVim supports, see @section(layers).
|
||||
" the second argv is the layer variable.
|
||||
function! SpaceVim#layers#load(layer, ...) abort
|
||||
if a:layer == '-l'
|
||||
call s:list_layers()
|
||||
endif
|
||||
if index(g:spacevim_plugin_groups, a:layer) == -1
|
||||
call add(g:spacevim_plugin_groups, a:layer)
|
||||
if a:0 == 1 && type(a:1) == 4
|
||||
call SpaceVim#layers#{a:layer}#set_variable(a:1)
|
||||
endif
|
||||
if a:0 > 1
|
||||
endif
|
||||
if a:0 > 0 && type(a:1) == 1
|
||||
for l in a:000
|
||||
call SpaceVim#layers#load(l)
|
||||
endfor
|
||||
|
@ -3,6 +3,9 @@
|
||||
" @parentsection layers
|
||||
" SpaceVim uses deol.nvim for shell support in neovim and uses vimshell for
|
||||
" vim. For more info, read |deol| and |vimshell|.
|
||||
" @subsection variable
|
||||
" default_shell
|
||||
"
|
||||
|
||||
function! SpaceVim#layers#shell#plugins() abort
|
||||
let plugins = []
|
||||
@ -13,3 +16,32 @@ function! SpaceVim#layers#shell#plugins() abort
|
||||
endif
|
||||
return plugins
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#shell#config()
|
||||
|
||||
call SpaceVim#mapping#space#def('nnoremap', ["'"], 'call call('
|
||||
\ . string(function('s:open_default_shell')) . ', [])',
|
||||
\ 'open shell', 1)
|
||||
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#shell#set_variable(var)
|
||||
let s:default_shell = get(a:var, 'defaut_shell', 'terminal')
|
||||
let s:default_position = get(a:var, 'default_position', 'top')
|
||||
let s:default_height = get(a:var, 'default_height', 30)
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:open_default_shell() abort
|
||||
let cmd = s:default_position ==# 'top' ?
|
||||
\ 'topleft split' :
|
||||
\ s:default_position ==# 'bottom' ?
|
||||
\ 'botright split' :
|
||||
\ s:default_position ==# 'right' ?
|
||||
\ 'rightbelow vsplit' : 'leftabove vsplit'
|
||||
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
|
||||
endfunction
|
||||
|
@ -414,7 +414,7 @@ FUNCTIONS *SpaceVim-functions*
|
||||
|
||||
SpaceVim#layers#load({layer}) *SpaceVim#layers#load()*
|
||||
Load the {layer} you want. For all the layers SpaceVim supports, see
|
||||
|SpaceVim-layers|.
|
||||
|SpaceVim-layers|. the second argv is the layer variable.
|
||||
|
||||
SpaceVim#logger#setLevel({level}) *SpaceVim#logger#setLevel()*
|
||||
Set debug level of SpaceVim. Default is 1.
|
||||
@ -922,6 +922,9 @@ SHELL *SpaceVim-layer-shell*
|
||||
|
||||
SpaceVim uses deol.nvim for shell support in neovim and uses vimshell for vim.
|
||||
For more info, read |deol| and |vimshell|.
|
||||
VARIABLE
|
||||
default_shell
|
||||
|
||||
|
||||
==============================================================================
|
||||
TMUX *SpaceVim-layer-tmux*
|
||||
|
@ -1,14 +1,15 @@
|
||||
# SpaceVim Layers
|
||||
|
||||
Name | Description | Documentation
|
||||
----- |:----:| ------------------
|
||||
default | better default for vim and neovim | [documentation](https://spacevim.org/layers/default)
|
||||
checkers | checking in vim | [documentation](https://spacevim.org/layers/checkers)
|
||||
autocomplete | autocomplete in vim | [documentation](https://spacevim.org/layers/autocomplete)
|
||||
chinese | layer for chinese vimer | [documentation](https://spacevim.org/layers/chinese)
|
||||
colorscheme | all colorscheme in spacevim | [documentation](https://spacevim.org/layers/colorscheme)
|
||||
chat | chatting in vim | [documentation](https://spacevim.org/layers/chat)
|
||||
lang#java | java development in vim | [documentation](https://spacevim.org/layers/lang/java)
|
||||
lang#lisp | lisp development in vim | [documentation](https://spacevim.org/layers/lang/lisp)
|
||||
lang#markdown | layer for editing markdown in vim | [documentation](https://spacevim.org/layers/lang/markdown)
|
||||
lang#php | php development in vim | [documentation](https://spacevim.org/layers/lang/php)
|
||||
| Name | Description | Documentation |
|
||||
| ------------- | :-------------------------------: | ---------------------------------------------------------- |
|
||||
| default | better default for vim and neovim | [documentation](https://spacevim.org/layers/default) |
|
||||
| shell | shell support for SpaceVim | [documentation](https://spacevim.org/layers/shell) |
|
||||
| checkers | checking in vim | [documentation](https://spacevim.org/layers/checkers) |
|
||||
| autocomplete | autocomplete in vim | [documentation](https://spacevim.org/layers/autocomplete) |
|
||||
| chinese | layer for chinese vimer | [documentation](https://spacevim.org/layers/chinese) |
|
||||
| colorscheme | all colorscheme in spacevim | [documentation](https://spacevim.org/layers/colorscheme) |
|
||||
| chat | chatting in vim | [documentation](https://spacevim.org/layers/chat) |
|
||||
| lang#java | java development in vim | [documentation](https://spacevim.org/layers/lang/java) |
|
||||
| lang#lisp | lisp development in vim | [documentation](https://spacevim.org/layers/lang/lisp) |
|
||||
| lang#markdown | layer for editing markdown in vim | [documentation](https://spacevim.org/layers/lang/markdown) |
|
||||
| lang#php | php development in vim | [documentation](https://spacevim.org/layers/lang/php) |
|
||||
|
55
docs/layers/shell.md
Normal file
55
docs/layers/shell.md
Normal file
@ -0,0 +1,55 @@
|
||||
---
|
||||
title: "SpaceVim shell layer"
|
||||
---
|
||||
|
||||
# [SpaceVim Layers:](https://spacevim.org/layers) shell
|
||||
|
||||
<!-- vim-markdown-toc GFM -->
|
||||
* [Description](#description)
|
||||
* [Install](#install)
|
||||
* [Configuration](#configuration)
|
||||
* [Default shell](#default-shell)
|
||||
* [Default shell position and height](#default-shell-position-and-height)
|
||||
* [Key bindings](#key-bindings)
|
||||
|
||||
<!-- vim-markdown-toc -->
|
||||
|
||||
## Description
|
||||
|
||||
This layer provide shell support in SpaceVim.
|
||||
|
||||
## Install
|
||||
|
||||
To use this configuration layer, add `SPLayer 'shell'` to your custom configuration file.
|
||||
|
||||
## Configuration
|
||||
|
||||
### Default shell
|
||||
|
||||
Vim support these kinds of shell:
|
||||
|
||||
To define the default shell you can set the layer variable `default_shell` to the following variables:
|
||||
|
||||
- terminal
|
||||
- VimShell
|
||||
|
||||
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 in percents with the variable `default_height`. Default value is 30.
|
||||
|
||||
```vim
|
||||
call SpaceVim#layers#load('shell',
|
||||
\ {
|
||||
\ 'default_position' : 'top',
|
||||
\ 'default_height' : 30,
|
||||
\ }
|
||||
\ )
|
||||
```
|
||||
|
||||
## Key bindings
|
||||
|
||||
| Key Binding | Description |
|
||||
| ----------- | -------------------------------------- |
|
||||
| `SPC '` | Open, close or go to the default shell |
|
Loading…
Reference in New Issue
Block a user