1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 17:40:06 +08:00

refactor(lang#lua)!: remove vim-support and add layer options

1. add `lua_file_head`
2. add `format_on_save`
3. disable lua-support

BREAKING CHANGE: remove lua-support plugin
This commit is contained in:
Shidong Wang 2021-10-15 23:42:43 +08:00
parent 71fd4db943
commit 1f2ce0e686
No known key found for this signature in database
GPG Key ID: 41BB7053E835C848
2 changed files with 71 additions and 4 deletions

View File

@ -15,6 +15,30 @@
" name = 'lang#lua'
" <
"
" @subsection Layer options
"
" 1. lua_file_head: the default file head for lua source code.
" >
" [layers]
" name = "lang#lua"
" ruby_file_head = [
" '--!/usr/bin/lua',
" ''
" ]
" <
" 2. repl_command: the REPL command for lua
" >
" [[layers]]
" name = 'lang#lua'
" repl_command = '~/download/bin/lua'
" <
" 3. format_on_save: enable/disable code formation when save lua file. This
" options is disabled by default, to enable it:
" >
" [[layers]]
" name = 'lang#lua'
" format_on_save = true
" <
" @subsection Key bindings
" >
" Mode Key Function
@ -34,17 +58,25 @@
" <
"
if exists('s:lua_repl_command')
finish
endif
let s:lua_repl_command = ''
let s:lua_foldmethod = 'manual'
let s:lua_file_head = [
\ '--!/usr/bin/lua',
\ ''
\ ]
function! SpaceVim#layers#lang#lua#plugins() abort
let plugins = []
" Improved Lua 5.3 syntax and indentation support for Vim
call add(plugins, [g:_spacevim_root_dir . 'bundle/vim-lua', {'on_ft' : 'lua'}])
call add(plugins, ['WolfgangMehner/lua-support', {'on_ft' : 'lua'}])
return plugins
endfunction
let s:lua_repl_command = ''
let s:lua_foldmethod = 'manual'
function! SpaceVim#layers#lang#lua#config() abort
augroup spacevim_lang_lua
@ -78,11 +110,20 @@ function! SpaceVim#layers#lang#lua#config() abort
let lua_repl = ['lua', '-i']
endif
call SpaceVim#plugins#repl#reg('lua', lua_repl)
call SpaceVim#layers#edit#add_ft_head_tamplate('lua', s:lua_file_head)
" Format on save
if s:format_on_save
call SpaceVim#layers#format#add_filetype({
\ 'filetype' : 'lua',
\ 'enable' : 1,
\ })
endif
endfunction
function! SpaceVim#layers#lang#lua#set_variable(opt) abort
let s:lua_repl_command = get(a:opt, 'repl_command', '')
let s:lua_foldmethod = get(a:opt, 'foldmethod', 'manual')
let s:format_on_save = get(a:var, 'format_on_save', s:format_on_save)
endfunction
" Add language specific mappings

View File

@ -3151,6 +3151,32 @@ development.
name = 'lang#lua'
<
LAYER OPTIONS
1. lua_file_head: the default file head for lua source code.
>
[layers]
name = "lang#lua"
ruby_file_head = [
'--!/usr/bin/lua',
''
]
<
2. repl_command: the REPL command for lua
>
[[layers]]
name = 'lang#lua'
repl_command = '~/download/bin/lua'
<
3. format_on_save: enable/disable code formation when save lua file. This
options is disabled by default, to enable it:
>
[[layers]]
name = 'lang#lua'
format_on_save = true
<
KEY BINDINGS
>