diff --git a/autoload/SpaceVim/layers/ssh.vim b/autoload/SpaceVim/layers/ssh.vim new file mode 100644 index 000000000..7b2d1b4d1 --- /dev/null +++ b/autoload/SpaceVim/layers/ssh.vim @@ -0,0 +1,62 @@ +"============================================================================= +" ssh.vim --- ssh layer for spacevim +" Copyright (c) 2016-2019 Wang Shidong & Contributors +" Author: Wang Shidong < wsdjeg@outlook.com > +" URL: https://spacevim.org +" License: GPLv3 +"============================================================================= + + +"" +" @section ssh, layers-ssh +" @parentsection layers +" The `ssh` layer provides basic function to connected to ssh server. +" +" @subsection layer options +" +" 1. `ssh_port`: set the port of ssh server +" 2. `ssh_address`: set the ip of ssh server +" 3. `ssh_user`: set the user name of ssh server +" +" @subsection key bindings +" > +" Key Bingding Description +" SPC S o connect to ssh server +" < + +if exists('s:ssh') + finish +endif + +let s:ssh = 'ssh' +let s:user = 'root' +let s:ip = '127.0.0.1' +let s:port = '20' + +function! SpaceVim#layers#ssh#config() abort + let g:_spacevim_mappings_space.S = {'name' : '+SSH'} + call SpaceVim#mapping#space#langSPC('nmap', ['S','o'], + \ 'call SpaceVim#layers#ssh#connect()', + \ 'connect-to-ssh-server', 1) +endfunction + +function! SpaceVim#layers#ssh#set_variable(opt) abort + let s:ssh = get(a:opt, 'ssh_command', s:ssh) + let s:user = get(a:opt, 'ssh_user', s:user) + let s:ip = get(a:opt, 'ssh_address', s:ip) + let s:port = get(a:opt, 'ssh_port', s:port) +endfunction + +function! SpaceVim#layers#ssh#connect() abort + if has('nvim') + call termopen([s:ssh, '-p', s:port, s:user . '@' . s:ip]) + else + call term_start([s:ssh, '-p', s:port, s:user . '@' . s:ip], {'curwin' : 1, 'term_finish' : 'close'}) + endif +endfunction + +function! SpaceVim#layers#ssh#get_options() abort + + return ['ssh_port', 'ssh_user', 'ssh_address', 'ssh_command'] + +endfunction diff --git a/doc/SpaceVim.txt b/doc/SpaceVim.txt index edad16e9a..6606ccdb8 100644 --- a/doc/SpaceVim.txt +++ b/doc/SpaceVim.txt @@ -192,14 +192,15 @@ CONTENTS *SpaceVim-contents* 106. leaderf...................................|SpaceVim-layers-leaderf| 107. operator.................................|SpaceVim-layers-operator| 108. shell.......................................|SpaceVim-layers-shell| - 109. test.........................................|SpaceVim-layers-test| - 110. tmux.........................................|SpaceVim-layers-tmux| - 111. tools#dash.............................|SpaceVim-layers-tools-dash| - 112. tools#mpv...............................|SpaceVim-layers-tools-mpv| - 113. tools#zeal.............................|SpaceVim-layers-tools-zeal| - 114. treesitter.............................|SpaceVim-layers-treesitter| - 115. ui.............................................|SpaceVim-layers-ui| - 116. unite.......................................|SpaceVim-layers-unite| + 109. ssh...........................................|SpaceVim-layers-ssh| + 110. test.........................................|SpaceVim-layers-test| + 111. tmux.........................................|SpaceVim-layers-tmux| + 112. tools#dash.............................|SpaceVim-layers-tools-dash| + 113. tools#mpv...............................|SpaceVim-layers-tools-mpv| + 114. tools#zeal.............................|SpaceVim-layers-tools-zeal| + 115. treesitter.............................|SpaceVim-layers-treesitter| + 116. ui.............................................|SpaceVim-layers-ui| + 117. unite.......................................|SpaceVim-layers-unite| 7. Usage....................................................|SpaceVim-usage| 1. buffers-and-files..................|SpaceVim-usage-buffers-and-files| 2. custom_plugins........................|SpaceVim-usage-custom_plugins| @@ -4575,6 +4576,24 @@ KEY BINDINGS q Hide terminal windows in normal mode < +============================================================================== +SSH *SpaceVim-layers-ssh* + +The `ssh` layer provides basic function to connected to ssh server. + +LAYER OPTIONS + + 1. `ssh_port`: set the port of ssh server + 2. `ssh_address`: set the ip of ssh server + 3. `ssh_user`: set the user name of ssh server + +KEY BINDINGS + +> + Key Bingding Description + SPC S o connect to ssh server +< + ============================================================================== TEST *SpaceVim-layers-test* diff --git a/docs/layers.md b/docs/layers.md index ae53bb802..0134e657c 100644 --- a/docs/layers.md +++ b/docs/layers.md @@ -189,6 +189,7 @@ Some layers are enabled by default. The following example shows how to disable ` | [language-server-protocol](language-server-protocol/) | This layers provides language server protocol for vim and neovim | | [leaderf](leaderf/) | This layer provides a heavily customized LeaderF centric workflow | | [shell](shell/) | This layer provides shell support in SpaceVim | +| [ssh](ssh/) | This layer provides ssh support in SpaceVim | | [sudo](sudo/) | sudo layer provides the ability to read and write files with elevated privileges in SpaceVim | | [test](test/) | This layer allows to run tests directly in SpaceVim | | [tmux](tmux/) | This layers adds extensive support for tmux | @@ -196,6 +197,7 @@ Some layers are enabled by default. The following example shows how to disable ` | [tools#mpv](tools/mpv/) | This layer provides mpv integration for SpaceVim | | [tools#zeal](tools/zeal/) | This layer provides Zeal integration for SpaceVim | | [tools](tools/) | This layer provides some tools for vim | +| [treesitter](treesitter/) | This layers adds extensive support for treesitter | | [ui](ui/) | Awesome UI layer for SpaceVim, provide IDE-like UI for neovim and vim in both TUI and GUI | | [unite](unite/) | This layer provides a heavily customized Unite centric workflow | | [VersionControl](VersionControl/) | This layer provides general version control features for SpaceVim. It should work with all VC backends such as Git, Mercurial, Bazaar, SVN, etc | diff --git a/docs/layers/ssh.md b/docs/layers/ssh.md new file mode 100644 index 000000000..e3f9ea065 --- /dev/null +++ b/docs/layers/ssh.md @@ -0,0 +1,51 @@ +--- +title: "SpaceVim ssh layer" +description: "This layer provides ssh support in SpaceVim" +--- + +# [Available Layers](../) >> shell + + + +- [Description](#description) +- [Install](#install) +- [Configuration](#configuration) +- [Key bindings](#key-bindings) + + + +## Description + +This layer provides ssh connection support for SpaceVim. + +## Install + +To use this configuration layer, add following snippet to your custom configuration file. + +```toml +[[layers]] + name = "ssh" +``` + +## Configuration + +- `ssh_port`: set the port of ssh server +- `ssh_address`: set the ip of ssh server +- `ssh_user`: set the user name of ssh server + +Example: + +``` +[[layers]] + name = 'ssh' + ssh_command = 'D:\Programs\Git\usr\bin\ssh.exe' + ssh_user = 'root' + ssh_address = '192.168.1.10' + ssh_port = '8097' +``` + +## Key bindings + +| Key Binding | Description | +| ----------- | --------------------------- | +| `SPC S o` | open ssh connection windows |