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

feat(ssh): add ssh layer

This commit is contained in:
Shidong Wang 2021-10-16 22:23:53 +08:00
parent 63c2bbf5af
commit 3f8724524d
No known key found for this signature in database
GPG Key ID: 41BB7053E835C848
4 changed files with 142 additions and 8 deletions

View File

@ -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

View File

@ -192,14 +192,15 @@ CONTENTS *SpaceVim-contents*
106. leaderf...................................|SpaceVim-layers-leaderf| 106. leaderf...................................|SpaceVim-layers-leaderf|
107. operator.................................|SpaceVim-layers-operator| 107. operator.................................|SpaceVim-layers-operator|
108. shell.......................................|SpaceVim-layers-shell| 108. shell.......................................|SpaceVim-layers-shell|
109. test.........................................|SpaceVim-layers-test| 109. ssh...........................................|SpaceVim-layers-ssh|
110. tmux.........................................|SpaceVim-layers-tmux| 110. test.........................................|SpaceVim-layers-test|
111. tools#dash.............................|SpaceVim-layers-tools-dash| 111. tmux.........................................|SpaceVim-layers-tmux|
112. tools#mpv...............................|SpaceVim-layers-tools-mpv| 112. tools#dash.............................|SpaceVim-layers-tools-dash|
113. tools#zeal.............................|SpaceVim-layers-tools-zeal| 113. tools#mpv...............................|SpaceVim-layers-tools-mpv|
114. treesitter.............................|SpaceVim-layers-treesitter| 114. tools#zeal.............................|SpaceVim-layers-tools-zeal|
115. ui.............................................|SpaceVim-layers-ui| 115. treesitter.............................|SpaceVim-layers-treesitter|
116. unite.......................................|SpaceVim-layers-unite| 116. ui.............................................|SpaceVim-layers-ui|
117. unite.......................................|SpaceVim-layers-unite|
7. Usage....................................................|SpaceVim-usage| 7. Usage....................................................|SpaceVim-usage|
1. buffers-and-files..................|SpaceVim-usage-buffers-and-files| 1. buffers-and-files..................|SpaceVim-usage-buffers-and-files|
2. custom_plugins........................|SpaceVim-usage-custom_plugins| 2. custom_plugins........................|SpaceVim-usage-custom_plugins|
@ -4575,6 +4576,24 @@ KEY BINDINGS
q Hide terminal windows in normal mode 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* TEST *SpaceVim-layers-test*

View File

@ -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 | | [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 | | [leaderf](leaderf/) | This layer provides a heavily customized LeaderF centric workflow |
| [shell](shell/) | This layer provides shell support in SpaceVim | | [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 | | [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 | | [test](test/) | This layer allows to run tests directly in SpaceVim |
| [tmux](tmux/) | This layers adds extensive support for tmux | | [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#mpv](tools/mpv/) | This layer provides mpv integration for SpaceVim |
| [tools#zeal](tools/zeal/) | This layer provides Zeal integration for SpaceVim | | [tools#zeal](tools/zeal/) | This layer provides Zeal integration for SpaceVim |
| [tools](tools/) | This layer provides some tools for vim | | [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 | | [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 | | [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 | | [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 |

51
docs/layers/ssh.md Normal file
View File

@ -0,0 +1,51 @@
---
title: "SpaceVim ssh layer"
description: "This layer provides ssh support in SpaceVim"
---
# [Available Layers](../) >> shell
<!-- vim-markdown-toc GFM -->
- [Description](#description)
- [Install](#install)
- [Configuration](#configuration)
- [Key bindings](#key-bindings)
<!-- vim-markdown-toc -->
## 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 |