summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/engine.vim4
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/mix_format.vim16
-rw-r--r--autoload/ale/gradle.vim15
4 files changed, 37 insertions, 3 deletions
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index 890d3df2..1b22df46 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -841,7 +841,7 @@ function! ale#engine#WaitForJobs(deadline) abort
" Gather all of the jobs from every buffer.
for l:info in values(g:ale_buffer_info)
- call extend(l:job_list, l:info.job_list)
+ call extend(l:job_list, get(l:info, 'job_list', []))
endfor
" NeoVim has a built-in API for this, so use that.
@@ -889,7 +889,7 @@ function! ale#engine#WaitForJobs(deadline) abort
" Check again to see if any jobs are running.
for l:info in values(g:ale_buffer_info)
- for l:job_id in l:info.job_list
+ for l:job_id in get(l:info, 'job_list', [])
if ale#job#IsRunning(l:job_id)
let l:has_new_jobs = 1
break
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 07daa402..e17521f4 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -27,6 +27,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['javascript', 'typescript'],
\ 'description': 'Apply eslint --fix to a file.',
\ },
+\ 'mix_format': {
+\ 'function': 'ale#fixers#mix_format#Fix',
+\ 'suggested_filetypes': ['elixir'],
+\ 'description': 'Apply mix format to a file.',
+\ },
\ 'format': {
\ 'function': 'ale#fixers#format#Fix',
\ 'suggested_filetypes': ['elm'],
diff --git a/autoload/ale/fixers/mix_format.vim b/autoload/ale/fixers/mix_format.vim
new file mode 100644
index 00000000..04866408
--- /dev/null
+++ b/autoload/ale/fixers/mix_format.vim
@@ -0,0 +1,16 @@
+" Author: carakan <carakan@gmail.com>
+" Description: Fixing files with elixir formatter 'mix format'.
+
+call ale#Set('elixir_mix_executable', 'mix')
+
+function! ale#fixers#mix_format#GetExecutable(buffer) abort
+ return ale#Var(a:buffer, 'elixir_mix_executable')
+endfunction
+
+function! ale#fixers#mix_format#Fix(buffer) abort
+ return {
+ \ 'command': ale#Escape(ale#fixers#mix_format#GetExecutable(a:buffer))
+ \ . ' format %t',
+ \ 'read_temporary_file': 1,
+ \}
+endfunction
diff --git a/autoload/ale/gradle.vim b/autoload/ale/gradle.vim
index 89b56a82..dc377fb9 100644
--- a/autoload/ale/gradle.vim
+++ b/autoload/ale/gradle.vim
@@ -2,20 +2,30 @@
" Description: Functions for working with Gradle projects.
let s:script_path = fnamemodify(resolve(expand('<sfile>:p')), ':h')
+let s:init_path = has('win32')
+\ ? s:script_path . '\gradle\init.gradle'
+\ : s:script_path . '/gradle/init.gradle'
+
+function! ale#gradle#GetInitPath() abort
+ return s:init_path
+endfunction
" Given a buffer number, find a Gradle project root.
function! ale#gradle#FindProjectRoot(buffer) abort
let l:gradlew_path = ale#path#FindNearestFile(a:buffer, 'gradlew')
+
if !empty(l:gradlew_path)
return fnamemodify(l:gradlew_path, ':h')
endif
let l:settings_path = ale#path#FindNearestFile(a:buffer, 'settings.gradle')
+
if !empty(l:settings_path)
return fnamemodify(l:settings_path, ':h')
endif
let l:build_path = ale#path#FindNearestFile(a:buffer, 'build.gradle')
+
if !empty(l:build_path)
return fnamemodify(l:build_path, ':h')
endif
@@ -28,6 +38,7 @@ endfunction
" command. Returns an empty string if cannot find the executable.
function! ale#gradle#FindExecutable(buffer) abort
let l:gradlew_path = ale#path#FindNearestFile(a:buffer, 'gradlew')
+
if !empty(l:gradlew_path)
return l:gradlew_path
endif
@@ -47,7 +58,9 @@ function! ale#gradle#BuildClasspathCommand(buffer) abort
if !empty(l:executable) && !empty(l:project_root)
return ale#path#CdString(l:project_root)
- \ . l:executable . ' -I ' . s:script_path . '/gradle/init.gradle -q printClasspath'
+ \ . ale#Escape(l:executable)
+ \ . ' -I ' . ale#Escape(s:init_path)
+ \ . ' -q printClasspath'
endif
return ''