1
0
mirror of https://github.com/amix/vimrc synced 2025-08-29 18:35:00 +08:00

Updated plugins

This commit is contained in:
Amir
2022-10-15 21:05:32 +02:00
parent 950b470eb9
commit 23ee6b7311
30 changed files with 412 additions and 77 deletions

View File

@ -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,
\})

View File

@ -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)

View File

@ -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

View File

@ -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)

View 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',
\})

View File

@ -585,3 +585,38 @@ function! ale#c#IncludeOptions(include_paths) abort
return join(l:option_list)
endfunction
" Get the language flag depending on on the executable, options and
" file extension
function! ale#c#GetLanguageFlag(
\ buffer,
\ executable,
\ use_header_lang_flag,
\ header_exts,
\ linter_lang_flag
\) abort
" Use only '-header' if the executable is 'clang' by default
if a:use_header_lang_flag == -1
let l:use_header_lang_flag = a:executable =~# 'clang'
else
let l:use_header_lang_flag = a:use_header_lang_flag
endif
" If we don't use the header language flag, return the default linter
" language flag
if !l:use_header_lang_flag
return a:linter_lang_flag
endif
" Get the buffer file extension
let l:buf_ext = expand('#' . a:buffer . ':e')
" If the buffer file is an header according to its extension, use
" the linter language flag + '-header', ex: 'c-header'
if index(a:header_exts, l:buf_ext) >= 0
return a:linter_lang_flag . '-header'
endif
" Else, use the default linter language flag
return a:linter_lang_flag
endfunction

View File

