summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2018-04-24 21:48:33 +0100
committerw0rp <devw0rp@gmail.com>2018-04-24 21:48:33 +0100
commit41c0b837aec7770612274df1078ceddb6accd3f7 (patch)
tree7f6712e1b2fdfb7e017440b7c00e20f41824a160 /autoload
parentebbf7d0353d9d5d3ecc42bddd50e270ba60e5243 (diff)
downloadale-41c0b837aec7770612274df1078ceddb6accd3f7.zip
#1278 Allow linters to be defined pretty much anywhere
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/linter.vim18
1 files changed, 10 insertions, 8 deletions
diff --git a/autoload/ale/linter.vim b/autoload/ale/linter.vim
index 7e32b7bc..8aec2598 100644
--- a/autoload/ale/linter.vim
+++ b/autoload/ale/linter.vim
@@ -3,6 +3,7 @@ call ale#Set('wrap_command_as_one_argument', 0)
" Description: Linter registration and lazy-loading
" Retrieves linters as requested by the engine, loading them if needed.
+let s:runtime_loaded_map = {}
let s:linters = {}
" Default filetype aliases.
@@ -38,6 +39,7 @@ let s:default_ale_linters = {
" Testing/debugging helper to unload all linters.
function! ale#linter#Reset() abort
+ let s:runtime_loaded_map = {}
let s:linters = {}
endfunction
@@ -250,20 +252,20 @@ function! ale#linter#Define(filetype, linter) abort
call add(s:linters[a:filetype], l:new_linter)
endfunction
+" Prevent any linters from being loaded for a given filetype.
+function! ale#linter#PreventLoading(filetype) abort
+ let s:runtime_loaded_map[a:filetype] = 1
+endfunction
+
function! ale#linter#GetAll(filetypes) abort
let l:combined_linters = []
for l:filetype in a:filetypes
- " Load linter defintions from files if we haven't loaded them yet.
- if !has_key(s:linters, l:filetype)
+ " Load linters from runtimepath if we haven't done that yet.
+ if !has_key(s:runtime_loaded_map, l:filetype)
execute 'silent! runtime! ale_linters/' . l:filetype . '/*.vim'
- " Always set an empty List for the loaded linters if we don't find
- " any. This will prevent us from executing the runtime command
- " many times, redundantly.
- if !has_key(s:linters, l:filetype)
- let s:linters[l:filetype] = []
- endif
+ let s:runtime_loaded_map[l:filetype] = 1
endif
call extend(l:combined_linters, get(s:linters, l:filetype, []))