mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated plugins
This commit is contained in:
43
sources_non_forked/ale/ale_linters/sh/bashate.vim
Normal file
43
sources_non_forked/ale/ale_linters/sh/bashate.vim
Normal file
@ -0,0 +1,43 @@
|
||||
" Author: hsanson <hsanson@gmail.com>
|
||||
" Description: Lints sh files using bashate
|
||||
" URL: https://github.com/openstack/bashate
|
||||
|
||||
call ale#Set('sh_bashate_executable', 'bashate')
|
||||
call ale#Set('sh_bashate_options', '')
|
||||
|
||||
function! ale_linters#sh#bashate#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'sh_bashate_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#sh#bashate#GetCommand(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'sh_bashate_options')
|
||||
let l:executable = ale_linters#sh#bashate#GetExecutable(a:buffer)
|
||||
|
||||
return ale#Escape(l:executable) . ' ' . l:options . ' ' . '%t'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#sh#bashate#Handle(buffer, lines) abort
|
||||
" Matches patterns line the following:
|
||||
"
|
||||
" /path/to/script/file:694:1: E003 Indent not multiple of 4
|
||||
let l:pattern = ':\(\d\+\):\(\d\+\): \(.*\)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'lnum': str2nr(l:match[1]),
|
||||
\ 'col': str2nr(l:match[2]),
|
||||
\ 'text': l:match[3],
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('sh', {
|
||||
\ 'name': 'bashate',
|
||||
\ 'output_stream': 'stdout',
|
||||
\ 'executable': function('ale_linters#sh#bashate#GetExecutable'),
|
||||
\ 'command': function('ale_linters#sh#bashate#GetCommand'),
|
||||
\ 'callback': 'ale_linters#sh#bashate#Handle',
|
||||
\})
|
@ -1,5 +1,5 @@
|
||||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: Lints sh files using bash -n
|
||||
" Description: Lints shell files by invoking the shell with -n
|
||||
|
||||
" Backwards compatibility
|
||||
if exists('g:ale_linters_sh_shell_default_shell')
|
||||
|
Reference in New Issue
Block a user