Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
142 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | |