func! ShouldReformat()
return normal :w !elm-format --stdin --validate
endfunc
func! Reformat()
if ShouldReformat()
normal gggqG
endif
endfunc
But return normal
is not taken into account, how can I test that ?
func! ShouldReformat()
return normal :w !elm-format --stdin --validate
endfunc
func! Reformat()
if ShouldReformat()
normal gggqG
endif
endfunc
But return normal
is not taken into account, how can I test that ?
func! ShouldReformat()
write !elm-format --stdin --validate
return v:shell_error
endfunc
v:shell_error
returns the last shell execution exit code
:help shell_error
v:shell_error Result of the last shell command. When non-zero, the last
shell command had an error. When zero, there was no problem.
This only works when the shell returns the error code to Vim.
The value -1 is often used when the command could not be
executed. Read-only.
write !elm-format …
is fine.