1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 00:00:04 +08:00

add lang#erlang layer (#2074)

* Add lang#erlang layer

* Fix erlang omni patterns

* Add doc

* Add repl support for erlang

* Add lang#erlang layer

* Type
This commit is contained in:
Wang Shidong 2018-08-22 20:40:25 +08:00 committed by GitHub
parent 7110672a95
commit 151e0a6e18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 198 additions and 1 deletions

View File

@ -0,0 +1,64 @@
"=============================================================================
" erlang.vim --- erlang support for SpaceVim
" Copyright (c) 2016-2017 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg at 163.com >
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
function! SpaceVim#layers#lang#erlang#plugins() abort
let plugins = []
call add(plugins, ['vim-erlang/vim-erlang-compiler', {'on_ft' : 'erlang'}])
call add(plugins, ['vim-erlang/vim-erlang-omnicomplete', {'on_ft' : 'erlang'}])
call add(plugins, ['vim-erlang/vim-erlang-runtime', {'on_ft' : 'erlang'}])
call add(plugins, ['vim-erlang/vim-erlang-tags', {'on_ft' : 'erlang'}])
return plugins
endfunction
function! SpaceVim#layers#lang#erlang#config() abort
call SpaceVim#plugins#repl#reg('erlang', 'erl')
" call SpaceVim#plugins#runner#reg_runner('erlang', ['erlc -o #TEMP# %s', 'erl -pa #TEMP#'])
call SpaceVim#mapping#space#regesit_lang_mappings('erlang', function('s:language_specified_mappings'))
" call SpaceVim#mapping#gd#add('erlang', function('s:go_to_def'))
endfunction
function! s:language_specified_mappings() abort
" call SpaceVim#mapping#space#langSPC('nmap', ['l','r'],
" \ 'call SpaceVim#plugins#runner#open()',
" \ 'execute current file', 1)
if SpaceVim#layers#lsp#check_filetype('erlang')
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)
" else
" nnoremap <silent><buffer> K :call alchemist#exdoc()<CR>
" call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'],
" \ 'call alchemist#exdoc()', 'show_document', 1)
" call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 't'],
" \ 'call alchemist#jump_tag_stack()', 'jump to tag stack', 1)
endif
let g:_spacevim_mappings_space.l.s = {'name' : '+Send'}
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'i'],
\ 'call SpaceVim#plugins#repl#start("erlang")',
\ 'start REPL process', 1)
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'l'],
\ 'call SpaceVim#plugins#repl#send("line")',
\ 'send line and keep code buffer focused', 1)
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'b'],
\ 'call SpaceVim#plugins#repl#send("buffer")',
\ 'send buffer and keep code buffer focused', 1)
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 's'],
\ 'call SpaceVim#plugins#repl#send("selection")',
\ 'send selection and keep code buffer focused', 1)
endfunction
function! s:go_to_def() abort
if SpaceVim#layers#lsp#check_filetype('erlang')
call SpaceVim#lsp#go_to_def()
else
normal! gd
endif
endfunction

View File

@ -95,6 +95,11 @@ let g:deoplete#keyword_patterns.clojure = '[\w!$%&*+/:<=>?@\^_~\-\.#]*'
" ocaml " ocaml
let g:deoplete#ignore_sources.ocaml = ['buffer', 'around', 'omni'] let g:deoplete#ignore_sources.ocaml = ['buffer', 'around', 'omni']
" erlang
let g:deoplete#omni#input_patterns.erlang = get(g:deoplete#omni#input_patterns, 'erlang', [
\'[^. \t0-9]\.\w*',
\])
" public settings " public settings
call deoplete#custom#source('_', 'matchers', ['matcher_full_fuzzy']) call deoplete#custom#source('_', 'matchers', ['matcher_full_fuzzy'])
call deoplete#custom#source('file/include', 'matchers', ['matcher_head']) call deoplete#custom#source('file/include', 'matchers', ['matcher_head'])

View File

