mirror of
https://github.com/amix/vimrc
synced 2025-07-01 20:55:00 +08:00
Updated plugins
This commit is contained in:
@ -26,7 +26,7 @@ function! ale_linters#bicep#bicep#Command(buffer) abort
|
||||
\ . l:nullfile
|
||||
\ . ' '
|
||||
\ . l:options
|
||||
\ . ' %t'
|
||||
\ . ' %s'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#bicep#bicep#Handle(buffer, lines) abort
|
||||
@ -60,4 +60,5 @@ call ale#linter#Define('bicep', {
|
||||
\ 'command': function('ale_linters#bicep#bicep#Command'),
|
||||
\ 'callback': 'ale_linters#bicep#bicep#Handle',
|
||||
\ 'output_stream': 'both',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
call ale#Set('c_cc_executable', '<auto>')
|
||||
call ale#Set('c_cc_options', '-std=c11 -Wall')
|
||||
call ale#Set('c_cc_use_header_lang_flag', -1)
|
||||
call ale#Set('c_cc_header_exts', ['h'])
|
||||
|
||||
function! ale_linters#c#cc#GetExecutable(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'c_cc_executable')
|
||||
@ -31,12 +33,24 @@ function! ale_linters#c#cc#GetCommand(buffer, output) abort
|
||||
\ 'g')
|
||||
endif
|
||||
|
||||
" Select the correct language flag depending on the executable, options
|
||||
" and file extension
|
||||
let l:executable = ale_linters#c#cc#GetExecutable(a:buffer)
|
||||
let l:use_header_lang_flag = ale#Var(a:buffer, 'c_cc_use_header_lang_flag')
|
||||
let l:header_exts = ale#Var(a:buffer, 'c_cc_header_exts')
|
||||
let l:lang_flag = ale#c#GetLanguageFlag(
|
||||
\ a:buffer,
|
||||
\ l:executable,
|
||||
\ l:use_header_lang_flag,
|
||||
\ l:header_exts,
|
||||
\ 'c')
|
||||
|
||||
" -iquote with the directory the file is in makes #include work for
|
||||
" headers in the same directory.
|
||||
"
|
||||
" `-o /dev/null` or `-o null` is needed to catch all errors,
|
||||
" -fsyntax-only doesn't catch everything.
|
||||
return '%e -S -x c'
|
||||
return '%e -S -x ' . l:lang_flag
|
||||
\ . ' -o ' . g:ale#util#nul_file
|
||||
\ . ' -iquote %s:h'
|
||||
\ . ale#Pad(l:cflags)
|
||||
|
@ -8,7 +8,8 @@ function! ale_linters#clojure#clj_kondo#GetCommand(buffer) abort
|
||||
|
||||
let l:command = 'clj-kondo'
|
||||
\ . ale#Pad(l:options)
|
||||
\ . ' --lint %t'
|
||||
\ . ' --lint -'
|
||||
\ . ' --filename %s'
|
||||
|
||||
return l:command
|
||||
endfunction
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
call ale#Set('cpp_cc_executable', '<auto>')
|
||||
call ale#Set('cpp_cc_options', '-std=c++14 -Wall')
|
||||
call ale#Set('cpp_cc_use_header_lang_flag', -1)
|
||||
call ale#Set('cpp_cc_header_exts', ['h', 'hpp'])
|
||||
|
||||
function! ale_linters#cpp#cc#GetExecutable(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'cpp_cc_executable')
|
||||
@ -31,12 +33,24 @@ function! ale_linters#cpp#cc#GetCommand(buffer, output) abort
|
||||
\ 'g')
|
||||
endif
|
||||
|
||||
" Select the correct language flag depending on the executable, options
|
||||
" and file extension
|
||||
let l:executable = ale_linters#cpp#cc#GetExecutable(a:buffer)
|
||||
let l:use_header_lang_flag = ale#Var(a:buffer, 'cpp_cc_use_header_lang_flag')
|
||||
let l:header_exts = ale#Var(a:buffer, 'cpp_cc_header_exts')
|
||||
let l:lang_flag = ale#c#GetLanguageFlag(
|
||||
\ a:buffer,
|
||||
\ l:executable,
|
||||
\ l:use_header_lang_flag,
|
||||
\ l:header_exts,
|
||||
\ 'c++')
|
||||
|
||||
" -iquote with the directory the file is in makes #include work for
|
||||
" headers in the same directory.
|
||||
"
|
||||
" `-o /dev/null` or `-o null` is needed to catch all errors,
|
||||
" -fsyntax-only doesn't catch everything.
|
||||
return '%e -S -x c++'
|
||||
return '%e -S -x ' . l:lang_flag
|
||||
\ . ' -o ' . g:ale#util#nul_file
|
||||
\ . ' -iquote %s:h'
|
||||
\ . ale#Pad(l:cflags)
|
||||
|
87
sources_non_forked/ale/ale_linters/terraform/tfsec.vim
Normal file
87
sources_non_forked/ale/ale_linters/terraform/tfsec.vim
Normal file
@ -0,0 +1,87 @@
|
||||
" Description: tfsec for Terraform files
|
||||
"
|
||||
" See: https://www.terraform.io/
|
||||
" https://github.com/aquasecurity/tfsec
|
||||
|
||||
call ale#Set('terraform_tfsec_options', '')
|
||||
call ale#Set('terraform_tfsec_executable', 'tfsec')
|
||||
|
||||
let s:separator = has('win32') ? '\' : '/'
|
||||
|
||||
function! ale_linters#terraform#tfsec#Handle(buffer, lines) abort
|
||||
let l:output = []
|
||||
let l:json = ale#util#FuzzyJSONDecode(a:lines, {})
|
||||
|
||||
" if there's no warning, 'result' is `null`.
|
||||
if empty(get(l:json, 'results'))
|
||||
return l:output
|
||||
endif
|
||||
|
||||
for l:result in get(l:json, 'results', [])
|
||||
if l:result.severity is# 'LOW'
|
||||
let l:type = 'I'
|
||||
elseif l:result.severity is# 'CRITICAL'
|
||||
let l:type = 'E'
|
||||
else
|
||||
let l:type = 'W'
|
||||
endif
|
||||
|
||||
call add(l:output, {
|
||||
\ 'filename': l:result.location.filename,
|
||||
\ 'lnum': l:result.location.start_line,
|
||||
\ 'end_lnum': l:result.location.end_line,
|
||||
\ 'text': l:result.description,
|
||||
\ 'code': l:result.long_id,
|
||||
\ 'type': l:type,
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
" Construct command arguments to tfsec with `terraform_tfsec_options`.
|
||||
function! ale_linters#terraform#tfsec#GetCommand(buffer) abort
|
||||
let l:cmd = '%e'
|
||||
|
||||
let l:config = ale_linters#terraform#tfsec#FindConfig(a:buffer)
|
||||
|
||||
if !empty(l:config)
|
||||
let l:cmd .= ' --config-file ' . l:config
|
||||
endif
|
||||
|
||||
let l:opts = ale#Var(a:buffer, 'terraform_tfsec_options')
|
||||
|
||||
if !empty(l:opts)
|
||||
let l:cmd .= ' ' . l:opts
|
||||
endif
|
||||
|
||||
let l:cmd .= ' --format json'
|
||||
|
||||
return l:cmd
|
||||
endfunction
|
||||
|
||||
" Find the nearest configuration file of tfsec.
|
||||
function! ale_linters#terraform#tfsec#FindConfig(buffer) abort
|
||||
let l:config_dir = ale#path#FindNearestDirectory(a:buffer, '.tfsec')
|
||||
|
||||
if !empty(l:config_dir)
|
||||
" https://aquasecurity.github.io/tfsec/v1.28.0/guides/configuration/config/
|
||||
for l:basename in ['config.yml', 'config.json']
|
||||
let l:config = ale#path#Simplify(join([l:config_dir, l:basename], s:separator))
|
||||
|
||||
if filereadable(l:config)
|
||||
return ale#Escape(l:config)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('terraform', {
|
||||
\ 'name': 'tfsec',
|
||||
\ 'executable': {b -> ale#Var(b, 'terraform_tfsec_executable')},
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': function('ale_linters#terraform#tfsec#GetCommand'),
|
||||
\ 'callback': 'ale_linters#terraform#tfsec#Handle',
|
||||
\})
|
Reference in New Issue
Block a user