1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-04-13 12:49:10 +08:00

Lsp support for elixir (#2037)

* Lsp support for elixir

* Update elixir key bindings

* Update key bindings

* Update key bindings

* Update wiki
This commit is contained in:
Wang Shidong 2018-08-14 20:02:54 +08:00 committed by GitHub
parent 7a7d77174e
commit 6b2ec2041c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 9 deletions

View File

@ -18,16 +18,35 @@
function! SpaceVim#layers#lang#elixir#plugins() abort
let plugins = []
call add(plugins, ['elixir-editors/vim-elixir', {'on_ft' : ['elixir', 'eelixir']}])
call add(plugins, ['slashmili/alchemist.vim', {'on_ft' : 'elixir'}])
if !SpaceVim#layers#lsp#check_filetype('elixir')
call add(plugins, ['slashmili/alchemist.vim', {'on_ft' : 'elixir'}])
endif
return plugins
endfunction
function! SpaceVim#layers#lang#elixir#config()
function! SpaceVim#layers#lang#elixir#config() abort
call SpaceVim#plugins#repl#reg('elixir', 'iex')
call SpaceVim#mapping#space#regesit_lang_mappings('elixir', function('s:language_specified_mappings'))
call SpaceVim#mapping#gd#add('elixir', function('s:go_to_def'))
let g:alchemist_mappings_disable = 1
let g:alchemist_tag_disable = 1
endfunction
function! s:language_specified_mappings() abort
if SpaceVim#layers#lsp#check_filetype('elixir')
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("elixir")',
@ -42,3 +61,11 @@ function! s:language_specified_mappings() abort
\ '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('elixir')
call SpaceVim#lsp#go_to_def()
else
ExDef
endif
endfunction

View File

@ -12,6 +12,7 @@ lang: cn
- [功能特性](#功能特性)
- [启用模块](#启用模块)
- [快捷键](#快捷键)
- [语言专属快捷键](#语言专属快捷键)
- [交互式编程](#交互式编程)
- [运行当前脚本](#运行当前脚本)
@ -29,7 +30,7 @@ lang: cn
- 文档查询
- 跳转定义处
同时,该模块还未 elixir 开发提供了交互式编程和调试等功能
同时,SpaceVim 还为 elixir 开发提供了交互式编程、一键运行和语言服务器等功能。若要启用语言服务器,需要载入 `lsp` 模块
## 启用模块
@ -40,20 +41,28 @@ lang: cn
name = "lang#elixir"
```
## 快捷键
### 语言专属快捷键
| 按键 | 功能描述 |
| --------------- | --------------------------------------- |
| `SPC l d` / `K` | 展示光标函数或变量相关文档 |
| `SPC l t` | 跳至 tag 栈 |
| `SPC l e` | 重命名光标函数或变量(需要 `lsp` 模块) |
| `g d` | 跳至函数或变量定义处 |
### 交互式编程
启动 `iex` 交互进程,快捷键为: `SPC l s i`
将代码传输给 REPL 进程执行:
| 快捷键 | 描述 |
| ----------- | --------------------------- |
| 快捷键 | 描述 |
| ----------- | ----------------------- |
| `SPC l s b` | 发送整个文件内容至 REPL |
| `SPC l s l` | 发送当前行内容至 REPL |
| `SPC l s s` | 发送已选中的内容至 REPL |
| `SPC l s l` | 发送当前行内容至 REPL |
| `SPC l s s` | 发送已选中的内容至 REPL |
### 运行当前脚本

View File

@ -12,6 +12,7 @@ description: "This layer is for elixir development, provide autocompletion, synt
- [Install](#install)
- [Layer](#layer)
- [Key bindings](#key-bindings)
- [Language specific key bindings](#language-specific-key-bindings)
- [Inferior REPL process](#inferior-repl-process)
- [Running current script](#running-current-script)
@ -29,7 +30,8 @@ This layer include the plugin [slashmili/alchemist.vim](https://github.com/slash
- Documentation lookup for Modules and functions.
- Jump to the definition.
SpaceVim also provides REPL/Debug support for elixir.
SpaceVim also provides REPL, code runner and Language Server protocol support for elixir. to enable language server protocol
for elixir, you need to load `lsp` layer for elixir.
## Install
@ -44,6 +46,15 @@ To use this configuration layer, update custom configuration file with:
## Key bindings
### Language specific key bindings
| Key binding | Description |
| --------------- | -------------------------------- |
| `SPC l d` / `K` | Show doc of cursor symbol |
| `SPC l t` | Jump to tag stack |
| `SPC l e` | Rename symbol (need `lsp` layer) |
| `g d` | Jump to definition |
### Inferior REPL process
Start a `iex` inferior REPL process with `SPC l s i`.

View File

@ -12,6 +12,7 @@ The next release is v0.9.0.
- Add test for toml, number, file, icon and highlight API ([#1849](https://github.com/SpaceVim/SpaceVim/pull/1849))
- 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 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))