@ -76,6 +76,7 @@ Vim 插件以及相关配置。而 SpaceVim 是以模块的方式来组织和管
| [lang#c](lang/c/) | 这一模块为 c/c++/object-c 的开发提供了支持,包括代码补全、语法检查等特性。 | | [lang#c](lang/c/) | 这一模块为 c/c++/object-c 的开发提供了支持,包括代码补全、语法检查等特性。 |
| [lang#dart](lang/dart/) | 这一模块为 dart 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | | [lang#dart](lang/dart/) | 这一模块为 dart 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 |
| [lang#elixir](lang/elixir/) | 这一模块为 elixir 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | | [lang#elixir](lang/elixir/) | 这一模块为 elixir 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 |
| [lang#erlang](lang/erlang/) | 这一模块为 erlang 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 |
| [lang#go](lang/go/) | 这一模块为 go 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | | [lang#go](lang/go/) | 这一模块为 go 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 |
| [lang#haskell](lang/haskell/) | 这一模块为 haskell 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | | [lang#haskell](lang/haskell/) | 这一模块为 haskell 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 |
| [lang#html](lang/html/) | 这一模块为 html 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | | [lang#html](lang/html/) | 这一模块为 html 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 |

View File

@ -0,0 +1,61 @@
---
title: "SpaceVim lang#erlang 模块"
description: "这一模块为 erlang 开发提供支持,包括代码补全、语法检查、代码格式化等特性。"
lang: cn
---
# [可用模块](../../) >> lang#erlang
<!-- vim-markdown-toc GFM -->
- [模块简介](#模块简介)
- [功能特性](#功能特性)
- [启用模块](#启用模块)
- [快捷键](#快捷键)
- [语言专属快捷键](#语言专属快捷键)
- [交互式编程](#交互式编程)
<!-- vim-markdown-toc -->
## 模块简介
这一模块为 SpaceVim 提供了 erlang 开发支持,包括代码补全、语法检查、以及代码格式化等特性。
## 功能特性
- 代码补全
- 文档查询
- 跳转定义处
同时SpaceVim 还为 erlang 开发提供了交互式编程和语言服务器等功能。若要启用语言服务器,需要载入 `lsp` 模块。
## 启用模块
可通过在配置文件内加入如下配置来启用该模块:
```toml
[[layers]]
name = "lang#erlang"
```
## 快捷键
### 语言专属快捷键
| 按键 | 功能描述 |
| --------------- | --------------------------------------- |
| `SPC l d` / `K` | 展示光标函数或变量相关文档(需要 `lsp` 模块) |
| `SPC l e` | 重命名光标函数或变量(需要 `lsp` 模块) |
| `g d` | 跳至函数或变量定义处(需要 `lsp` 模块) |
### 交互式编程
启动 `erl` 交互进程,快捷键为: `SPC l s i`
将代码传输给 REPL 进程执行:
| 快捷键 | 描述 |
| ----------- | ----------------------- |
| `SPC l s b` | 发送整个文件内容至 REPL |
| `SPC l s l` | 发送当前行内容至 REPL |
| `SPC l s s` | 发送已选中的内容至 REPL |

View File

@ -75,6 +75,7 @@ enable = false
| [lang#dart](lang/dart/) | This layer is for dart development, provide autocompletion, syntax checking, code format for dart file. | | [lang#dart](lang/dart/) | This layer is for dart development, provide autocompletion, syntax checking, code format for dart file. |
| [lang#dockerfile](lang/dockerfile/) | This layer adds DockerFile to SpaceVim | | [lang#dockerfile](lang/dockerfile/) | This layer adds DockerFile to SpaceVim |
| [lang#elixir](lang/elixir/) | This layer is for elixir development, provide autocompletion, syntax checking, code format for elixir file. | | [lang#elixir](lang/elixir/) | This layer is for elixir development, provide autocompletion, syntax checking, code format for elixir file. |
| [lang#erlang](lang/erlang/) | This layer is for erlang development, provide autocompletion, syntax checking, code format for erlang file. |
| [lang#go](lang/go/) | This layer is for golang development. It also provides additional language-specific key mappings. | | [lang#go](lang/go/) | This layer is for golang development. It also provides additional language-specific key mappings. |
| [lang#haskell](lang/haskell/) | haskell language support for SpaceVim, includes code completion, syntax checking, jumping to definition, also provides language server protocol support for haskell | | [lang#haskell](lang/haskell/) | haskell language support for SpaceVim, includes code completion, syntax checking, jumping to definition, also provides language server protocol support for haskell |
| [lang#html](lang/html/) | Edit html in SpaceVim, with this layer, this layer provides code completion, syntax checking and code formatting for html. | | [lang#html](lang/html/) | Edit html in SpaceVim, with this layer, this layer provides code completion, syntax checking and code formatting for html. |

View File

@ -27,5 +27,5 @@ To use this configuration layer, update custom configuration file with:
```toml ```toml
[[layers]] [[layers]]
name = "lang#kotlin" name = "lang#WebAssembly"
``` ```

View File

@ -0,0 +1,64 @@
---
title: "SpaceVim lang#elang layer"
description: "This layer is for erlang development, provide autocompletion, syntax checking, code format for erlang file."
---
# [Available Layers](../../) >> lang#erlang
<!-- vim-markdown-toc GFM -->
- [Description](#description)
- [Features](#features)
- [Install](#install)
- [Layer](#layer)
- [Key bindings](#key-bindings)
- [Language specific key bindings](#language-specific-key-bindings)
- [Inferior REPL process](#inferior-repl-process)
<!-- vim-markdown-toc -->
## Description
This layer is for erlang development.
## Features
- code completion
- syntax highlighting
- syntax checking
SpaceVim also provides REPL, code runner and Language Server protocol support for erlang. to enable language server protocol
for erlang, you need to load `lsp` layer for erlang.
## Install
### Layer
To use this configuration layer, update custom configuration file with:
```toml
[[layers]]
name = "lang#erlang"
```
## Key bindings
### Language specific key bindings
| Key binding | Description |
| --------------- | -------------------------------------------- |
| `SPC l d` / `K` | Show doc of cursor symbol (need `lsp` layer) |
| `SPC l e` | Rename symbol (need `lsp` layer) |
| `g d` | Jump to definition (need `lsp` layer) |
### Inferior REPL process
Start a `erl` inferior REPL process with `SPC l s i`.
Send code to inferior process commands:
| Key Binding | Description |
| ----------- | ------------------------------------------------ |
| `SPC l s b` | send buffer and keep code buffer focused |
| `SPC l s l` | send line and keep code buffer focused |
| `SPC l s s` | send selection text and keep code buffer focused |

View File

@ -25,6 +25,7 @@ The next release is v0.9.0.
- Add `lang#nim` layer ([#2018](https://github.com/SpaceVim/SpaceVim/pull/2018)) - Add `lang#nim` layer ([#2018](https://github.com/SpaceVim/SpaceVim/pull/2018))
- Add `lang#purescript` layer ([#2054](https://github.com/SpaceVim/SpaceVim/pull/2054)) - Add `lang#purescript` layer ([#2054](https://github.com/SpaceVim/SpaceVim/pull/2054))
- Add `lang#WebAssembly` layer ([#2068](https://github.com/SpaceVim/SpaceVim/pull/2068)) - Add `lang#WebAssembly` layer ([#2068](https://github.com/SpaceVim/SpaceVim/pull/2068))
- Add `lang#erlang` layer ([#2074](https://github.com/SpaceVim/SpaceVim/pull/2074))
### Improvement ### Improvement