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

Fix lua repl && add layer doc

This commit is contained in:
wsdjeg 2017-12-21 21:38:47 +08:00
parent 8495005056
commit 319968d12e
2 changed files with 77 additions and 10 deletions

View File

@ -11,30 +11,40 @@
" <
function! SpaceVim#layers#lang#lua#plugins() abort
let plugins = []
" Improved Lua 5.3 syntax and indentation support for Vim
call add(plugins, ['tbastos/vim-lua', {'on_ft' : 'lua'}])
call add(plugins, ['WolfgangMehner/lua-support', {'on_ft' : 'lua'}])
call add(plugins, ['SpaceVim/vim-luacomplete', {'on_ft' : 'lua', 'if' : has('lua')}])
return plugins
let plugins = []
" Improved Lua 5.3 syntax and indentation support for Vim
call add(plugins, ['tbastos/vim-lua', {'on_ft' : 'lua'}])
call add(plugins, ['WolfgangMehner/lua-support', {'on_ft' : 'lua'}])
call add(plugins, ['SpaceVim/vim-luacomplete', {'on_ft' : 'lua', 'if' : has('lua')}])
return plugins
endfunction
let s:lua_repl_command = ''
function! SpaceVim#layers#lang#lua#config() abort
if has('lua')
augroup spacevim_lua
autocmd FileType lua setlocal omnifunc=luacomplete#complete
autocmd FileType lua setlocal omnifunc=luacomplete#complete
augroup END
endif
call SpaceVim#mapping#space#regesit_lang_mappings('lua', funcref('s:language_specified_mappings'))
call SpaceVim#plugins#runner#reg_runner('lua', 'lua %s')
if executable('luap')
call SpaceVim#plugins#repl#reg('lua', 'luap')
if !empty(s:lua_repl_command)
call SpaceVim#plugins#repl#reg('lua',s:lua_repl_command)
else
call SpaceVim#plugins#repl#reg('lua', 'lua')
if executable('luap')
call SpaceVim#plugins#repl#reg('lua', 'luap')
else
call SpaceVim#plugins#repl#reg('lua', 'lua')
endif
endif
endfunction
function! SpaceVim#layers#lang#lua#set_variablee(opt) abort
let s:lua_repl_command = get(a:opt, 'repl_command', '')
endfunction
" Add language specific mappings
function! s:language_specified_mappings() abort
call SpaceVim#mapping#space#langSPC('nmap', ['l','b'], 'LuaCompile', 'lua compile', 1)

57
docs/layers/lang/lua.md Normal file
View File

@ -0,0 +1,57 @@
---
title: "SpaceVim lang#lua layer"
description: "This layer is for lua development, provide autocompletion, syntax checking, code format for lua file."
---
# [SpaceVim Layers:](https://spacevim.org/layers) lang#lua
<!-- vim-markdown-toc GFM -->
- [Description](#description)
- [Installation](#installation)
- [Layer](#layer)
- [Syntax checking && Code formatting](#syntax-checking--code-formatting)
- [Key bindings](#key-bindings)
- [Inferior REPL process](#inferior-repl-process)
- [Running current script](#running-current-script)
<!-- vim-markdown-toc -->
## Description
This layer is for lua development.
## Installation
### Layer
To use this configuration layer, add `SPLayer 'lang#lua'` to your custom configuration file.
### Syntax checking && Code formatting
## Key bindings
### Inferior REPL process
Start a `lua` or `luap` inferior REPL process with `SPC l s i`. You may change the REPL command by layer option `repl_command`. for example, if you want to use `lua.repl`, load this layer via:
```vim
call SpaceVim#layers#load('lang#lua'
\ {
\ 'repl_command' : '~/.luarocks/lib/luarocks/rocks-5.3/luarepl/0.8-1/bin/rep.lua',
\ }
```
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 |
### Running current script
To running a ruby script, you can press `SPC l r` to run current file without loss focus, and the result will be shown in a runner buffer.