mirror of https://github.com/dense-analysis/ale
Merge pull request #2053 from andreypopp/fix-ocamlformat-stdin-stdout
Make ocamlformat work without temporary files
This commit is contained in:
commit
90f2875f29
|
@ -5,14 +5,14 @@ call ale#Set('ocaml_ocamlformat_executable', 'ocamlformat')
|
|||
call ale#Set('ocaml_ocamlformat_options', '')
|
||||
|
||||
function! ale#fixers#ocamlformat#Fix(buffer) abort
|
||||
let l:filename = expand('#' . a:buffer . ':p')
|
||||
let l:executable = ale#Var(a:buffer, 'ocaml_ocamlformat_executable')
|
||||
let l:options = ale#Var(a:buffer, 'ocaml_ocamlformat_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . (empty(l:options) ? '' : ' ' . l:options)
|
||||
\ . ' --inplace'
|
||||
\ . ' %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\ . ' --name=' . ale#Escape(l:filename)
|
||||
\ . ' -'
|
||||
\}
|
||||
endfunction
|
||||
|
|
|
@ -18,10 +18,9 @@ Execute(The ocamlformat callback should return the correct default values):
|
|||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape('xxxinvalid')
|
||||
\ . ' --inplace'
|
||||
\ . ' %t',
|
||||
\ . ' --name=' . ale#Escape(bufname(bufnr('')))
|
||||
\ . ' -',
|
||||
\ },
|
||||
\ ale#fixers#ocamlformat#Fix(bufnr(''))
|
||||
|
||||
|
@ -31,10 +30,9 @@ Execute(The ocamlformat callback should include custom ocamlformat options):
|
|||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape('xxxinvalid')
|
||||
\ . ' ' . g:ale_ocaml_ocamlformat_options
|
||||
\ . ' --inplace'
|
||||
\ . ' %t',
|
||||
\ . ' --name=' . ale#Escape(bufname(bufnr('')))
|
||||
\ . ' -',
|
||||
\ },
|
||||
\ ale#fixers#ocamlformat#Fix(bufnr(''))
|
||||
|
|
Loading…
Reference in New Issue