mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-30 22:55:30 +08:00
#1278 Allow linters to be defined pretty much anywhere
This commit is contained in:
@@ -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, []))
|
||||
|
||||
Reference in New Issue
Block a user