mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-13 02:05:40 +08:00
Improve lang#sh layer (#2045)
* Update doc for lang#sh layer * Update doc and wiki
This commit is contained in:
parent
37ca2fd660
commit
ea79a6a523
@ -34,4 +34,22 @@ function! SpaceVim#layers#lang#sh#config()
|
||||
autocmd!
|
||||
autocmd FileType sh setlocal omnifunc=SpaceVim#plugins#bashcomplete#omnicomplete
|
||||
augroup END
|
||||
call SpaceVim#mapping#gd#add('sh', function('s:go_to_def'))
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('sh', function('s:language_specified_mappings'))
|
||||
endfunction
|
||||
function! s:language_specified_mappings() abort
|
||||
if SpaceVim#layers#lsp#check_filetype('sh')
|
||||
nnoremap <silent><buffer> K :call SpaceVim#lsp#show_doc()<CR>
|
||||
|
||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'],
|
||||
\ 'call SpaceVim#lsp#show_doc()', 'show_document', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'],
|
||||
\ 'call SpaceVim#lsp#rename()', 'rename symbol', 1)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:go_to_def() abort
|
||||
if SpaceVim#layers#lsp#check_filetype('sh')
|
||||
call SpaceVim#lsp#go_to_def()
|
||||
endif
|
||||
endfunction
|
||||
|
@ -81,6 +81,7 @@ let s:enabled_fts = []
|
||||
|
||||
let s:lsp_servers = {
|
||||
\ 'typescript' : ['typescript-language-server', '--stdio'],
|
||||
\ 'sh' : ['bash-language-server', 'start'],
|
||||
\ 'haskell' : ['hie-wrapper', '--lsp'],
|
||||
\ 'c' : ['clangd'],
|
||||
\ 'cpp' : ['clangd'],
|
||||
|
@ -88,6 +88,7 @@ Vim 插件以及相关配置。而 SpaceVim 是以模块的方式来组织和管
|
||||
| [lang#php](lang/php/) | 这一模块为 php 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 |
|
||||
| [lang#python](lang/python/) | 这一模块为 python 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 |
|
||||
| [lang#ruby](lang/ruby/) | 这一模块为 ruby 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 |
|
||||
| [lang#sh](lang/sh/) | 这一模块为 shell script 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 |
|
||||
| [lang#typescript](lang/typescript/) | 这一模块为 typescript 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 |
|
||||
| [lang#vim](lang/vim/) | 这一模块为 vim script 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 |
|
||||
| [language-server-protocol](language-server-protocol/) | lsp 模块为 SpaceVim 提供 language server protocol 的支持,提供更多语言相关服务 |
|
||||
|
50
docs/cn/layers/lang/sh.md
Normal file
50
docs/cn/layers/lang/sh.md
Normal file
@ -0,0 +1,50 @@
|
||||
---
|
||||
title: "SpaceVim lang#sh 模块"
|
||||
description: "这一模块为 shell script 开发提供支持,包括代码补全、语法检查、代码格式化等特性。"
|
||||
lang: cn
|
||||
---
|
||||
|
||||
# [可用模块](../../) >> lang#sh
|
||||
|
||||
<!-- vim-markdown-toc GFM -->
|
||||
|
||||
- [模块简介](#模块简介)
|
||||
- [功能特性](#功能特性)
|
||||
- [启用模块](#启用模块)
|
||||
- [快捷键](#快捷键)
|
||||
- [语言专属快捷键](#语言专属快捷键)
|
||||
|
||||
<!-- vim-markdown-toc -->
|
||||
|
||||
## 模块简介
|
||||
|
||||
这一模块为 SpaceVim 提供了 shell script 开发支持。Shell script 是指 bash script 和 zsh script。
|
||||
|
||||
## 功能特性
|
||||
|
||||
- 代码补全
|
||||
- 语法高亮与对齐
|
||||
- 语法检查
|
||||
- 代码格式化
|
||||
- 跳转定义处
|
||||
|
||||
同时,SpaceVim 还为 shell script 开发提供了语言服务器等功能。若要启用语言服务器,需要载入 `lsp` 模块。
|
||||
|
||||
## 启用模块
|
||||
|
||||
可通过在配置文件内加入如下配置来启用该模块:
|
||||
|
||||
```toml
|
||||
[[layers]]
|
||||
name = "lang#sh"
|
||||
```
|
||||
|
||||
## 快捷键
|
||||
|
||||
### 语言专属快捷键
|
||||
|
||||
| 按键 | 功能描述 |
|
||||
| --------------- | --------------------------------------- |
|
||||
| `SPC l d` / `K` | 展示光标函数或变量相关文档 |
|
||||
| `g d` | 跳至函数或变量定义处 |
|
||||
|
@ -65,6 +65,12 @@ endif
|
||||
|
||||
### 安装语言服务器
|
||||
|
||||
**Bash**
|
||||
|
||||
```sh
|
||||
npm i -g bash-language-server
|
||||
```
|
||||
|
||||
**JavaScript:**
|
||||
|
||||
```sh
|
||||
@ -77,6 +83,17 @@ npm install -g javascript-typescript-langserver
|
||||
pip install --user python-language-server
|
||||
```
|
||||
|
||||
**julia:**
|
||||
|
||||
安装 `LanguageServer` 包需要 Julia(0.6 或更高版本).
|
||||
|
||||
```sh
|
||||
julia> Pkg.clone("https://github.com/JuliaEditorSupport/LanguageServer.jl")
|
||||
```
|
||||
|
||||
在 Julia 0.7 新的包管理系统下,可以在 REPL 模式下进行安装,只需要输入 `]` 即可切入到包管理模式,
|
||||
然后执行 `add LanguageServer` 来安装对应的包。
|
||||
|
||||
## 模块配置
|
||||
|
||||
为指定模块启用语言服务器支持,需要在载入模块时,指定 `filetypes` 选项:
|
||||
@ -92,20 +109,23 @@ pip install --user python-language-server
|
||||
|
||||
默认语言服务器的执行命令列表如下:
|
||||
|
||||
| 语言 | 命令 |
|
||||
| ------------ | ------------------------------------------------ |
|
||||
| `javascript` | `['javascript-typescript-stdio']` |
|
||||
| `haskell` | `['hie', '--lsp']` |
|
||||
| `c` | `['clangd']` |
|
||||
| `cpp` | `['clangd']` |
|
||||
| `html` | `['html-languageserver', '--stdio']` |
|
||||
| `objc` | `['clangd']` |
|
||||
| `objcpp` | `['clangd']` |
|
||||
| `dart` | `['dart_language_server']` |
|
||||
| `go` | `['go-langserver', '-mode', 'stdio']` |
|
||||
| `rust` | `['rustup', 'run', 'nightly', 'rls']` |
|
||||
| `python` | `['pyls']` |
|
||||
| `php` | `['php', 'path/to/bin/php-language-server.php']` |
|
||||
| 语言 | 命令 |
|
||||
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `javascript` | `['javascript-typescript-stdio']` |
|
||||
| `sh` | `['bash-language-server', 'start']` |
|
||||
| `typescript` | `['typescript-language-server', '--stdio']` |
|
||||
| `haskell` | `['hie', '--lsp']` |
|
||||
| `c` | `['clangd']` |
|
||||
| `cpp` | `['clangd']` |
|
||||
| `html` | `['html-languageserver', '--stdio']` |
|
||||
| `objc` | `['clangd']` |
|
||||
| `objcpp` | `['clangd']` |
|
||||
| `dart` | `['dart_language_server']` |
|
||||
| `go` | `['go-langserver', '-mode', 'stdio']` |
|
||||
| `rust` | `['rustup', 'run', 'nightly', 'rls']` |
|
||||
| `python` | `['pyls']` |
|
||||
| `php` | `['php', 'path/to/bin/php-language-server.php']` |
|
||||
| `julia` | `['julia', '--startup-file=no', '--history-file=no', '-e', 'using LanguageServer; server = LanguageServer.LanguageServerInstance(STDIN, STDOUT, false); server.runlinter = true; run(server);']` |
|
||||
|
||||
如果需要修改语言服务器的命令,在载入模块时,需要指定 `override_cmd` 选项:
|
||||
|
||||
|
@ -90,6 +90,7 @@ enable = false
|
||||
| [lang#php](lang/php/) | This layer adds PHP language support to SpaceVim |
|
||||
| [lang#python](lang/python/) | This layer is for Python development, provide autocompletion, syntax checking, code format for python file. |
|
||||
| [lang#ruby](lang/ruby/) | This layer is for ruby development, provide autocompletion, syntax checking, code format for ruby file. |
|
||||
| [lang#sh](lang/sh/) | Shell script development layer, provides autocompletion, syntax checking, code format for bash and zsh script. |
|
||||
| [lang#swift](lang/swift/) | swift language support for SpaceVim, includes code completion, syntax highlighting |
|
||||
| [lang#typescript](lang/typescript/) | This layer is for TypeScript development |
|
||||
| [lang#vim](lang/vim/) | This layer is for writting vim script, including code completion, syntax checking and buffer formatting |
|
||||
|
52
docs/layers/lang/sh.md
Normal file
52
docs/layers/lang/sh.md
Normal file
@ -0,0 +1,52 @@
|
||||
---
|
||||
title: "SpaceVim lang#sh layer"
|
||||
description: "Shell script development layer, provides autocompletion, syntax checking, code format for bash and zsh script."
|
||||
---
|
||||
|
||||
# [Available Layers](../../) >> lang#sh
|
||||
|
||||
<!-- vim-markdown-toc GFM -->
|
||||
|
||||
- [Description](#description)
|
||||
- [Features](#features)
|
||||
- [Install](#install)
|
||||
- [Layer](#layer)
|
||||
- [Key bindings](#key-bindings)
|
||||
- [Language specific key bindings](#language-specific-key-bindings)
|
||||
|
||||
<!-- vim-markdown-toc -->
|
||||
|
||||
## Description
|
||||
|
||||
This layer is for shell script development. Shell script includes bash script and zsh script.
|
||||
|
||||
## Features
|
||||
|
||||
- Code completion
|
||||
- Syntax highlighting and indent
|
||||
- Syntax checking
|
||||
- Code formatting
|
||||
- Jump to declaration
|
||||
|
||||
SpaceVim also provides language server protocol support for bash script. to enable language server protocol
|
||||
for bash script, you need to load `lsp` layer for bash.
|
||||
|
||||
## Install
|
||||
|
||||
### Layer
|
||||
|
||||
To use this configuration layer, update custom configuration file with:
|
||||
|
||||
```toml
|
||||
[[layers]]
|
||||
name = "lang#sh"
|
||||
```
|
||||
|
||||
## Key bindings
|
||||
|
||||
### Language specific key bindings
|
||||
|
||||
| Key binding | Description |
|
||||
| --------------- | -------------------------------- |
|
||||
| `SPC l d` / `K` | Show doc of cursor symbol |
|
||||
| `g d` | Jump to definition |
|
@ -67,6 +67,12 @@ To use this configuration layer, update custom configuration file with:
|
||||
|
||||
### Install language server
|
||||
|
||||
**Bash**
|
||||
|
||||
```sh
|
||||
npm i -g bash-language-server
|
||||
```
|
||||
|
||||
**JavaScript:**
|
||||
|
||||
```sh
|
||||
@ -105,21 +111,22 @@ To enable lsp support for a specified filetype, you may need to load this layer
|
||||
|
||||
default language server commands:
|
||||
|
||||
| language | server command |
|
||||
| ------------ | ------------------------------------------------ |
|
||||
| `javascript` | `['javascript-typescript-stdio']` |
|
||||
| `typescript` | `['typescript-language-server', '--stdio']` |
|
||||
| `haskell` | `['hie', '--lsp']` |
|
||||
| `c` | `['clangd']` |
|
||||
| `cpp` | `['clangd']` |
|
||||
| `html` | `['html-languageserver', '--stdio']` |
|
||||
| `objc` | `['clangd']` |
|
||||
| `objcpp` | `['clangd']` |
|
||||
| `dart` | `['dart_language_server']` |
|
||||
| `go` | `['go-langserver', '-mode', 'stdio']` |
|
||||
| `rust` | `['rustup', 'run', 'nightly', 'rls']` |
|
||||
| `python` | `['pyls']` |
|
||||
| `php` | `['php', 'path/to/bin/php-language-server.php']` |
|
||||
| language | server command |
|
||||
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `javascript` | `['javascript-typescript-stdio']` |
|
||||
| `sh` | `['bash-language-server', 'start']` |
|
||||
| `typescript` | `['typescript-language-server', '--stdio']` |
|
||||
| `haskell` | `['hie', '--lsp']` |
|
||||
| `c` | `['clangd']` |
|
||||
| `cpp` | `['clangd']` |
|
||||
| `html` | `['html-languageserver', '--stdio']` |
|
||||
| `objc` | `['clangd']` |
|
||||
| `objcpp` | `['clangd']` |
|
||||
| `dart` | `['dart_language_server']` |
|
||||
| `go` | `['go-langserver', '-mode', 'stdio']` |
|
||||
| `rust` | `['rustup', 'run', 'nightly', 'rls']` |
|
||||
| `python` | `['pyls']` |
|
||||
| `php` | `['php', 'path/to/bin/php-language-server.php']` |
|
||||
| `julia` | `['julia', '--startup-file=no', '--history-file=no', '-e', 'using LanguageServer; server = LanguageServer.LanguageServerInstance(STDIN, STDOUT, false); server.runlinter = true; run(server);']` |
|
||||
|
||||
To override the server command, you may need to use `override_cmd` option:
|
||||
|
@ -13,6 +13,7 @@ The next release is v0.9.0.
|
||||
- Add lsp support for julia ([#1850](https://github.com/SpaceVim/SpaceVim/pull/1850))
|
||||
- Add lsp support for typescript ([#1870](https://github.com/SpaceVim/SpaceVim/pull/1870))
|
||||
- Add lsp support for elixir ([#2037](https://github.com/SpaceVim/SpaceVim/pull/2037))
|
||||
- Add lsp support for bash ([#2045](https://github.com/SpaceVim/SpaceVim/pull/2045))
|
||||
- Add option for disabling parentheses autocompletion ([#1920](https://github.com/SpaceVim/SpaceVim/pull/1920))
|
||||
- Add Docker build of Neovim and SpaceVim ([#1923](https://github.com/SpaceVim/SpaceVim/pull/1923))
|
||||
- Add gist manager vim-gista ([#1936](https://github.com/SpaceVim/SpaceVim/pull/1936))
|
||||
|
Loading…
x
Reference in New Issue
Block a user