mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-23 17:49:57 +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
|
function! SpaceVim#layers#lang#javascript#plugins() abort
|
||||||
let plugins = [
|
let plugins = [
|
||||||
@ -86,6 +86,9 @@ let s:enable_flow_syntax = 0
|
|||||||
function! SpaceVim#layers#lang#javascript#set_variable(var) abort
|
function! SpaceVim#layers#lang#javascript#set_variable(var) abort
|
||||||
let s:auto_fix = get(a:var, 'auto_fix', 0)
|
let s:auto_fix = get(a:var, 'auto_fix', 0)
|
||||||
let s:enable_flow_syntax = get(a:var, 'enable_flow_syntax', 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
|
endfunction
|
||||||
|
|
||||||
function! SpaceVim#layers#lang#javascript#config() abort
|
function! SpaceVim#layers#lang#javascript#config() abort
|
||||||
@ -136,6 +139,14 @@ function! SpaceVim#layers#lang#javascript#config() abort
|
|||||||
" be flushed by sender.
|
" be flushed by sender.
|
||||||
" Use node -i will show the output of repl command.
|
" Use node -i will show the output of repl command.
|
||||||
call SpaceVim#plugins#repl#reg('javascript', ['node', '-i'])
|
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
|
endfunction
|
||||||
|
|
||||||
function! s:on_ft() abort
|
function! s:on_ft() abort
|
||||||
|
@ -53,6 +53,15 @@ auto_fix = true
|
|||||||
enable_flow_syntax = 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
|
## Key bindings
|
||||||
|
|
||||||
### Import key bindings
|
### Import key bindings
|
||||||
|
Loading…
x
Reference in New Issue
Block a user