summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-05-18 17:26:17 +0100
committerw0rp <devw0rp@gmail.com>2017-05-20 19:02:36 +0100
commit05bab00c3c9878229e8b3cb8df3dc66a7ad9ee7f (patch)
treeb14e0b90ddeb36537c3baa453011092108dce9c0
parent8ebd15a54dba474ee634e0087bb460ca6e7d8428 (diff)
downloadale-05bab00c3c9878229e8b3cb8df3dc66a7ad9ee7f.zip
Allow strings to be used for selecting a single fix function for g:ale_fixers too
-rw-r--r--autoload/ale/fix.vim8
-rw-r--r--test/test_ale_fix.vader9
2 files changed, 16 insertions, 1 deletions
diff --git a/autoload/ale/fix.vim b/autoload/ale/fix.vim
index 6ed750ce..70a36edc 100644
--- a/autoload/ale/fix.vim
+++ b/autoload/ale/fix.vim
@@ -225,7 +225,13 @@ function! ale#fix#Fix() abort
let l:callback_list = []
for l:sub_type in split(&filetype, '\.')
- call extend(l:callback_list, get(g:ale_fixers, l:sub_type, []))
+ let l:sub_type_callacks = get(g:ale_fixers, l:sub_type, [])
+
+ if type(l:sub_type_callacks) == type('')
+ call add(l:callback_list, l:sub_type_callacks)
+ else
+ call extend(l:callback_list, l:sub_type_callacks)
+ endif
endfor
if empty(l:callback_list)
diff --git a/test/test_ale_fix.vader b/test/test_ale_fix.vader
index 50e0e065..95a37c6b 100644
--- a/test/test_ale_fix.vader
+++ b/test/test_ale_fix.vader
@@ -107,3 +107,12 @@ Expect(Only the second function should be applied):
$a
$b
$c
+
+Execute(ALEFix should handle strings for selecting a single function):
+ let g:ale_fixers.testft = 'AddCarets'
+ ALEFix
+
+Expect(The first function should be used):
+ ^a
+ ^b
+ ^c