summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/elixir/elixir_ls.vim2
-rw-r--r--autoload/ale/events.vim2
-rw-r--r--autoload/ale/fixers/ocamlformat.vim6
-rw-r--r--autoload/ale/handlers/elixir.vim21
-rw-r--r--autoload/ale/linter.vim2
-rw-r--r--doc/ale-typescript.txt4
-rw-r--r--doc/ale.txt5
-rw-r--r--test/command_callback/elixir_paths/mix_project/lib/app.ex (renamed from test/command_callback/elixir_paths/mix_project/lib/foo.ex)0
-rw-r--r--test/command_callback/elixir_paths/umbrella_project/apps/app1/lib/app.ex0
-rw-r--r--test/command_callback/elixir_paths/umbrella_project/apps/app1/mix.exs0
-rw-r--r--test/command_callback/elixir_paths/umbrella_project/apps/app2/lib/app.ex0
-rw-r--r--test/command_callback/elixir_paths/umbrella_project/apps/app2/mix.exs0
-rw-r--r--test/command_callback/elixir_paths/umbrella_project/mix.exs0
-rw-r--r--test/command_callback/mix_paths/wrapped_project/mix.exs1
-rw-r--r--test/command_callback/test_elixir_ls_command_callbacks.vader4
-rw-r--r--test/command_callback/test_elixir_mix_command_callbacks.vader19
-rw-r--r--test/fix/test_ale_fix.vader33
-rw-r--r--test/fixers/test_ocamlformat_fixer_callback.vader10
18 files changed, 84 insertions, 25 deletions
diff --git a/ale_linters/elixir/elixir_ls.vim b/ale_linters/elixir/elixir_ls.vim
index c1e8fdd6..3b299ec6 100644
--- a/ale_linters/elixir/elixir_ls.vim
+++ b/ale_linters/elixir/elixir_ls.vim
@@ -16,6 +16,6 @@ call ale#linter#Define('elixir', {
\ 'lsp': 'stdio',
\ 'executable_callback': 'ale_linters#elixir#elixir_ls#GetExecutable',
\ 'command_callback': 'ale_linters#elixir#elixir_ls#GetExecutable',
-\ 'project_root_callback': 'ale#handlers#elixir#FindMixProjectRoot',
+\ 'project_root_callback': 'ale#handlers#elixir#FindMixUmbrellaRoot',
\ 'lsp_config_callback': ale#VarFunc('elixir_elixir_ls_config'),
\})
diff --git a/autoload/ale/events.vim b/autoload/ale/events.vim
index 55e0a6cc..c3dbd378 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/handlers/elixir.vim b/autoload/ale/handlers/elixir.vim
index 91b75aac..2fddf8e7 100644
--- a/autoload/ale/handlers/elixir.vim
+++ b/autoload/ale/handlers/elixir.vim
@@ -1,13 +1,28 @@
" Author: Matteo Centenaro (bugant) - https://github.com/bugant
-"
-" Description: find the root directory for an elixir project that uses mix
+" Author: Jon Parise <jon@indelible.org>
+" Description: Functions for working with Elixir projects
+" Find the root directory for an elixir project that uses mix.
function! ale#handlers#elixir#FindMixProjectRoot(buffer) abort
let l:mix_file = ale#path#FindNearestFile(a:buffer, 'mix.exs')
if !empty(l:mix_file)
- return fnamemodify(l:mix_file, ':p:h')
+ return fnamemodify(l:mix_file, ':p:h')
endif
return '.'
endfunction
+
+" Similar to ale#handlers#elixir#FindMixProjectRoot but also continue the
+" search upward for a potential umbrella project root. If an umbrella root
+" does not exist, the initial project root will be returned.
+function! ale#handlers#elixir#FindMixUmbrellaRoot(buffer) abort
+ let l:app_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer)
+ let l:umbrella_root = fnamemodify(l:app_root, ':h:h')
+
+ if filereadable(l:umbrella_root . '/mix.exs')
+ return l:umbrella_root
+ endif
+
+ return l:app_root
+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-typescript.txt b/doc/ale-typescript.txt
index 0cb0a7c2..7dc59820 100644
--- a/doc/ale-typescript.txt
+++ b/doc/ale-typescript.txt
@@ -21,9 +21,11 @@ tslint *ale-typescript-tslint*
This linter isn't recommended, because TSLint can't be used for checking for
problems while you type. You should probably use the tsserver plugin instead.
+tsserver plugins are described here:
+https://github.com/Microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin
Follow the instructions on the plugin website for installing it:
-https://github.com/angelozerr/tsserver-plugins
+https://github.com/Microsoft/typescript-tslint-plugin
Then disable TSLint in vimrc or any other Vim configuration file. >
let g:ale_linters_ignore = {'typescript': ['tslint']}
diff --git a/doc/ale.txt b/doc/ale.txt
index d260b40e..5da95930 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -1187,6 +1187,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`.
@@ -1365,6 +1368,7 @@ g:ale_linter_aliases *g:ale_linter_aliases*
\ 'systemverilog': 'verilog',
\ 'verilog_systemverilog': ['verilog_systemverilog', 'verilog'],
\ 'vimwiki': 'markdown',
+ \ 'vue': ['vue', 'javascript'],
\ 'zsh': 'sh',
\}
<
@@ -1422,6 +1426,7 @@ g:ale_linters *g:ale_linters*
\ 'rust': ['cargo'],
\ 'spec': [],
\ 'text': [],
+ \ 'vue': ['eslint', 'vls'],
\ 'zsh': ['shell'],
\}
<
diff --git a/test/command_callback/elixir_paths/mix_project/lib/foo.ex b/test/command_callback/elixir_paths/mix_project/lib/app.ex
index e69de29b..e69de29b 100644
--- a/test/command_callback/elixir_paths/mix_project/lib/foo.ex
+++ b/test/command_callback/elixir_paths/mix_project/lib/app.ex
diff --git a/test/command_callback/elixir_paths/umbrella_project/apps/app1/lib/app.ex b/test/command_callback/elixir_paths/umbrella_project/apps/app1/lib/app.ex
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/elixir_paths/umbrella_project/apps/app1/lib/app.ex
diff --git a/test/command_callback/elixir_paths/umbrella_project/apps/app1/mix.exs b/test/command_callback/elixir_paths/umbrella_project/apps/app1/mix.exs
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/elixir_paths/umbrella_project/apps/app1/mix.exs
diff --git a/test/command_callback/elixir_paths/umbrella_project/apps/app2/lib/app.ex b/test/command_callback/elixir_paths/umbrella_project/apps/app2/lib/app.ex
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/elixir_paths/umbrella_project/apps/app2/lib/app.ex
diff --git a/test/command_callback/elixir_paths/umbrella_project/apps/app2/mix.exs b/test/command_callback/elixir_paths/umbrella_project/apps/app2/mix.exs
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/elixir_paths/umbrella_project/apps/app2/mix.exs
diff --git a/test/command_callback/elixir_paths/umbrella_project/mix.exs b/test/command_callback/elixir_paths/umbrella_project/mix.exs
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/elixir_paths/umbrella_project/mix.exs
diff --git a/test/command_callback/mix_paths/wrapped_project/mix.exs b/test/command_callback/mix_paths/wrapped_project/mix.exs
deleted file mode 100644
index d2d855e6..00000000
--- a/test/command_callback/mix_paths/wrapped_project/mix.exs
+++ /dev/null
@@ -1 +0,0 @@
-use Mix.Config
diff --git a/test/command_callback/test_elixir_ls_command_callbacks.vader b/test/command_callback/test_elixir_ls_command_callbacks.vader
index 5a8d8496..ca785054 100644
--- a/test/command_callback/test_elixir_ls_command_callbacks.vader
+++ b/test/command_callback/test_elixir_ls_command_callbacks.vader
@@ -22,12 +22,12 @@ Execute(should configure elixir-ls release location):
AssertLinter 'boo/language_server.sh', 'boo/language_server.sh'
Execute(should set correct LSP values):
- call ale#test#SetFilename('mix_paths/wrapped_project/lib/app.ex')
+ call ale#test#SetFilename('elixir_paths/umbrella_project/apps/app1/lib/app.ex')
AssertLSPLanguage 'elixir'
AssertLSPOptions {}
AssertLSPConfig {}
- AssertLSPProject ale#path#Simplify(g:dir . '/mix_paths/wrapped_project')
+ AssertLSPProject ale#path#Simplify(g:dir . '/elixir_paths/umbrella_project')
Execute(should accept configuration settings):
AssertLSPConfig {}
diff --git a/test/command_callback/test_elixir_mix_command_callbacks.vader b/test/command_callback/test_elixir_mix_command_callbacks.vader
index 9315a850..b0d0af98 100644
--- a/test/command_callback/test_elixir_mix_command_callbacks.vader
+++ b/test/command_callback/test_elixir_mix_command_callbacks.vader
@@ -11,16 +11,23 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The default mix command should be correct):
- call ale#test#SetFilename('mix_paths/wrapped_project/lib/app.ex')
+ call ale#test#SetFilename('elixir_paths/mix_project/lib/app.ex')
AssertLinter 'mix',
- \ ale#path#CdString(ale#path#Simplify(g:dir . '/mix_paths/wrapped_project'))
+ \ ale#path#CdString(ale#path#Simplify(g:dir . '/elixir_paths/mix_project'))
\ . g:env_prefix
\ . 'mix compile %s'
-Execute(The FindMixProjectRoot should detect the project root directory via mix.exs):
- silent execute 'file ' . fnameescape(g:dir . '/elixir_paths/mix_project/lib/app.ex')
+Execute(FindMixProjectRoot should detect the project root directory via mix.exs):
+ silent execute 'file ' . fnameescape(g:dir . '/elixir_paths/mix_project/lib/app.ex')
- AssertEqual
- \ ale#path#Simplify(g:dir . '/elixir_paths/mix_project'),
+ AssertEqual
+ \ ale#path#Simplify(g:dir . '/elixir_paths/mix_project'),
\ ale#handlers#elixir#FindMixProjectRoot(bufnr(''))
+
+Execute(FindMixUmbrellaRoot should detect the umbrella root directory via mix.exs):
+ silent execute 'file ' . fnameescape(g:dir . '/elixir_paths/umbrella_project/apps/app1/lib/app.ex')
+
+ AssertEqual
+ \ ale#path#Simplify(g:dir . '/elixir_paths/umbrella_project'),
+ \ ale#handlers#elixir#FindMixUmbrellaRoot(bufnr(''))
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(''))