@ -47,6 +47,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['bzl'],
\ 'description': 'Format BUILD and .bzl files with buildifier.',
\ },
\ 'css-beautify': {
\ 'function': 'ale#fixers#css_beautify#Fix',
\ 'suggested_filetypes': ['css'],
\ 'description': 'Format CSS using css-beautify from js-beautify.',
\ },
\ 'deno': {
\ 'function': 'ale#fixers#deno#Fix',
\ 'suggested_filetypes': ['typescript'],
@ -514,7 +519,7 @@ let s:default_registry = {
\ 'html-beautify': {
\ 'function': 'ale#fixers#html_beautify#Fix',
\ 'suggested_filetypes': ['html', 'htmldjango'],
\ 'description': 'Fix HTML files with html-beautify.',
\ 'description': 'Fix HTML files with html-beautify from js-beautify.',
\ },
\ 'lua-format': {
\ 'function': 'ale#fixers#lua_format#Fix',
@ -528,7 +533,7 @@ let s:default_registry = {
\ },
\ 'dprint': {
\ 'function': 'ale#fixers#dprint#Fix',
\ 'suggested_filetypes': ['javascript', 'typescript', 'json', 'markdown'],
\ 'suggested_filetypes': ['dockerfile', 'javascript', 'json', 'markdown', 'toml', 'typescript'],
\ 'description': 'Pluggable and configurable code formatting platform',
\ },
\ 'stylua': {

View File

@ -0,0 +1,20 @@
" Author: https://github.com/Spixmaster
" Description: Format CSS using css-beautify from js-beautify.
call ale#Set('css_css_beautify_executable', 'css-beautify')
call ale#Set('css_css_beautify_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('css_css_beautify_options', '')
function! ale#fixers#css_beautify#Fix(buffer) abort
let l:executable = ale#python#FindExecutable(
\ a:buffer,
\ 'css_css_beautify',
\ ['css-beautify']
\)
let l:options = ale#Var(a:buffer, 'css_css_beautify_options')
return {
\ 'command': ale#Escape(l:executable) . ' ' . l:options . ' -',
\}
endfunction

View File

@ -1,10 +1,9 @@
" Author: WhyNotHugo <hugo@barrera.io>
" Description: Lint HTML files with html-beautify.
"
" Description: Format HTML files with html-beautify.
call ale#Set('html_beautify_executable', 'html-beautify')
call ale#Set('html_beautify_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('html_beautify_options', '')
call ale#Set('html_beautify_change_directory', 1)
function! ale#fixers#html_beautify#Fix(buffer) abort
let l:executable = ale#python#FindExecutable(
@ -16,6 +15,6 @@ function! ale#fixers#html_beautify#Fix(buffer) abort
let l:options = ale#Var(a:buffer, 'html_beautify_options')
return {
\ 'command': ale#Escape(l:executable). ' ' . l:options . ' -',
\ 'command': ale#Escape(l:executable) . ' ' . l:options . ' -',
\}
endfunction

View File

@ -33,6 +33,8 @@ function! ale#python#FindProjectRootIni(buffer) abort
\|| filereadable(l:path . '/pylama.ini')
\|| filereadable(l:path . '/pylintrc')
\|| filereadable(l:path . '/.pylintrc')
\|| filereadable(l:path . '/pyrightconfig.json')
\|| filereadable(l:path . '/pyrightconfig.toml')
\|| filereadable(l:path . '/Pipfile')
\|| filereadable(l:path . '/Pipfile.lock')
\|| filereadable(l:path . '/poetry.lock')

View File

@ -133,7 +133,42 @@ g:ale_c_cc_options *g:ale_c_cc_options*
Type: |String|
Default: `'-std=c11 -Wall'`
This variable can be change to modify flags given to the C compiler.
This variable can be changed to modify flags given to the C compiler.
g:ale_c_cc_use_header_lang_flag *g:ale_c_cc_use_header_lang_flag*
*b:ale_c_cc_use_header_lang_flag*
Type: |Number|
Default: `-1`
By default, ALE will use `'-x c-header'` instead of `'-x c'` for header files
when using Clang.
This variable can be changed to manually activate or deactivate this flag
for header files.
- When set to `-1`, the default beviour is used, `'-x c-header'` is used with
Clang and `'-x c'` is used with other compilers.
- When set to `0`, the flag is deactivated, `'-x c'` is always used
independently of the compiler.
- When set to `1`, the flag is activated, `'-x c-header'` is always used
independently of the compiler.
Gcc does not support `'-x c-header'` when using `'-'` as input filename,
which is what ALE does. This why, by default, ALE only uses `'-x c-header'`
with Clang.
g:ale_c_cc_header_exts *g:ale_c_cc_header_exts*
*b:ale_c_cc_header_exts*
Type: |List|
Default: `['h']`
This variable can be changed to modify the list of extensions of the files
considered as header files.
This variable is only used when `'-x c-header'` is used instead of `'-x c'`,
see |ale_c_cc_use_header_lang_flag|.
===============================================================================

View File

@ -62,7 +62,42 @@ g:ale_cpp_cc_options *g:ale_cpp_cc_options*
Type: |String|
Default: `'-std=c++14 -Wall'`
This variable can be change to modify flags given to the C++ compiler.
This variable can be changed to modify flags given to the C++ compiler.
g:ale_cpp_cc_use_header_lang_flag *g:ale_cpp_cc_use_header_lang_flag*
*b:ale_cpp_cc_use_header_lang_flag*
Type: |Number|
Default: `-1`
By default, ALE will use `'-x c++-header'` instead of `'-x c++'` for header
files when using Clang.
This variable can be changed to manually activate or deactivate this flag
for header files.
- When set to `-1`, the default beviour is used, `'-x c++-header'` is used with
Clang and `'-x c++'` is used with other compilers.
- When set to `0`, the flag is deactivated, `'-x c++'` is always used
independently of the compiler.
- When set to `1`, the flag is activated, `'-x c++-header'` is always used
independently of the compiler.
Gcc does not support `'-x c++-header'` when using `'-'` as input filename,
which is what ALE does. This why, by default, ALE only uses `'-x c++-header'`
with Clang.
g:ale_cpp_cc_header_exts *g:ale_cpp_cc_header_exts*
*b:ale_cpp_cc_header_exts*
Type: |List|
Default: `['h', 'hpp']`
This variable can be changed to modify the list of extensions of the files
considered as header files.
This variable is only used when `'-x c++-header'` is used instead of `'-x c++'`,
see |ale_cpp_cc_use_header_lang_flag|.
===============================================================================

View File

@ -8,6 +8,33 @@ cspell *ale-css-cspell*
See |ale-cspell-options|
===============================================================================
css-beautify *ale-css-css-beautify*
g:ale_css_css_beautify_executable *g:ale_css_css_beautify_executable*
*b:ale_css_css_beautify_executable*
Type: |String|
Default: `'css-beautify'`
See |ale-integrations-local-executables|
g:ale_css_css_beautify_options *g:ale_css_css_beautify_options*
*b:ale_css_css_beautify_options*
Type: |String|
Default: `''`
This variable can be set to pass additional options to css-beautify.
g:ale_css_css_beautify_use_global *g:ale_css_css_beautify_use_global*
*b:ale_css_css_beautify_use_global*
Type: |String|
Default: `get(g:, 'ale_use_global_executables', 0)`
See |ale-integrations-local-executables|
===============================================================================
fecs *ale-css-fecs*

View File

@ -45,6 +45,14 @@ See: |ale-javascript-fecs|.
===============================================================================
html-beautify *ale-html-beautify*
g:ale_html_beautify_executable *g:ale_html_beautify_executable*
*b:ale_html_beautify_executable*
Type: |String|
Default: `'html-beautify'`
See |ale-integrations-local-executables|
g:ale_html_beautify_options *g:ale_html_beautify_options*
*b:ale_html_beautify_options*
Type: |String|
@ -53,6 +61,14 @@ g:ale_html_beautify_options *g:ale_html_beautify_options*
This variable can be changed to modify flags given to html-beautify.
g:ale_html_beautify_use_global *g:ale_html_beautify_use_global*
*b:ale_html_beautify_use_global*
Type: |String|
Default: `get(g:, 'ale_use_global_executables', 0)`
See |ale-integrations-local-executables|
===============================================================================
htmlhint *ale-html-htmlhint*
@ -80,7 +96,6 @@ g:ale_html_htmlhint_use_global *g:ale_html_htmlhint_use_global*
See |ale-integrations-local-executables|
===============================================================================
prettier *ale-html-prettier*

View File

@ -46,6 +46,8 @@ ALE will look for configuration files with the following filenames. >
pylama.ini
pylintrc
.pylintrc
pyrightconfig.json
pyrightconfig.toml
Pipfile
Pipfile.lock
poetry.lock

View File

@ -120,6 +120,7 @@ Notes:
* CSS
* `VSCode CSS language server`
* `cspell`
* `css-beautify`
* `csslint`
* `fecs`
* `prettier`
@ -596,6 +597,7 @@ Notes:
* `terraform-ls`
* `terraform-lsp`
* `tflint`
* `tfsec`
* Texinfo
* `alex`
* `cspell`

View File

@ -114,6 +114,25 @@ g:ale_terraform_tflint_options *g:ale_terraform_tflint_options*
to include '-f json' in your new value.
===============================================================================
tfsec *ale-terraform-tfsec*
g:ale_terraform_tfsec_executable *g:ale_terraform_tfsec_executable*
*b:ale_terraform_tfsec_executable*
Type: |String|
Default: `'tfsec'`
This variable can be changed to use a different executable for tfsec.
g:ale_terraform_tfsec_options *g:ale_terraform_tfsec_options*
*b:ale_terraform_tfsec_options*
Type: |String|
Default: `''`
This variable can be changed to pass custom CLI flags to tfsec.
===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

View File

@ -2841,6 +2841,7 @@ documented in additional help files.
uncrustify............................|ale-cs-uncrustify|
css.....................................|ale-css-options|
cspell................................|ale-css-cspell|
css-beautify..........................|ale-css-css-beautify|
fecs..................................|ale-css-fecs|
prettier..............................|ale-css-prettier|
stylelint.............................|ale-css-stylelint|
@ -3260,6 +3261,7 @@ documented in additional help files.
terraform-ls..........................|ale-terraform-terraform-ls|
terraform-lsp.........................|ale-terraform-terraform-lsp|
tflint................................|ale-terraform-tflint|
tfsec.................................|ale-terraform-tfsec|
tex.....................................|ale-tex-options|
chktex................................|ale-tex-chktex|
cspell................................|ale-tex-cspell|

View File

@ -62,7 +62,7 @@ formatting.
* BibTeX
* [bibclean](http://ftp.math.utah.edu/pub/bibclean/)
* Bicep
* [bicep](https://github.com/Azure/bicep)
* [bicep](https://github.com/Azure/bicep) :floppy_disk:
* BitBake
* [oelint-adv](https://github.com/priv-kweihmann/oelint-adv)
* Bourne Shell
@ -129,6 +129,7 @@ formatting.
* CSS
* [VSCode CSS language server](https://github.com/hrsh7th/vscode-langservers-extracted)
* [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell)
* [css-beautify](https://github.com/beautify-web/js-beautify)
* [csslint](http://csslint.net/)
* [fecs](http://fecs.baidu.com/)
* [prettier](https://github.com/prettier/prettier)
@ -605,6 +606,7 @@ formatting.
* [terraform-ls](https://github.com/hashicorp/terraform-ls)
* [terraform-lsp](https://github.com/juliosueiras/terraform-lsp)
* [tflint](https://github.com/wata727/tflint)
* [tfsec](https://github.com/aquasecurity/tfsec)
* Texinfo
* [alex](https://github.com/get-alex/alex)
* [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell)