From b0bba34ea2228ac73ecc63f1c459daf2a02066c4 Mon Sep 17 00:00:00 2001 From: Adriaan Zonnenberg Date: Sat, 29 Apr 2017 20:57:34 +0200 Subject: [PATCH] Rename g:ale_linters_sh_* to g:ale_sh_* --- ale_linters/sh/shell.vim | 15 ++++++++++----- ale_linters/sh/shellcheck.vim | 9 ++++----- doc/ale-sh.txt | 10 +++++----- test/test_backwards_compatibility.vader | 19 +++++++++++++++++++ 4 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 test/test_backwards_compatibility.vader diff --git a/ale_linters/sh/shell.vim b/ale_linters/sh/shell.vim index cd36309..3b017b0 100644 --- a/ale_linters/sh/shell.vim +++ b/ale_linters/sh/shell.vim @@ -1,13 +1,18 @@ " Author: w0rp " Description: Lints sh files using bash -n +" Backwards compatibility +if exists('g:ale_linters_sh_shell_default_shell') + let g:ale_sh_shell_default_shell = g:ale_linters_sh_shell_default_shell +endif + " This option can be changed to change the default shell when the shell " cannot be taken from the hashbang line. -if !exists('g:ale_linters_sh_shell_default_shell') - let g:ale_linters_sh_shell_default_shell = fnamemodify($SHELL, ':t') +if !exists('g:ale_sh_shell_default_shell') + let g:ale_sh_shell_default_shell = fnamemodify($SHELL, ':t') - if g:ale_linters_sh_shell_default_shell ==# '' - let g:ale_linters_sh_shell_default_shell = 'bash' + if g:ale_sh_shell_default_shell ==# '' + let g:ale_sh_shell_default_shell = 'bash' endif endif @@ -26,7 +31,7 @@ function! ale_linters#sh#shell#GetExecutable(buffer) abort endfor endif - return ale#Var(a:buffer, 'linters_sh_shell_default_shell') + return ale#Var(a:buffer, 'sh_shell_default_shell') endfunction function! ale_linters#sh#shell#GetCommand(buffer) abort diff --git a/ale_linters/sh/shellcheck.vim b/ale_linters/sh/shellcheck.vim index b4a622a..5353683 100644 --- a/ale_linters/sh/shellcheck.vim +++ b/ale_linters/sh/shellcheck.vim @@ -5,10 +5,9 @@ " This global variable can be set with a string of comma-seperated error " codes to exclude from shellcheck. For example: " -" let g:ale_linters_sh_shellcheck_exclusions = 'SC2002,SC2004' -if !exists('g:ale_linters_sh_shellcheck_exclusions') - let g:ale_linters_sh_shellcheck_exclusions = '' -endif +" let g:ale_sh_shellcheck_exclusions = 'SC2002,SC2004' +let g:ale_sh_shellcheck_exclusions = +\ get(g:, 'ale_sh_shellcheck_exclusions', get(g:, 'ale_linters_sh_shellcheck_exclusions', '')) let g:ale_sh_shellcheck_executable = \ get(g:, 'ale_sh_shellcheck_executable', 'shellcheck') @@ -33,7 +32,7 @@ function! s:GetDialectArgument() abort endfunction function! ale_linters#sh#shellcheck#GetCommand(buffer) abort - let l:exclude_option = ale#Var(a:buffer, 'linters_sh_shellcheck_exclusions') + let l:exclude_option = ale#Var(a:buffer, 'sh_shellcheck_exclusions') return ale_linters#sh#shellcheck#GetExecutable(a:buffer) \ . ' ' . ale#Var(a:buffer, 'sh_shellcheck_options') diff --git a/doc/ale-sh.txt b/doc/ale-sh.txt index 597b75f..1d9f12f 100644 --- a/doc/ale-sh.txt +++ b/doc/ale-sh.txt @@ -5,8 +5,8 @@ ALE Shell Integration *ale-sh-options* ------------------------------------------------------------------------------- shell *ale-sh-shell* -g:ale_linters_sh_shell_default_shell *g:ale_linters_sh_shell_default_shell* - *b:ale_linters_sh_shell_default_shell* +g:ale_sh_shell_default_shell *g:ale_sh_shell_default_shell* + *b:ale_sh_shell_default_shell* Type: |String| Default: The current shell (`$SHELL`) or `'bash'` if that cannot be read. @@ -41,8 +41,8 @@ g:ale_sh_shellcheck_options *g:ale_sh_shellcheck_options* let g:ale_sh_shellcheck_options = '-x' < -g:ale_linters_sh_shellcheck_exclusions *g:ale_linters_sh_shellcheck_exclusions* - *b:ale_linters_sh_shellcheck_exclusions* +g:ale_sh_shellcheck_exclusions *g:ale_sh_shellcheck_exclusions* + *b:ale_sh_shellcheck_exclusions* Type: |String| Default: `''` @@ -53,7 +53,7 @@ g:ale_linters_sh_shellcheck_exclusions *g:ale_linters_sh_shellcheck_exclusions* will be sourced by other scripts, use the buffer-local variant: > autocmd BufEnter PKGBUILD,.env - \ let b:ale_linters_sh_shellcheck_exclusions = 'SC2034,SC2154,SC2164' + \ let b:ale_sh_shellcheck_exclusions = 'SC2034,SC2154,SC2164' < ------------------------------------------------------------------------------- diff --git a/test/test_backwards_compatibility.vader b/test/test_backwards_compatibility.vader new file mode 100644 index 0000000..e4e3756 --- /dev/null +++ b/test/test_backwards_compatibility.vader @@ -0,0 +1,19 @@ +" These tests, and the code that it covers, may be removed upon a major release. + +After: + unlet! g:ale_linters_sh_shellcheck_exclusions + unlet! g:ale_sh_shellcheck_exclusions + unlet! g:ale_linters_sh_shell_default_shell + unlet! g:ale_sh_shell_default_shell + +Execute(Old variable name for the 'shellcheck' linter should still work): + let g:ale_linters_sh_shellcheck_exclusions = 'SC1234' + runtime ale_linters/sh/shellcheck.vim + + AssertEqual 'SC1234', g:ale_sh_shellcheck_exclusions + +Execute (Old variable name for the 'shell' linter should still work): + let g:ale_linters_sh_shell_default_shell = 'woosh' + runtime ale_linters/sh/shell.vim + + AssertEqual 'woosh', g:ale_sh_shell_default_shell