summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/events.vim2
-rw-r--r--autoload/ale/fixers/ocamlformat.vim6
-rw-r--r--autoload/ale/linter.vim2
-rw-r--r--doc/ale.txt5
-rw-r--r--test/fix/test_ale_fix.vader33
-rw-r--r--test/fixers/test_ocamlformat_fixer_callback.vader10
6 files changed, 47 insertions, 11 deletions
diff --git a/autoload/ale/events.vim b/autoload/ale/events.vim
index e48ad488..61a625df 100644
--- a/autoload/ale/events.vim
+++ b/autoload/ale/events.vim
@@ -29,7 +29,7 @@ function! ale#events#SaveEvent(buffer) abort
call setbufvar(a:buffer, 'ale_save_event_fired', 1)
endif
- if ale#Var(a:buffer, 'fix_on_save')
+ if ale#Var(a:buffer, 'fix_on_save') && !ale#events#QuitRecently(a:buffer)
let l:will_fix = ale#fix#Fix(a:buffer, 'save_file')
let l:should_lint = l:should_lint && !l:will_fix
endif
diff --git a/autoload/ale/fixers/ocamlformat.vim b/autoload/ale/fixers/ocamlformat.vim
index fac142aa..9b7c3e12 100644
--- a/autoload/ale/fixers/ocamlformat.vim
+++ b/autoload/ale/fixers/ocamlformat.vim
@@ -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
diff --git a/autoload/ale/linter.vim b/autoload/ale/linter.vim
index 114765e6..0a249282 100644
--- a/autoload/ale/linter.vim
+++ b/autoload/ale/linter.vim
@@ -16,6 +16,7 @@ let s:default_ale_linter_aliases = {
\ 'systemverilog': 'verilog',
\ 'verilog_systemverilog': ['verilog_systemverilog', 'verilog'],
\ 'vimwiki': 'markdown',
+\ 'vue': ['vue', 'javascript'],
\ 'zsh': 'sh',
\}
@@ -40,6 +41,7 @@ let s:default_ale_linters = {
\ 'rust': ['cargo'],
\ 'spec': [],
\ 'text': [],
+\ 'vue': ['eslint', 'vls'],
\ 'zsh': ['shell'],
\}
diff --git a/doc/ale.txt b/doc/ale.txt
index d4223f84..d619e526 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -1186,6 +1186,9 @@ b:ale_fix_on_save *b:ale_fix_on_save*
after files are fixed, only when the buffer is open, or re-opened. Changes
to the file will be saved to the file on disk.
+ Files will not be fixed on `:wq`, so you should check your code before
+ closing a buffer.
+
Fixing files can be disabled or enabled for individual buffers by setting
`b:ale_fix_on_save` to `0` or `1`.
@@ -1364,6 +1367,7 @@ g:ale_linter_aliases *g:ale_linter_aliases*
\ 'systemverilog': 'verilog',
\ 'verilog_systemverilog': ['verilog_systemverilog', 'verilog'],
\ 'vimwiki': 'markdown',
+ \ 'vue': ['vue', 'javascript'],
\ 'zsh': 'sh',
\}
<
@@ -1421,6 +1425,7 @@ g:ale_linters *g:ale_linters*
\ 'rust': ['cargo'],
\ 'spec': [],
\ 'text': [],
+ \ 'vue': ['eslint', 'vls'],
\ 'zsh': ['shell'],
\}
<
diff --git a/test/fix/test_ale_fix.vader b/test/fix/test_ale_fix.vader
index 539972a4..90407681 100644
--- a/test/fix/test_ale_fix.vader
+++ b/test/fix/test_ale_fix.vader
@@ -180,6 +180,7 @@ After:
unlet! g:ale_emulate_job_failure
unlet! b:ale_fixers
unlet! b:ale_fix_on_save
+ unlet! b:ale_quitting
delfunction AddCarets
delfunction AddDollars
delfunction DoNothing
@@ -431,7 +432,7 @@ Given testft (A file with three lines):
b
c
-Execute(ALEFix should save files on the save event):
+Execute(ALEFix should fix files on the save event):
let g:ale_fix_on_save = 1
let g:ale_lint_on_save = 1
let g:ale_enabled = 1
@@ -471,6 +472,36 @@ Expect(The buffer should be modified):
$b
$c
+Execute(ALEFix should not fix files on :wq):
+ let g:ale_fix_on_save = 1
+ let g:ale_lint_on_save = 1
+ let g:ale_enabled = 1
+
+ noautocmd silent file fix_test_file
+ call writefile(getline(1, '$'), 'fix_test_file')
+
+ let g:ale_fixers.testft = ['AddDollars']
+
+ " We have to set the buftype to empty so the file will be written.
+ setlocal buftype=
+
+ call ale#events#QuitEvent(bufnr(''))
+
+ call SetUpLinters()
+ call ale#events#SaveEvent(bufnr(''))
+
+ " We should save the file.
+ AssertEqual ['a', 'b', 'c'], readfile('fix_test_file')
+ Assert &modified, 'The was not marked as ''modified'''
+
+ " We should not run the linter.
+ AssertEqual [], ale#test#GetLoclistWithoutModule()
+
+Expect(The buffer should not be modified):
+ a
+ b
+ c
+
Given testft (A file with three lines):
a
b
diff --git a/test/fixers/test_ocamlformat_fixer_callback.vader b/test/fixers/test_ocamlformat_fixer_callback.vader
index d2aee066..f0c36ed7 100644
--- a/test/fixers/test_ocamlformat_fixer_callback.vader
+++ b/test/fixers/test_ocamlformat_fixer_callback.vader
@@ -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(''))