From e85eb824016a0ca4217d41cc2ec603ff22a3b74d Mon Sep 17 00:00:00 2001 From: w0rp Date: Sun, 7 Apr 2019 15:34:39 +0100 Subject: #2132 - Implement feature tests with ale#Has --- autoload/ale.vim | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'autoload/ale.vim') diff --git a/autoload/ale.vim b/autoload/ale.vim index bcb89095..cd106887 100644 --- a/autoload/ale.vim +++ b/autoload/ale.vim @@ -151,12 +151,19 @@ function! ale#Queue(delay, ...) abort endif endfunction -let g:ale_has_override = get(g:, 'ale_has_override', {}) +let s:current_ale_version = [2, 4, 0] -" Call has(), but check a global Dictionary so we can force flags on or off -" for testing purposes. +" A function used to check for ALE features in files outside of the project. function! ale#Has(feature) abort - return get(g:ale_has_override, a:feature, has(a:feature)) + let l:match = matchlist(a:feature, '\c\v^ale-(\d+)\.(\d+)(\.(\d+))?$') + + if !empty(l:match) + let l:version = [l:match[1] + 0, l:match[2] + 0, l:match[4] + 0] + + return ale#semver#GTE(s:current_ale_version, l:version) + endif + + return 0 endfunction " Given a buffer number and a variable name, look for that variable in the -- cgit v1.2.3