mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 17:50:04 +08:00
Add format_on_save toggle for javascript (#4183)
This commit is contained in:
parent
a74237108a
commit
a1909e1b69
@ -47,7 +47,7 @@
|
||||
" <
|
||||
"
|
||||
|
||||
|
||||
let s:format_on_save = 0
|
||||
|
||||
function! SpaceVim#layers#lang#javascript#plugins() abort
|
||||
let plugins = [
|
||||
@ -86,6 +86,9 @@ let s:enable_flow_syntax = 0
|
||||
function! SpaceVim#layers#lang#javascript#set_variable(var) abort
|
||||
let s:auto_fix = get(a:var, 'auto_fix', 0)
|
||||
let s:enable_flow_syntax = get(a:var, 'enable_flow_syntax', 0)
|
||||
let s:format_on_save = get(a:var,
|
||||
\ 'format_on_save',
|
||||
\ s:format_on_save)
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lang#javascript#config() abort
|
||||
@ -136,6 +139,14 @@ function! SpaceVim#layers#lang#javascript#config() abort
|
||||
" be flushed by sender.
|
||||
" Use node -i will show the output of repl command.
|
||||
call SpaceVim#plugins#repl#reg('javascript', ['node', '-i'])
|
||||
|
||||
" Format on save
|
||||
if s:format_on_save
|
||||
call SpaceVim#layers#format#add_filetype({
|
||||
\ 'filetype' : 'javascript',
|
||||
\ 'enable' : 1,
|
||||
\ })
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:on_ft() abort
|
||||
|
@ -53,6 +53,15 @@ auto_fix = true
|
||||
enable_flow_syntax = true
|
||||
```
|
||||
|
||||
`format_on_save`: Enable/disable file formatting when saving current javascript file. By default,
|
||||
it is disabled, to enable it:
|
||||
```toml
|
||||
[[layers]]
|
||||
name = 'lang#javascript'
|
||||
format_on_save = true
|
||||
```
|
||||
|
||||
|
||||
## Key bindings
|
||||
|
||||
### Import key bindings
|
||||
|
Loading…
Reference in New Issue
Block a user