mirror of
1
0
Fork 0

Merge branch 'amix:master' into patch-1

This commit is contained in:
bryango 2022-08-10 20:49:27 +08:00 committed by GitHub
commit 68dca93994
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
306 changed files with 6985 additions and 2112 deletions

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for Ada files.
call ale#handlers#cspell#DefineLinter('ada')

View File

@ -18,9 +18,30 @@ function! ale_linters#ansible#ansible_lint#Handle(buffer, version, lines) abort
endif
endfor
let l:version_group = ale#semver#GTE(a:version, [5, 0, 0]) ? '>=5.0.0' : '<5.0.0'
let l:version_group = ale#semver#GTE(a:version, [6, 0, 0]) ? '>=6.0.0' :
\ ale#semver#GTE(a:version, [5, 0, 0]) ? '>=5.0.0' :
\ '<5.0.0'
let l:output = []
if '>=6.0.0' is# l:version_group
let l:error_codes = { 'blocker': 'E', 'critical': 'E', 'major': 'W', 'minor': 'W', 'info': 'I' }
let l:linter_issues = json_decode(join(a:lines, ''))
for l:issue in l:linter_issues
if ale#path#IsBufferPath(a:buffer, l:issue.location.path)
call add(l:output, {
\ 'lnum': exists('l:issue.location.lines.begin.column') ? l:issue.location.lines.begin.line :
\ l:issue.location.lines.begin,
\ 'col': exists('l:issue.location.lines.begin.column') ? l:issue.location.lines.begin.column : 0,
\ 'text': l:issue.check_name,
\ 'detail': l:issue.description,
\ 'code': l:issue.severity,
\ 'type': l:error_codes[l:issue.severity],
\})
endif
endfor
endif
if '>=5.0.0' is# l:version_group
" Matches patterns line the following:
" test.yml:3:148: syntax-check 'var' is not a valid attribute for a Play
@ -73,10 +94,13 @@ endfunction
function! ale_linters#ansible#ansible_lint#GetCommand(buffer, version) abort
let l:commands = {
\ '>=6.0.0': '%e --nocolor -f json -x yaml %s',
\ '>=5.0.0': '%e --nocolor --parseable-severity -x yaml %s',
\ '<5.0.0': '%e --nocolor -p %t'
\}
let l:command = ale#semver#GTE(a:version, [5, 0]) ? l:commands['>=5.0.0'] : l:commands['<5.0.0']
let l:command = ale#semver#GTE(a:version, [6, 0]) ? l:commands['>=6.0.0'] :
\ ale#semver#GTE(a:version, [5, 0]) ? l:commands['>=5.0.0'] :
\ l:commands['<5.0.0']
return l:command
endfunction

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for ASCIIDoc files.
call ale#handlers#cspell#DefineLinter('asciidoc')

View File

@ -0,0 +1,36 @@
" Author: Utkarsh Verma <utkarshverma@protonmail.com>
" Description: AVRA linter for avra syntax.
call ale#Set('avra_avra_executable', 'avra')
call ale#Set('avra_avra_options', '')
function! ale_linters#avra#avra#GetCommand(buffer) abort
return '%e'
\ . ' %t'
\ . ale#Pad(ale#Var(a:buffer, 'avra_avra_options'))
\ . ' -o ' . g:ale#util#nul_file
endfunction
function! ale_linters#avra#avra#Handle(buffer, lines) abort
" Note that we treat 'fatal' as errors.
let l:pattern = '^\S\+(\(\d\+\))\s\+:\s\+\(\S\+\)\s\+:\s\+\(.\+\)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[1] + 0,
\ 'type': l:match[2] =~? 'Error' ? 'E' : 'W',
\ 'text': l:match[3],
\})
endfor
return l:output
endfunction
call ale#linter#Define('avra', {
\ 'name': 'avra',
\ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'avra_avra_executable')},
\ 'command': function('ale_linters#avra#avra#GetCommand'),
\ 'callback': 'ale_linters#avra#avra#Handle',
\})

View File

@ -9,8 +9,9 @@ function! ale_linters#awk#gawk#GetCommand(buffer) abort
" gawk from attempting to execute the body of the script
" it is linting.
return '%e --source ' . ale#Escape('BEGIN { exit } END { exit 1 }')
\ . ' --lint'
\ . ale#Pad(ale#Var(a:buffer, 'awk_gawk_options'))
\ . ' -f %t --lint /dev/null'
\ . ' -f %t /dev/null'
endfunction
call ale#linter#Define('awk', {

View File

@ -0,0 +1,47 @@
" Author: offa
" Description: oelint-adv for BitBake files
call ale#Set('bitbake_oelint_adv_executable', 'oelint-adv')
call ale#Set('bitbake_oelint_adv_options', '')
call ale#Set('bitbake_oelint_adv_config', '.oelint.cfg')
function! ale_linters#bitbake#oelint_adv#Command(buffer) abort
let l:config_file = ale#path#FindNearestFile(a:buffer,
\ ale#Var(a:buffer, 'bitbake_oelint_adv_config'))
return ((!empty(l:config_file))
\ ? 'OELINT_CONFIG=' . ale#Escape(l:config_file) . ' '
\ : '')
\ . '%e --quiet '
\ . ale#Pad(ale#Var(a:buffer, 'bitbake_oelint_adv_options')) . '%s'
endfunction
function! ale_linters#bitbake#oelint_adv#Handle(buffer, lines) abort
let l:pattern = '\v^(.+):(.+):(.+):(.+):(.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': str2nr(l:match[2]),
\ 'type': l:match[3] is# 'error'
\ ? 'E' : (l:match[3] is# 'warning' ? 'W' : 'I'),
\ 'text': StripAnsiCodes(l:match[5]),
\ 'code': l:match[4]
\ })
endfor
return l:output
endfunction
function! StripAnsiCodes(line) abort
return substitute(a:line, '\e\[[0-9;]\+[mK]', '', 'g')
endfunction
call ale#linter#Define('bitbake', {
\ 'name': 'oelint_adv',
\ 'output_stream': 'both',
\ 'executable': {b -> ale#Var(b, 'bitbake_oelint_adv_executable')},
\ 'cwd': '%s:h',
\ 'command': function('ale_linters#bitbake#oelint_adv#Command'),
\ 'callback': 'ale_linters#bitbake#oelint_adv#Handle',
\ })

View File

@ -0,0 +1,20 @@
" Author: Justin Huang <justin.y.huang@live.com>
" Description: cpplint for c files
call ale#Set('c_cpplint_executable', 'cpplint')
call ale#Set('c_cpplint_options', '')
function! ale_linters#c#cpplint#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'c_cpplint_options')
return '%e' . ale#Pad(l:options) . ' %s'
endfunction
call ale#linter#Define('c', {
\ 'name': 'cpplint',
\ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'c_cpplint_executable')},
\ 'command': function('ale_linters#c#cpplint#GetCommand'),
\ 'callback': 'ale#handlers#cpplint#HandleCppLintFormat',
\ 'lint_file': 1,
\})

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for C files.
call ale#handlers#cspell#DefineLinter('c')

View File

@ -0,0 +1,37 @@
" Author: 0xHyoga <0xHyoga@gmx.com>
" Description: Report starknet-compile errors in cairo code
call ale#Set('cairo_starknet_executable', 'starknet-compile')
call ale#Set('cairo_starknet_options', '')
function! ale_linters#cairo#starknet#Handle(buffer, lines) abort
" Error always on the first line
" e.g ex01.cairo:20:6: Could not find module 'contracts.utils.ex00_base'. Searched in the following paths:
let l:pattern = '\v\.cairo:(\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]),
\ 'type': 'E',
\ 'text': l:match[3],
\})
endfor
return l:output
endfunction
function! ale_linters#cairo#starknet#GetCommand(buffer) abort
let l:executable = ale#Var(a:buffer, 'cairo_starknet_executable')
return l:executable . ale#Pad(ale#Var(a:buffer, 'cairo_starknet_options')) . ' %s'
endfunction
call ale#linter#Define('cairo', {
\ 'name': 'starknet',
\ 'executable': {b -> ale#Var(b, 'cairo_starknet_executable')},
\ 'command': function('ale_linters#cairo#starknet#GetCommand'),
\ 'callback': 'ale_linters#cairo#starknet#Handle',
\ 'output_stream': 'stderr',
\})

View File

@ -0,0 +1,43 @@
" Author: Carl Smedstad <carl.smedstad at protonmail dot com>
" Description: cmake-lint for cmake files
let g:ale_cmake_cmake_lint_executable =
\ get(g:, 'ale_cmake_cmake_lint_executable', 'cmake-lint')
let g:ale_cmake_cmake_lint_options =
\ get(g:, 'ale_cmake_cmake_lint_options', '')
function! ale_linters#cmake#cmake_lint#Executable(buffer) abort
return ale#Var(a:buffer, 'cmake_cmake_lint_executable')
endfunction
function! ale_linters#cmake#cmake_lint#Command(buffer) abort
let l:executable = ale_linters#cmake#cmake_lint#Executable(a:buffer)
let l:options = ale#Var(a:buffer, 'cmake_cmake_lint_options')
return ale#Escape(l:executable) . ' ' . l:options . ' %t'
endfunction
function! ale_linters#cmake#cmake_lint#Handle(buffer, lines) abort
let l:pattern = '\v^[^:]+:(\d+),?(\d+)?:\s\[([A-Z]\d+)\]\s(.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'type': 'W',
\ 'code': l:match[3],
\ 'text': l:match[4],
\})
endfor
return l:output
endfunction
call ale#linter#Define('cmake', {
\ 'name': 'cmake_lint',
\ 'executable': function('ale_linters#cmake#cmake_lint#Executable'),
\ 'command': function('ale_linters#cmake#cmake_lint#Command'),
\ 'callback': 'ale_linters#cmake#cmake_lint#Handle',
\})

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for C++ files.
call ale#handlers#cspell#DefineLinter('cpp')

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for C# files.
call ale#handlers#cspell#DefineLinter('cs')

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for CSS files.
call ale#handlers#cspell#DefineLinter('css')

View File

@ -0,0 +1,16 @@
" Author: Dalius Dobravolskas <dalius.dobravolskas@gmail.com>
" Description: VSCode css language server
function! ale_linters#css#vscodecss#GetProjectRoot(buffer) abort
let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git')
return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : ''
endfunction
call ale#linter#Define('css', {
\ 'name': 'vscodecss',
\ 'lsp': 'stdio',
\ 'executable': 'vscode-css-language-server',
\ 'command': '%e --stdio',
\ 'project_root': function('ale_linters#css#vscodecss#GetProjectRoot'),
\})

View File

@ -4,15 +4,16 @@
call ale#Set('dart_analyze_executable', 'dart')
function! ale_linters#dart#dart_analyze#Handle(buffer, lines) abort
let l:pattern = '\v^ ([a-z]+) - (.+):(\d+):(\d+) - (.+) - (.+)$'
let l:pattern = '\v([a-z]+) - (.+):(\d+):(\d+) - (.+) - (.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let [l:type, l:filename, l:lnum, l:col, l:message, l:code] = l:match[1:6]
call add(l:output, {
\ 'type': l:match[1] is# 'error' ? 'E' : 'W',
\ 'text': l:match[6] . ': ' . l:match[5],
\ 'lnum': str2nr(l:match[3]),
\ 'col': str2nr(l:match[4]),
\ 'type': l:type is# 'error' ? 'E' : l:type is# 'info' ? 'I' : 'W',
\ 'text': l:code . ': ' . l:message,
\ 'lnum': str2nr(l:lnum),
\ 'col': str2nr(l:col),
\})
endfor
@ -22,7 +23,7 @@ endfunction
call ale#linter#Define('dart', {
\ 'name': 'dart_analyze',
\ 'executable': {b -> ale#Var(b, 'dart_analyze_executable')},
\ 'command': '%e analyze %s',
\ 'command': '%e analyze --fatal-infos %s',
\ 'callback': 'ale_linters#dart#dart_analyze#Handle',
\ 'lint_file': 1,
\})

View File

@ -1,36 +0,0 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: Check Dart files with dartanalyzer
call ale#Set('dart_dartanalyzer_executable', 'dartanalyzer')
function! ale_linters#dart#dartanalyzer#GetCommand(buffer) abort
let l:path = ale#path#FindNearestFile(a:buffer, '.packages')
return '%e'
\ . (!empty(l:path) ? ' --packages ' . ale#Escape(l:path) : '')
\ . ' %s'
endfunction
function! ale_linters#dart#dartanalyzer#Handle(buffer, lines) abort
let l:pattern = '\v^ ([a-z]+) . (.+) at (.+):(\d+):(\d+) . (.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'type': l:match[1] is# 'error' ? 'E' : 'W',
\ 'text': l:match[6] . ': ' . l:match[2],
\ 'lnum': str2nr(l:match[4]),
\ 'col': str2nr(l:match[5]),
\})
endfor
return l:output
endfunction
call ale#linter#Define('dart', {
\ 'name': 'dartanalyzer',
\ 'executable': {b -> ale#Var(b, 'dart_dartanalyzer_executable')},
\ 'command': function('ale_linters#dart#dartanalyzer#GetCommand'),
\ 'callback': 'ale_linters#dart#dartanalyzer#Handle',
\ 'lint_file': 1,
\})

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for Elixir files.
call ale#handlers#cspell#DefineLinter('elixir')

View File

@ -12,6 +12,7 @@ function! ale_linters#erlang#elvis#Handle(buffer, lines) abort
\ 'lnum': str2nr(l:match[1]),
\ 'text': s:AbbreviateMessage(l:match[2]),
\ 'type': 'W',
\ 'sub_type': 'style',
\})
endfor

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for Go files.
call ale#handlers#cspell#DefineLinter('go')

View File

@ -24,7 +24,7 @@ function! ale_linters#go#golangci_lint#GetCommand(buffer) abort
endfunction
function! ale_linters#go#golangci_lint#GetMatches(lines) abort
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?:?:?:?\s\*?(.+)$'
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?:?:?:?\s\*?(.+)\s+\((.+)\)$'
return ale#util#GetMatches(a:lines, l:pattern)
endfunction
@ -34,14 +34,20 @@ function! ale_linters#go#golangci_lint#Handler(buffer, lines) abort
let l:output = []
for l:match in ale_linters#go#golangci_lint#GetMatches(a:lines)
if l:match[5] is# 'typecheck'
let l:msg_type = 'E'
else
let l:msg_type = 'W'
endif
" l:match[1] will already be an absolute path, output from
" golangci_lint
call add(l:output, {
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'type': 'E',
\ 'text': l:match[4],
\ 'type': l:msg_type,
\ 'text': l:match[4] . ' (' . l:match[5] . ')',
\})
endfor

View File

@ -11,10 +11,17 @@ function! ale_linters#handlebars#embertemplatelint#GetExecutable(buffer) abort
endfunction
function! ale_linters#handlebars#embertemplatelint#GetCommand(buffer, version) abort
" Reading from stdin was introduced in ember-template-lint@1.6.0
return ale#semver#GTE(a:version, [1, 6, 0])
\ ? '%e --json --filename %s'
\ : '%e --json %t'
if ale#semver#GTE(a:version, [4, 0, 0])
" --json was removed in favor of --format=json in ember-template-lint@4.0.0
return '%e --format=json --filename %s'
endif
if ale#semver#GTE(a:version, [1, 6, 0])
" Reading from stdin was introduced in ember-template-lint@1.6.0
return '%e --json --filename %s'
endif
return '%e --json %t'
endfunction
function! ale_linters#handlebars#embertemplatelint#GetCommandWithVersionCheck(buffer) abort

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for Haskell files.
call ale#handlers#cspell#DefineLinter('haskell')

View File

@ -4,6 +4,7 @@
" <devildead13@gmail.com>). It search more project root files.
"
call ale#Set('haskell_hls_executable', 'haskell-language-server-wrapper')
call ale#Set('haskell_hls_config', {})
function! ale_linters#haskell#hls#FindRootFile(buffer) abort
let l:serach_root_files = [
@ -60,4 +61,5 @@ call ale#linter#Define('haskell', {
\ 'command': function('ale_linters#haskell#hls#GetCommand'),
\ 'executable': {b -> ale#Var(b, 'haskell_hls_executable')},
\ 'project_root': function('ale_linters#haskell#hls#GetProjectRoot'),
\ 'lsp_config': {b -> ale#Var(b, 'haskell_hls_config')},
\})

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for help files.
call ale#handlers#cspell#DefineLinter('help')

View File

@ -11,10 +11,7 @@ function! ale_linters#html#angular#GetProjectRoot(buffer) abort
endfunction
function! ale_linters#html#angular#GetExecutable(buffer) abort
return ale#path#FindExecutable(a:buffer, 'html_angular', [
\ 'node_modules/@angular/language-server/bin/ngserver',
\ 'node_modules/@angular/language-server/index.js',
\])
return 'node'
endfunction
function! ale_linters#html#angular#GetCommand(buffer) abort
@ -34,9 +31,16 @@ function! ale_linters#html#angular#GetCommand(buffer) abort
\ fnamemodify(l:language_service_dir, ':h:h')
\ . '/typescript'
\)
let l:executable = ale_linters#html#angular#GetExecutable(a:buffer)
let l:script = ale#path#FindExecutable(a:buffer, 'html_angular', [
\ 'node_modules/@angular/language-server/bin/ngserver',
\ 'node_modules/@angular/language-server/index.js',
\])
return ale#node#Executable(a:buffer, l:executable)
if !filereadable(l:script)
return ''
endif
return ale#Escape('node') . ' ' . ale#Escape(l:script)
\ . ' --ngProbeLocations ' . ale#Escape(l:language_service_dir)
\ . ' --tsProbeLocations ' . ale#Escape(l:typescript_dir)
\ . ' --stdio'

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for HTML files.
call ale#handlers#cspell#DefineLinter('html')

View File

@ -0,0 +1,16 @@
" Author: Dalius Dobravolskas <dalius.dobravolskas@gmail.com>
" Description: VSCode html language server
function! ale_linters#html#vscodehtml#GetProjectRoot(buffer) abort
let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git')
return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : ''
endfunction
call ale#linter#Define('html', {
\ 'name': 'vscodehtml',
\ 'lsp': 'stdio',
\ 'executable': 'vscode-html-language-server',
\ 'command': '%e --stdio',
\ 'project_root': function('ale_linters#html#vscodehtml#GetProjectRoot'),
\})

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for Java files.
call ale#handlers#cspell#DefineLinter('java')

View File

@ -192,4 +192,9 @@ call ale#linter#Define('java', {
\ 'command': function('ale_linters#java#eclipselsp#RunWithVersionCheck'),
\ 'language': 'java',
\ 'project_root': function('ale#java#FindProjectRoot'),
\ 'initialization_options': {
\ 'extendedClientCapabilities': {
\ 'classFileContentsSupport': v:true
\ }
\ }
\})

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for JavaScript files.
call ale#handlers#cspell#DefineLinter('javascript')

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for JSON files.
call ale#handlers#cspell#DefineLinter('json')

View File

@ -0,0 +1,16 @@
" Author: Dalius Dobravolskas <dalius.dobravolskas@gmail.com>
" Description: VSCode json language server
function! ale_linters#json#vscodejson#GetProjectRoot(buffer) abort
let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git')
return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : ''
endfunction
call ale#linter#Define('json', {
\ 'name': 'vscodejson',
\ 'lsp': 'stdio',
\ 'executable': 'vscode-json-language-server',
\ 'command': '%e --stdio',
\ 'project_root': function('ale_linters#json#vscodejson#GetProjectRoot'),
\})

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for Lua files.
call ale#handlers#cspell#DefineLinter('lua')

View File

@ -0,0 +1,46 @@
call ale#Set('lua_selene_executable', 'selene')
call ale#Set('lua_selene_options', '')
function! ale_linters#lua#selene#GetCommand(buffer) abort
return '%e' . ale#Pad(ale#Var(a:buffer, 'lua_selene_options'))
\ . ' --display-style=json -'
endfunction
function! ale_linters#lua#selene#Handle(buffer, lines) abort
let l:output = []
for l:line in a:lines
" as of version 0.17.0, selene has no way to suppress summary
" information when outputting json, so stop processing when we hit it
" (PR for this here: https://github.com/Kampfkarren/selene/pull/356)
if l:line is# 'Results:'
break
endif
let l:json = json_decode(l:line)
let l:lint = {
\ 'lnum': l:json.primary_label.span.start_line + 1,
\ 'end_lnum': l:json.primary_label.span.end_line + 1,
\ 'col': l:json.primary_label.span.start_column + 1,
\ 'end_col': l:json.primary_label.span.end_column,
\ 'text': l:json.message,
\ 'code': l:json.code,
\ 'type': l:json.severity is# 'Warning' ? 'W' : 'E',
\}
if has_key(l:json, 'notes') && len(l:json.notes) > 0
let l:lint.detail = l:lint.text . "\n\n" . join(l:json.notes, "\n")
endif
call add(l:output, l:lint)
endfor
return l:output
endfunction
call ale#linter#Define('lua', {
\ 'name': 'selene',
\ 'executable': {b -> ale#Var(b, 'lua_selene_executable')},
\ 'command': function('ale_linters#lua#selene#GetCommand'),
\ 'callback': 'ale_linters#lua#selene#Handle',
\})

View File

@ -20,6 +20,6 @@ endfunction
call ale#linter#Define('make', {
\ 'name': 'checkmake',
\ 'executable': 'checkmake',
\ 'command': 'checkmake %s --format="{{.LineNumber}}:{{.Rule}}:{{.Violation}}"',
\ 'command': 'checkmake %s --format="{{.LineNumber}}:{{.Rule}}:{{.Violation}}{{\"\r\n\"}}"',
\ 'callback': 'ale_linters#make#checkmake#Handle',
\})

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for Markdown files.
call ale#handlers#cspell#DefineLinter('markdown')

View File

@ -5,7 +5,7 @@
function! ale_linters#nix#nix#Command(buffer, output, meta) abort
let l:version = a:output[0][22:]
if l:version =~# '^\(2.4\|3\).*'
if l:version =~# '^\(2.[4-9]\|3\).*'
return 'nix-instantiate --log-format internal-json --parse -'
else
return 'nix-instantiate --parse -'

View File

@ -0,0 +1,18 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: statix analysis and suggestions for Nix files
call ale#Set('nix_statix_check_executable', 'statix')
call ale#Set('nix_statix_check_options', '')
function! ale_linters#nix#statix#GetCommand(buffer) abort
return '%e check -o errfmt --stdin'
\ . ale#Pad(ale#Var(a:buffer, 'nix_statix_check_options'))
endfunction
call ale#linter#Define('nix', {
\ 'name': 'statix',
\ 'executable': {b -> ale#Var(b, 'nix_statix_check_executable')},
\ 'command': function('ale_linters#nix#statix#GetCommand'),
\ 'callback': 'ale#handlers#statix#Handle',
\})

View File

@ -0,0 +1,24 @@
" Description: SCA2D linter for OpenSCAD files
call ale#Set('openscad_sca2d_executable', 'sca2d')
call ale#Set('openscad_sca2d_options', '')
function! ale_linters#openscad#sca2d#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'openscad_sca2d_executable')
endfunction
function! ale_linters#openscad#sca2d#GetCommand(buffer) abort
let l:executable = ale_linters#openscad#sca2d#GetExecutable(a:buffer)
let l:options = ale#Var(a:buffer, 'openscad_sca2d_options')
return ale#Escape(l:executable) . ale#Pad(l:options) . ' %s'
endfunction
call ale#linter#Define('openscad', {
\ 'name': 'SCA2D',
\ 'aliases': ['sca2d'],
\ 'executable': function('ale_linters#openscad#sca2d#GetExecutable'),
\ 'command': function('ale_linters#openscad#sca2d#GetCommand'),
\ 'callback': 'ale#handlers#openscad#SCA2D_callback',
\ 'lint_file': 1,
\ })

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for PHP files.
call ale#handlers#cspell#DefineLinter('php')

View File

@ -0,0 +1,23 @@
" Author: Arizard <https://github.com/Arizard>
" Description: PHPactor integration for ALE
" Copied from langserver.vim
function! ale_linters#php#phpactor#GetProjectRoot(buffer) abort
let l:composer_path = ale#path#FindNearestFile(a:buffer, 'composer.json')
if (!empty(l:composer_path))
return fnamemodify(l:composer_path, ':h')
endif
let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git')
return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : ''
endfunction
call ale#linter#Define('php', {
\ 'name': 'phpactor',
\ 'lsp': 'stdio',
\ 'executable': 'phpactor',
\ 'command': '%e language-server',
\ 'project_root': function('ale_linters#php#phpactor#GetProjectRoot'),
\})

View File

@ -1,4 +1,4 @@
" Author: medains <https://github.com/medains>, ardis <https://github.com/ardisdreelath>
" Author: medains <https://github.com/medains>, ardis <https://github.com/ardisdreelath>, Arizard <https://github.com/Arizard>
" Description: phpstan for PHP files
" Set to change the ruleset
@ -6,6 +6,7 @@ let g:ale_php_phpstan_executable = get(g:, 'ale_php_phpstan_executable', 'phpsta
let g:ale_php_phpstan_level = get(g:, 'ale_php_phpstan_level', '')
let g:ale_php_phpstan_configuration = get(g:, 'ale_php_phpstan_configuration', '')
let g:ale_php_phpstan_autoload = get(g:, 'ale_php_phpstan_autoload', '')
let g:ale_php_phpstan_memory_limit = get(g:, 'ale_php_phpstan_memory_limit', '')
call ale#Set('php_phpstan_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#php#phpstan#GetCommand(buffer, version) abort
@ -19,6 +20,11 @@ function! ale_linters#php#phpstan#GetCommand(buffer, version) abort
\ ? ' -a ' . ale#Escape(l:autoload)
\ : ''
let l:memory_limit = ale#Var(a:buffer, 'php_phpstan_memory_limit')
let l:memory_limit_option = !empty(l:memory_limit)
\ ? ' --memory-limit ' . ale#Escape(l:memory_limit)
\ : ''
let l:level = ale#Var(a:buffer, 'php_phpstan_level')
let l:config_file_exists = ale#path#FindNearestFile(a:buffer, 'phpstan.neon')
let l:dist_config_file_exists = ale#path#FindNearestFile(a:buffer, 'phpstan.neon.dist')
@ -41,6 +47,7 @@ function! ale_linters#php#phpstan#GetCommand(buffer, version) abort
\ . l:configuration_option
\ . l:autoload_option
\ . l:level_option
\ . l:memory_limit_option
\ . ' %s'
endfunction

View File

@ -6,6 +6,12 @@ call ale#Set('php_psalm_options', '')
call ale#Set('php_psalm_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#php#psalm#GetProjectRoot(buffer) abort
let l:composer_path = ale#path#FindNearestFile(a:buffer, 'composer.json')
if (!empty(l:composer_path))
return fnamemodify(l:composer_path, ':h')
endif
let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git')
return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : ''

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for PowerShell files.
call ale#handlers#cspell#DefineLinter('powershell')

View File

@ -0,0 +1,23 @@
" Author: Alex McKinney <alexmckinney01@gmail.com>
" Description: Run buf lint.
call ale#Set('proto_buf_lint_executable', 'buf')
call ale#Set('proto_buf_lint_config', '')
function! ale_linters#proto#buf_lint#GetCommand(buffer) abort
let l:config = ale#Var(a:buffer, 'proto_buf_lint_config')
return '%e lint'
\ . (!empty(l:config) ? ' --config=' . ale#Escape(l:config) : '')
\ . ' %s#include_package_files=true'
endfunction
call ale#linter#Define('proto', {
\ 'name': 'buf_lint',
\ 'aliases': ['buf-lint'],
\ 'lint_file': 1,
\ 'output_stream': 'stdout',
\ 'executable': {b -> ale#Var(b, 'proto_buf_lint_executable')},
\ 'command': function('ale_linters#proto#buf_lint#GetCommand'),
\ 'callback': 'ale#handlers#unix#HandleAsError',
\})

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for Python files.
call ale#handlers#cspell#DefineLinter('python')

View File

@ -29,7 +29,7 @@ function! ale_linters#python#pydocstyle#GetCommand(buffer) abort
return ale#Escape(l:executable) . l:exec_args
\ . ale#Pad(ale#Var(a:buffer, 'python_pydocstyle_options'))
\ . ' %s:t'
\ . ' %s'
endfunction
function! ale_linters#python#pydocstyle#Handle(buffer, lines) abort

View File

@ -22,6 +22,22 @@ function! ale_linters#python#pylama#GetExecutable(buffer) abort
return ale#python#FindExecutable(a:buffer, 'python_pylama', ['pylama'])
endfunction
function! ale_linters#python#pylama#RunWithVersionCheck(buffer) abort
let l:executable = ale_linters#python#pylama#GetExecutable(a:buffer)
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
\ ? ' run pylama'
\ : ''
let l:command = ale#Escape(l:executable) . l:exec_args . ' --version'
return ale#semver#RunWithVersionCheck(
\ a:buffer,
\ l:executable,
\ l:command,
\ function('ale_linters#python#pylama#GetCommand'),
\)
endfunction
function! ale_linters#python#pylama#GetCwd(buffer) abort
if ale#Var(a:buffer, 'python_pylama_change_directory')
" Pylama loads its configuration from the current directory only, and
@ -35,27 +51,33 @@ function! ale_linters#python#pylama#GetCwd(buffer) abort
return ''
endfunction
function! ale_linters#python#pylama#GetCommand(buffer) abort
function! ale_linters#python#pylama#GetCommand(buffer, version) abort
let l:executable = ale_linters#python#pylama#GetExecutable(a:buffer)
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
\ ? ' run pylama'
\ : ''
" json format is added in version 8.1.4
" https://github.com/klen/pylama/blob/develop/Changelog
let l:format_json_args = ale#semver#GTE(a:version, [8, 1, 4])
\ ? ' --format json'
\ : ''
" Note: Using %t to lint changes would be preferable, but many pylama
" checks use surrounding paths (e.g. C0103 module name, E0402 relative
" import beyond top, etc.). Neither is ideal.
return ale#Escape(l:executable) . l:exec_args
\ . ale#Pad(ale#Var(a:buffer, 'python_pylama_options'))
\ . l:format_json_args
\ . ' %s'
endfunction
function! ale_linters#python#pylama#Handle(buffer, lines) abort
function! ale_linters#python#pylama#Handle(buffer, version, lines) abort
if empty(a:lines)
return []
endif
let l:output = ale#python#HandleTraceback(a:lines, 1)
let l:pattern = '\v^.{-}:([0-9]+):([0-9]+): +%(([A-Z][0-9]+):? +)?(.*)$'
" First letter of error code is a pylint-compatible message type
" http://pylint.pycqa.org/en/latest/user_guide/output.html#source-code-analysis-section
@ -75,16 +97,41 @@ function! ale_linters#python#pylama#Handle(buffer, lines) abort
\ 'D': 'style',
\}
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]),
\ 'code': l:match[3],
\ 'type': get(l:pylint_type_to_ale_type, l:match[3][0], 'W'),
\ 'sub_type': get(l:pylint_type_to_ale_sub_type, l:match[3][0], ''),
\ 'text': l:match[4],
\})
endfor
if ale#semver#GTE(a:version, [8, 1, 4])
try
let l:errors = json_decode(join(a:lines, ''))
catch
return l:output
endtry
if empty(l:errors)
return l:output
endif
for l:error in l:errors
call add(l:output, {
\ 'lnum': l:error['lnum'],
\ 'col': l:error['col'],
\ 'code': l:error['number'],
\ 'type': get(l:pylint_type_to_ale_type, l:error['etype'], 'W'),
\ 'sub_type': get(l:pylint_type_to_ale_sub_type, l:error['etype'], ''),
\ 'text': printf('%s [%s]', l:error['message'], l:error['source']),
\})
endfor
else
let l:pattern = '\v^.{-}:([0-9]+):([0-9]+): +%(([A-Z][0-9]+):? +)?(.*)$'
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]),
\ 'code': l:match[3],
\ 'type': get(l:pylint_type_to_ale_type, l:match[3][0], 'W'),
\ 'sub_type': get(l:pylint_type_to_ale_sub_type, l:match[3][0], ''),
\ 'text': l:match[4],
\})
endfor
endif
return l:output
endfunction
@ -93,7 +140,15 @@ call ale#linter#Define('python', {
\ 'name': 'pylama',
\ 'executable': function('ale_linters#python#pylama#GetExecutable'),
\ 'cwd': function('ale_linters#python#pylama#GetCwd'),
\ 'command': function('ale_linters#python#pylama#GetCommand'),
\ 'callback': 'ale_linters#python#pylama#Handle',
\ 'command': function('ale_linters#python#pylama#RunWithVersionCheck'),
\ 'callback': {buffer, lines -> ale#semver#RunWithVersionCheck(
\ buffer,
\ ale_linters#python#pylama#GetExecutable(buffer),
\ '%e --version',
\ {buffer, version -> ale_linters#python#pylama#Handle(
\ buffer,
\ l:version,
\ lines)},
\ )},
\ 'lint_file': 1,
\})

View File

@ -0,0 +1,75 @@
" Author: Author: Jon Parise <jon@indelible.org>
call ale#Set('python_unimport_executable', 'unimport')
call ale#Set('python_unimport_options', '')
call ale#Set('python_unimport_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_unimport_auto_pipenv', 0)
call ale#Set('python_unimport_auto_poetry', 0)
function! ale_linters#python#unimport#GetExecutable(buffer) abort
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_unimport_auto_pipenv'))
\ && ale#python#PipenvPresent(a:buffer)
return 'pipenv'
endif
if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_unimport_auto_poetry'))
\ && ale#python#PoetryPresent(a:buffer)
return 'poetry'
endif
return ale#python#FindExecutable(a:buffer, 'python_unimport', ['unimport'])
endfunction
function! ale_linters#python#unimport#GetCommand(buffer) abort
let l:executable = ale_linters#python#unimport#GetExecutable(a:buffer)
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
\ ? ' run unimport'
\ : ''
return '%e' . l:exec_args
\ . ale#Pad(ale#Var(a:buffer, 'python_unimport_options'))
\ . ' --check'
\ . ' %t'
endfunction
function! ale_linters#python#unimport#GetCwd(buffer) abort
let l:project_root = ale#python#FindProjectRoot(a:buffer)
return !empty(l:project_root)
\ ? l:project_root
\ : expand('#' . a:buffer . ':p:h')
endfunction
function! ale_linters#python#unimport#Handle(buffer, lines) abort
let l:output = ale#python#HandleTraceback(a:lines, 10)
if !empty(l:output)
return l:output
endif
" Matches lines like:
"
" urllib.parse at path/to/file.py:9
let l:pattern = '\v(.+) at [^:]+:(\d+)$'
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[2] + 0,
\ 'type': 'W',
\ 'text': 'unused: ' . l:match[1],
\})
endfor
return l:output
endfunction
call ale#linter#Define('python', {
\ 'name': 'unimport',
\ 'executable': function('ale_linters#python#unimport#GetExecutable'),
\ 'cwd': function('ale_linters#python#unimport#GetCwd'),
\ 'command': function('ale_linters#python#unimport#GetCommand'),
\ 'callback': 'ale_linters#python#unimport#Handle',
\})

View File

@ -0,0 +1,4 @@
scriptencoding utf-8
" Description: cspell support for rego files.
call ale#handlers#cspell#DefineLinter('rego')

View File

@ -0,0 +1,56 @@
" Description: opa check for rego files
call ale#Set('rego_opacheck_executable', 'opa')
call ale#Set('rego_opacheck_options', '')
function! ale_linters#rego#opacheck#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'rego_opacheck_executable')
endfunction
function! ale_linters#rego#opacheck#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'rego_opacheck_options')
return ale#Escape(ale_linters#rego#opacheck#GetExecutable(a:buffer))
\ . ' check %s --format json '
\ . (!empty(l:options) ? ' ' . l:options : '')
endfunction
function! ale_linters#rego#opacheck#Handle(buffer, lines) abort
let l:output = []
let l:errors = ale#util#FuzzyJSONDecode(a:lines, {'errors': []})
let l:dir = expand('#' . a:buffer . ':p:h')
let l:file = expand('#' . a:buffer . ':p')
for l:error in l:errors['errors']
if has_key(l:error, 'location')
call add(l:output, {
\ 'filename': ale#path#GetAbsPath(l:dir, l:error['location']['file']),
\ 'lnum': l:error['location']['row'],
\ 'col': l:error['location']['col'],
\ 'text': l:error['message'],
\ 'code': l:error['code'],
\ 'type': 'E',
\})
else
call add(l:output, {
\ 'filename': l:file,
\ 'lnum': 0,
\ 'col': 0,
\ 'text': l:error['message'],
\ 'code': l:error['code'],
\ 'type': 'E',
\})
endif
endfor
return l:output
endfunction
call ale#linter#Define('rego', {
\ 'name': 'opacheck',
\ 'output_stream': 'both',
\ 'executable': function('ale_linters#rego#opacheck#GetExecutable'),
\ 'command': function('ale_linters#rego#opacheck#GetCommand'),
\ 'callback': 'ale_linters#rego#opacheck#Handle',
\})

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for ReStructuredText files.
call ale#handlers#cspell#DefineLinter('rst')

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for Ruby files.
call ale#handlers#cspell#DefineLinter('ruby')

View File

@ -19,6 +19,10 @@ function! ale_linters#ruby#reek#GetCommand(buffer, version) abort
\ . l:display_name_args
endfunction
function! s:GetDocumentationLink(error) abort
return get(a:error, 'documentation_link', get(a:error, 'wiki_link', ''))
endfunction
function! s:BuildText(buffer, error) abort
let l:parts = []
@ -29,7 +33,7 @@ function! s:BuildText(buffer, error) abort
call add(l:parts, a:error.message)
if ale#Var(a:buffer, 'ruby_reek_show_wiki_link')
call add(l:parts, '[' . a:error.wiki_link . ']')
call add(l:parts, '[' . s:GetDocumentationLink(a:error) . ']')
endif
return join(l:parts, ' ')

View File

@ -9,9 +9,21 @@ function! ale_linters#rust#analyzer#GetCommand(buffer) abort
endfunction
function! ale_linters#rust#analyzer#GetProjectRoot(buffer) abort
" Try to find nearest Cargo.toml for cargo projects
let l:cargo_file = ale#path#FindNearestFile(a:buffer, 'Cargo.toml')
return !empty(l:cargo_file) ? fnamemodify(l:cargo_file, ':h') : ''
if !empty(l:cargo_file)
return fnamemodify(l:cargo_file, ':h')
endif
" Try to find nearest rust-project.json for non-cargo projects
let l:rust_project = ale#path#FindNearestFile(a:buffer, 'rust-project.json')
if !empty(l:rust_project)
return fnamemodify(l:rust_project, ':h')
endif
return ''
endfunction
call ale#linter#Define('rust', {

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for Rust files.
call ale#handlers#cspell#DefineLinter('rust')

View File

@ -1,7 +1,7 @@
" Author: Daniel Schemala <istjanichtzufassen@gmail.com>
" Description: rustc for rust files
call ale#Set('rust_rustc_options', '-Z no-codegen')
call ale#Set('rust_rustc_options', '--emit=mir -o /dev/null')
function! ale_linters#rust#rustc#RustcCommand(buffer) abort
" Try to guess the library search path. If the project is managed by cargo,

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for Scala files.
call ale#handlers#cspell#DefineLinter('scala')

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for shell scripts.
call ale#handlers#cspell#DefineLinter('sh')

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for Swift files.
call ale#handlers#cspell#DefineLinter('swift')

View File

@ -0,0 +1,41 @@
" Author: Thyme-87 <thyme-87@posteo.me>
" Description: use checkov for providing warnings via ale
call ale#Set('terraform_checkov_executable', 'checkov')
call ale#Set('terraform_checkov_options', '')
function! ale_linters#terraform#checkov#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'terraform_checkov_executable')
endfunction
function! ale_linters#terraform#checkov#GetCommand(buffer) abort
return '%e ' . '-f %t -o json --quiet ' . ale#Var(a:buffer, 'terraform_checkov_options')
endfunction
function! ale_linters#terraform#checkov#Handle(buffer, lines) abort
let l:output = []
let l:results = get(get(ale#util#FuzzyJSONDecode(a:lines, {}), 'results', []), 'failed_checks', [])
for l:violation in l:results
call add(l:output, {
\ 'filename': l:violation['file_path'],
\ 'lnum': l:violation['file_line_range'][0],
\ 'end_lnum': l:violation['file_line_range'][1],
\ 'text': l:violation['check_name'] . ' [' . l:violation['check_id'] . ']',
\ 'detail': l:violation['check_id'] . ': ' . l:violation['check_name'] . "\n" .
\ 'For more information, see: '. l:violation['guideline'],
\ 'type': 'W',
\ })
endfor
return l:output
endfunction
call ale#linter#Define('terraform', {
\ 'name': 'checkov',
\ 'output_stream': 'stdout',
\ 'executable': function('ale_linters#terraform#checkov#GetExecutable'),
\ 'command': function('ale_linters#terraform#checkov#GetCommand'),
\ 'callback': 'ale_linters#terraform#checkov#Handle',
\})

View File

@ -21,7 +21,13 @@ function! ale_linters#terraform#terraform#GetType(severity) abort
endfunction
function! ale_linters#terraform#terraform#GetDetail(error) abort
return get(a:error, 'detail', get(a:error, 'summary', ''))
let l:detail = get(a:error, 'detail', '')
if strlen(l:detail) > 0
return l:detail
else
return get(a:error, 'summary', '')
endif
endfunction
function! ale_linters#terraform#terraform#Handle(buffer, lines) abort

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for TeX files.
call ale#handlers#cspell#DefineLinter('tex')

View File

@ -4,6 +4,7 @@
call ale#Set('tex_texlab_executable', 'texlab')
call ale#Set('tex_texlab_options', '')
call ale#Set('tex_texlab_config', {})
function! ale_linters#tex#texlab#GetProjectRoot(buffer) abort
let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git')
@ -21,4 +22,5 @@ call ale#linter#Define('tex', {
\ 'executable': {b -> ale#Var(b, 'tex_texlab_executable')},
\ 'command': function('ale_linters#tex#texlab#GetCommand'),
\ 'project_root': function('ale_linters#tex#texlab#GetProjectRoot'),
\ 'lsp_config': {b -> ale#Var(b, 'tex_texlab_config')},
\})

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for TeXInfo files.
call ale#handlers#cspell#DefineLinter('texinfo')

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for general text files.
call ale#handlers#cspell#DefineLinter('text')

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for TypeScript files.
call ale#handlers#cspell#DefineLinter('typescript')

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for Vue files.
call ale#handlers#cspell#DefineLinter('vue')

View File

@ -0,0 +1,80 @@
" Author: Arnold Chand <creativenull@outlook.com>
" Description: Volar Language Server integration for ALE adopted from
" nvim-lspconfig and volar/packages/shared/src/types.ts
call ale#Set('vue_volar_executable', 'volar-server')
call ale#Set('vue_volar_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('vue_volar_init_options', {
\ 'documentFeatures': {
\ 'documentColor': v:false,
\ 'documentFormatting': {
\ 'defaultPrintWidth': 100,
\ },
\ 'documentSymbol': v:true,
\ 'foldingRange': v:true,
\ 'linkedEditingRange': v:true,
\ 'selectionRange': v:true,
\ },
\ 'languageFeatures': {
\ 'callHierarchy': v:true,
\ 'codeAction': v:true,
\ 'codeLens': v:true,
\ 'completion': {
\ 'defaultAttrNameCase': 'kebabCase',
\ 'defaultTagNameCase': 'both',
\ 'getDocumentNameCaseRequest': v:false,
\ 'getDocumentSelectionRequest': v:false,
\ },
\ 'definition': v:true,
\ 'diagnostics': v:true,
\ 'documentHighlight': v:true,
\ 'documentLink': v:true,
\ 'hover': v:true,
\ 'references': v:true,
\ 'rename': v:true,
\ 'renameFileRefactoring': v:true,
\ 'schemaRequestService': v:true,
\ 'semanticTokens': v:false,
\ 'signatureHelp': v:true,
\ 'typeDefinition': v:true,
\ 'workspaceSymbol': v:false,
\ },
\ 'typescript': {
\ 'serverPath': '',
\ 'localizedPath': v:null,
\ },
\})
function! ale_linters#vue#volar#GetProjectRoot(buffer) abort
let l:project_roots = ['package.json', 'vite.config.js', '.git', bufname(a:buffer)]
for l:project_root in l:project_roots
let l:nearest_filepath = ale#path#FindNearestFile(a:buffer, l:project_root)
if !empty(l:nearest_filepath)
return fnamemodify(l:nearest_filepath, ':h')
endif
endfor
return ''
endfunction
function! ale_linters#vue#volar#GetInitializationOptions(buffer) abort
let l:tsserver_path = ale#path#FindNearestExecutable(a:buffer, [
\ 'node_modules/typescript/lib/tsserverlibrary.js'
\ ])
let l:init_options = ale#Var(a:buffer, 'vue_volar_init_options')
let l:init_options.typescript.serverPath = l:tsserver_path
return l:init_options
endfunction
call ale#linter#Define('vue', {
\ 'name': 'volar',
\ 'language': 'vue',
\ 'lsp': 'stdio',
\ 'executable': {b -> ale#path#FindExecutable(b, 'vue_volar', ['node_modules/.bin/volar-server'])},
\ 'command': '%e --stdio',
\ 'project_root': function('ale_linters#vue#volar#GetProjectRoot'),
\ 'initialization_options': function('ale_linters#vue#volar#GetInitializationOptions'),
\})

View File

@ -0,0 +1,12 @@
" Author: rhysd <https://github.com/rhysd>
" Description: naga-cli linter for WGSL syntax.
call ale#Set('wgsl_naga_executable', 'naga')
call ale#linter#Define('wgsl', {
\ 'name': 'naga',
\ 'executable': {b -> ale#Var(b, 'wgsl_naga_executable')},
\ 'output_stream': 'stderr',
\ 'command': {b -> '%e --stdin-file-path %s'},
\ 'callback': 'ale#handlers#naga#Handle',
\})

View File

@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for XHTML files.
call ale#handlers#cspell#DefineLinter('xhtml')

View File

@ -0,0 +1,11 @@
" Author: bretello <bretello@distruzione.org>
call ale#Set('yaml_actionlint_executable', 'actionlint')
call ale#Set('yaml_actionlint_options', '')
call ale#linter#Define('yaml', {
\ 'name': 'actionlint',
\ 'executable': {b -> ale#Var(b, 'yaml_actionlint_executable')},
\ 'command': function('ale#handlers#actionlint#GetCommand'),
\ 'callback': 'ale#handlers#actionlint#Handle',
\})

View File

@ -0,0 +1,34 @@
" Author: Jeffrey Lau - https://github.com/zoonfafer
" Description: YAML Language Server https://github.com/redhat-developer/yaml-language-server
call ale#Set('yaml_ls_executable', 'yaml-language-server')
call ale#Set('yaml_ls_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('yaml_ls_config', {})
function! ale_linters#yaml#ls#GetExecutable(buffer) abort
return ale#path#FindExecutable(a:buffer, 'yaml_ls', [
\ 'node_modules/.bin/yaml-language-server',
\])
endfunction
function! ale_linters#yaml#ls#GetCommand(buffer) abort
let l:executable = ale_linters#yaml#ls#GetExecutable(a:buffer)
return ale#Escape(l:executable) . ' --stdio'
endfunction
" Just use the current file
function! ale_linters#yaml#ls#FindProjectRoot(buffer) abort
let l:project_file = expand('#' . a:buffer . ':p')
return fnamemodify(l:project_file, ':h')
endfunction
call ale#linter#Define('yaml', {
\ 'name': 'yaml-language-server',
\ 'lsp': 'stdio',
\ 'executable': function('ale_linters#yaml#ls#GetExecutable'),
\ 'command': function('ale_linters#yaml#ls#GetCommand'),
\ 'project_root': function('ale_linters#yaml#ls#FindProjectRoot'),
\ 'lsp_config': {b -> ale#Var(b, 'yaml_ls_config')},
\})

View File

@ -157,7 +157,7 @@ function! ale#Queue(delay, ...) abort
endif
endfunction
let s:current_ale_version = [3, 1, 0]
let s:current_ale_version = [3, 2, 0]
" A function used to check for ALE features in files outside of the project.
function! ale#Has(feature) abort

View File

@ -16,13 +16,12 @@ endfunction
function! ale#code_action#HandleCodeAction(code_action, options) abort
let l:current_buffer = bufnr('')
let l:changes = a:code_action.changes
let l:should_save = get(a:options, 'should_save')
for l:file_code_edit in l:changes
call ale#code_action#ApplyChanges(
\ l:file_code_edit.fileName,
\ l:file_code_edit.textChanges,
\ l:should_save,
\ a:options,
\)
endfor
endfunction
@ -63,29 +62,29 @@ function! s:ChangeCmp(left, right) abort
return 0
endfunction
function! ale#code_action#ApplyChanges(filename, changes, should_save) abort
let l:current_buffer = bufnr('')
function! ale#code_action#ApplyChanges(filename, changes, options) abort
let l:should_save = get(a:options, 'should_save')
let l:conn_id = get(a:options, 'conn_id')
let l:orig_buffer = bufnr('')
" The buffer is used to determine the fileformat, if available.
let l:buffer = bufnr(a:filename)
let l:is_current_buffer = l:buffer > 0 && l:buffer == l:current_buffer
if l:buffer > 0
let l:lines = getbufline(l:buffer, 1, '$')
" Add empty line if there's trailing newline, like readfile() does.
if getbufvar(l:buffer, '&eol')
let l:lines += ['']
endif
else
let l:lines = readfile(a:filename, 'b')
if l:buffer != l:orig_buffer
call ale#util#Execute('silent edit ' . a:filename)
let l:buffer = bufnr('')
endif
if l:is_current_buffer
let l:pos = getpos('.')[1:2]
else
let l:pos = [1, 1]
let l:lines = getbufline(l:buffer, 1, '$')
" Add empty line if there's trailing newline, like readfile() does.
if getbufvar(l:buffer, '&eol')
let l:lines += ['']
endif
let l:pos = getpos('.')[1:2]
" Changes have to be sorted so we apply them from bottom-to-top
for l:code_edit in reverse(sort(copy(a:changes), function('s:ChangeCmp')))
let l:line = l:code_edit.start.line
@ -155,46 +154,25 @@ function! ale#code_action#ApplyChanges(filename, changes, should_save) abort
endif
endfor
if l:buffer > 0
" Make sure ale#util#{Writefile,SetBufferContents} add trailing
" newline if and only if it should be added.
if l:lines[-1] is# '' && getbufvar(l:buffer, '&eol')
call remove(l:lines, -1)
else
call setbufvar(l:buffer, '&eol', 0)
endif
elseif exists('+fixeol') && &fixeol && l:lines[-1] is# ''
" Not in buffer, ale#util#Writefile can't check &eol and always adds
" newline if &fixeol: remove to prevent double trailing newline.
" Make sure to add a trailing newline if and only if it should be added.
if l:lines[-1] is# '' && getbufvar(l:buffer, '&eol')
call remove(l:lines, -1)
endif
if a:should_save || l:buffer < 0
call ale#util#Writefile(l:buffer, l:lines, a:filename)
else
call ale#util#SetBufferContents(l:buffer, l:lines)
call setbufvar(l:buffer, '&eol', 0)
endif
if l:is_current_buffer
if a:should_save
call ale#util#Execute(':e!')
endif
call ale#util#SetBufferContents(l:buffer, l:lines)
call setpos('.', [0, l:pos[0], l:pos[1], 0])
call ale#lsp#NotifyForChanges(l:conn_id, l:buffer)
if l:should_save
call ale#util#Execute('silent w!')
endif
if a:should_save && l:buffer > 0 && !l:is_current_buffer
" Set up a one-time use event that will delete itself to reload the
" buffer next time it's entered to view the changes made to it.
execute 'augroup ALECodeActionReloadGroup' . l:buffer
autocmd!
call setpos('.', [0, l:pos[0], l:pos[1], 0])
execute printf(
\ 'autocmd BufEnter <buffer=%d>'
\ . ' call ale#code_action#ReloadBuffer()',
\ l:buffer
\)
augroup END
if l:orig_buffer != l:buffer && bufexists(l:orig_buffer)
call ale#util#Execute('silent buf ' . string(l:orig_buffer))
endif
endfunction
@ -300,7 +278,7 @@ function! ale#code_action#BuildChangesList(changes_map) abort
endfor
call add(l:changes, {
\ 'fileName': ale#path#FromURI(l:file_name),
\ 'fileName': ale#util#ToResource(l:file_name),
\ 'textChanges': l:text_changes,
\})
endfor

View File

@ -391,8 +391,8 @@ function! s:OnReady(
\ 'character': l:nearest_error.col - 1,
\ },
\ 'end': {
\ 'line': l:nearest_error.end_lnum - 1,
\ 'character': l:nearest_error.end_col,
\ 'line': get(l:nearest_error, 'end_lnum', 1) - 1,
\ 'character': get(l:nearest_error, 'end_col', 0)
\ },
\ },
\ },
@ -457,7 +457,7 @@ function! s:ExecuteGetCodeFix(linter, range, MenuCallback) abort
let [l:end_line, l:end_column] = getpos("'>")[1:2]
endif
let l:column = min([l:column, len(getline(l:line))])
let l:column = max([min([l:column, len(getline(l:line))]), 1])
let l:end_column = min([l:end_column, len(getline(l:end_line))])
let l:Callback = function(

View File

@ -16,7 +16,7 @@ onoremap <silent> <Plug>(ale_show_completion_menu) <Nop>
let g:ale_completion_delay = get(g:, 'ale_completion_delay', 100)
let g:ale_completion_excluded_words = get(g:, 'ale_completion_excluded_words', [])
let g:ale_completion_max_suggestions = get(g:, 'ale_completion_max_suggestions', 50)
let g:ale_completion_autoimport = get(g:, 'ale_completion_autoimport', 0)
let g:ale_completion_autoimport = get(g:, 'ale_completion_autoimport', 1)
let g:ale_completion_tsserver_remove_warnings = get(g:, 'ale_completion_tsserver_remove_warnings', 0)
let s:timer_id = -1
@ -133,11 +133,13 @@ let s:should_complete_map = {
\ 'typescript': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|''$|"$',
\ 'rust': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|::$',
\ 'cpp': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|::$|-\>$',
\ 'c': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|-\>$',
\}
" Regular expressions for finding the start column to replace with completion.
let s:omni_start_map = {
\ '<default>': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$',
\ 'racket': '\k\+',
\}
" A map of exact characters for triggering LSP completions. Do not forget to
@ -147,6 +149,7 @@ let s:trigger_character_map = {
\ 'typescript': ['.', '''', '"'],
\ 'rust': ['.', '::'],
\ 'cpp': ['.', '::', '->'],
\ 'c': ['.', '->'],
\}
function! s:GetFiletypeValue(map, filetype) abort
@ -581,7 +584,7 @@ function! ale#completion#ParseLSPCompletions(response) abort
continue
endif
if get(l:item, 'insertTextFormat') is s:LSP_INSERT_TEXT_FORMAT_PLAIN
if get(l:item, 'insertTextFormat', s:LSP_INSERT_TEXT_FORMAT_PLAIN) is s:LSP_INSERT_TEXT_FORMAT_PLAIN
\&& type(get(l:item, 'textEdit')) is v:t_dict
let l:text = l:item.textEdit.newText
elseif type(get(l:item, 'insertText')) is v:t_string
@ -776,7 +779,8 @@ function! s:OnReady(linter, lsp_details) abort
if a:linter.lsp is# 'tsserver'
if get(g:, 'ale_completion_tsserver_autoimport') is 1
execute 'echom `g:ale_completion_tsserver_autoimport` is deprecated. Use `g:ale_completion_autoimport` instead.'''
" no-custom-checks
echom '`g:ale_completion_tsserver_autoimport` is deprecated. Use `g:ale_completion_autoimport` instead.'
endif
let l:message = ale#lsp#tsserver_message#Completions(
@ -911,7 +915,8 @@ function! ale#completion#Import() abort
endif
let [l:line, l:column] = getpos('.')[1:2]
let l:column = searchpos('\V' . escape(l:word, '/\'), 'bn', l:line)[1]
let l:column = searchpos('\V' . escape(l:word, '/\'), 'bnc', l:line)[1]
let l:column = l:column + len(l:word) - 1
if l:column isnot 0
let l:started = ale#completion#GetCompletions('ale-import', {

View File

@ -10,12 +10,21 @@ let g:ale_echo_msg_format = get(g:, 'ale_echo_msg_format', '%code: %%s')
let s:cursor_timer = -1
" A wrapper for echon so we can test messages we echo in Vader tests.
function! ale#cursor#Echom(message) abort
" no-custom-checks
exec "norm! :echom a:message\n"
endfunction
function! ale#cursor#TruncatedEcho(original_message) abort
let l:message = a:original_message
" Change tabs to spaces.
let l:message = substitute(l:message, "\t", ' ', 'g')
" Remove any newlines in the message.
let l:message = substitute(l:message, "\n", '', 'g')
" Convert indentation groups into single spaces for better legibility when
" put on a single line
let l:message = substitute(l:message, ' \+', ' ', 'g')
" We need to remember the setting for shortmess and reset it again.
let l:shortmess_options = &l:shortmess
@ -27,7 +36,7 @@ function! ale#cursor#TruncatedEcho(original_message) abort
silent! setlocal shortmess+=T
try
exec "norm! :echomsg l:message\n"
call ale#cursor#Echom(l:message)
catch /^Vim\%((\a\+)\)\=:E523/
" Fallback into manual truncate (#1987)
let l:winwidth = winwidth(0)
@ -87,7 +96,9 @@ function! ale#cursor#EchoCursorWarning(...) abort
elseif get(l:info, 'echoed')
" We'll only clear the echoed message when moving off errors once,
" so we don't continually clear the echo line.
execute 'echo'
"
" no-custom-checks
echo
let l:info.echoed = 0
endif
endif
@ -150,7 +161,8 @@ function! s:ShowCursorDetailForItem(loc, options) abort
" Clear the echo message if we manually displayed details.
if !l:stay_here
execute 'echo'
" no-custom-checks
echo
endif
endif
endfunction

View File

@ -62,7 +62,8 @@ let s:global_variable_list = [
\]
function! s:Echo(message) abort
execute 'echo a:message'
" no-custom-checks
echo a:message
endfunction
function! s:GetLinterVariables(filetype, exclude_linter_names) abort

View File

@ -68,18 +68,27 @@ function! ale#definition#HandleLSPResponse(conn_id, response) abort
for l:item in l:result
if has_key(l:item, 'targetUri')
" LocationLink items use targetUri
let l:filename = ale#path#FromURI(l:item.targetUri)
let l:uri = l:item.targetUri
let l:line = l:item.targetRange.start.line + 1
let l:column = l:item.targetRange.start.character + 1
else
" LocationLink items use uri
let l:filename = ale#path#FromURI(l:item.uri)
let l:uri = l:item.uri
let l:line = l:item.range.start.line + 1
let l:column = l:item.range.start.character + 1
endif
call ale#definition#UpdateTagStack()
call ale#util#Open(l:filename, l:line, l:column, l:options)
let l:uri_handler = ale#uri#GetURIHandler(l:uri)
if l:uri_handler is# v:null
let l:filename = ale#path#FromFileURI(l:uri)
call ale#util#Open(l:filename, l:line, l:column, l:options)
else
call l:uri_handler.OpenURILink(l:uri, l:line, l:column, l:options, a:conn_id)
endif
break
endfor
endif
@ -112,6 +121,12 @@ function! s:OnReady(line, column, options, capability, linter, lsp_details) abor
\ a:line,
\ a:column
\)
elseif a:capability is# 'implementation'
let l:message = ale#lsp#tsserver_message#Implementation(
\ l:buffer,
\ a:line,
\ a:column
\)
endif
else
" Send a message saying the buffer has changed first, or the
@ -125,6 +140,8 @@ function! s:OnReady(line, column, options, capability, linter, lsp_details) abor
let l:message = ale#lsp#message#Definition(l:buffer, a:line, a:column)
elseif a:capability is# 'typeDefinition'
let l:message = ale#lsp#message#TypeDefinition(l:buffer, a:line, a:column)
elseif a:capability is# 'implementation'
let l:message = ale#lsp#message#Implementation(l:buffer, a:line, a:column)
else
" XXX: log here?
return
@ -166,6 +183,14 @@ function! ale#definition#GoToType(options) abort
endfor
endfunction
function! ale#definition#GoToImpl(options) abort
for l:linter in ale#linter#Get(&filetype)
if !empty(l:linter.lsp)
call s:GoToLSPDefinition(l:linter, a:options, 'implementation')
endif
endfor
endfunction
function! ale#definition#GoToCommandHandler(command, ...) abort
let l:options = {}
@ -191,6 +216,8 @@ function! ale#definition#GoToCommandHandler(command, ...) abort
if a:command is# 'type'
call ale#definition#GoToType(l:options)
elseif a:command is# 'implementation'
call ale#definition#GoToImpl(l:options)
else
call ale#definition#GoTo(l:options)
endif

View File

@ -347,6 +347,12 @@ function! ale#engine#FixLocList(buffer, linter_name, from_other_source, loclist)
if has_key(l:old_item, 'end_lnum')
let l:item.end_lnum = str2nr(l:old_item.end_lnum)
" When the error ends after the end of the file, put it at the
" end. This is only done for the current buffer.
if l:item.bufnr == a:buffer && l:item.end_lnum > l:last_line_number
let l:item.end_lnum = l:last_line_number
endif
endif
if has_key(l:old_item, 'sub_type')

View File

@ -156,4 +156,10 @@ function! ale#events#Init() abort
endif
endif
augroup END
augroup AleURISchemes
autocmd!
autocmd BufNewFile,BufReadPre jdt://** call ale#uri#jdt#ReadJDTLink(expand('<amatch>'))
augroup END
endfunction

View File

@ -0,0 +1,133 @@
" Author: Dalius Dobravolskas <dalius.dobravolskas@gmail.com>
" Description: Rename file support for tsserver
let s:filerename_map = {}
" Used to get the rename map in tests.
function! ale#filerename#GetMap() abort
return deepcopy(s:filerename_map)
endfunction
" Used to set the rename map in tests.
function! ale#filerename#SetMap(map) abort
let s:filerename_map = a:map
endfunction
function! ale#filerename#ClearLSPData() abort
let s:filerename_map = {}
endfunction
function! s:message(message) abort
call ale#util#Execute('echom ' . string(a:message))
endfunction
function! ale#filerename#HandleTSServerResponse(conn_id, response) abort
if get(a:response, 'command', '') isnot# 'getEditsForFileRename'
return
endif
if !has_key(s:filerename_map, a:response.request_seq)
return
endif
let l:options = remove(s:filerename_map, a:response.request_seq)
let l:old_name = l:options.old_name
let l:new_name = l:options.new_name
if get(a:response, 'success', v:false) is v:false
let l:message = get(a:response, 'message', 'unknown')
call s:message('Error renaming file "' . l:old_name . '" to "' . l:new_name
\ . '". Reason: ' . l:message)
return
endif
let l:changes = a:response.body
if empty(l:changes)
call s:message('No changes while renaming "' . l:old_name . '" to "' . l:new_name . '"')
else
call ale#code_action#HandleCodeAction(
\ {
\ 'description': 'filerename',
\ 'changes': l:changes,
\ },
\ {
\ 'should_save': 1,
\ },
\)
endif
silent! noautocmd execute 'saveas ' . l:new_name
call delete(l:old_name)
endfunction
function! s:OnReady(options, linter, lsp_details) abort
let l:id = a:lsp_details.connection_id
if !ale#lsp#HasCapability(l:id, 'filerename')
return
endif
let l:buffer = a:lsp_details.buffer
let l:Callback = function('ale#filerename#HandleTSServerResponse')
call ale#lsp#RegisterCallback(l:id, l:Callback)
let l:message = ale#lsp#tsserver_message#GetEditsForFileRename(
\ a:options.old_name,
\ a:options.new_name,
\)
let l:request_id = ale#lsp#Send(l:id, l:message)
let s:filerename_map[l:request_id] = a:options
endfunction
function! s:ExecuteFileRename(linter, options) abort
let l:buffer = bufnr('')
let l:Callback = function('s:OnReady', [a:options])
call ale#lsp_linter#StartLSP(l:buffer, a:linter, l:Callback)
endfunction
function! ale#filerename#Execute() abort
let l:lsp_linters = []
for l:linter in ale#linter#Get(&filetype)
if l:linter.lsp is# 'tsserver'
call add(l:lsp_linters, l:linter)
endif
endfor
if empty(l:lsp_linters)
call s:message('No active tsserver LSPs')
return
endif
let l:buffer = bufnr('')
let l:old_name = expand('#' . l:buffer . ':p')
let l:new_name = ale#util#Input('New file name: ', l:old_name, 'file')
if l:old_name is# l:new_name
call s:message('New file name matches old file name')
return
endif
if empty(l:new_name)
call s:message('New name cannot be empty!')
return
endif
for l:lsp_linter in l:lsp_linters
call s:ExecuteFileRename(l:lsp_linter, {
\ 'old_name': l:old_name,
\ 'new_name': l:new_name,
\})
endfor
endfunction

View File

@ -77,7 +77,8 @@ function! ale#fix#ApplyFixes(buffer, output) abort
call remove(g:ale_fix_buffer_data, a:buffer)
if !l:data.ignore_file_changed_errors
execute 'echoerr ''The file was changed before fixing finished'''
" no-custom-checks
echoerr 'The file was changed before fixing finished'
endif
return
@ -358,7 +359,8 @@ function! ale#fix#Fix(buffer, fixing_flag, ...) abort
\ 'There is no fixer named `%s`. Check :ALEFixSuggest',
\ l:function_name,
\)
execute 'echom l:echo_message'
" no-custom-checks
echom l:echo_message
endif
return 0
@ -366,7 +368,8 @@ function! ale#fix#Fix(buffer, fixing_flag, ...) abort
if empty(l:callback_list)
if a:fixing_flag is# ''
execute 'echom ''No fixers have been defined. Try :ALEFixSuggest'''
" no-custom-checks
echom 'No fixers have been defined. Try :ALEFixSuggest'
endif
return 0

View File

@ -37,6 +37,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['python'],
\ 'description': 'Fix PEP8 issues with black.',
\ },
\ 'buf-format': {
\ 'function': 'ale#fixers#buf_format#Fix',
\ 'suggested_filetypes': ['proto'],
\ 'description': 'Fix .proto files with buf format.',
\ },
\ 'buildifier': {
\ 'function': 'ale#fixers#buildifier#Fix',
\ 'suggested_filetypes': ['bzl'],
@ -73,6 +78,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['dhall'],
\ 'description': 'Standard code formatter for the Dhall language and removing dead code',
\ },
\ 'dune': {
\ 'function': 'ale#fixers#dune#Fix',
\ 'suggested_filetypes': ['dune'],
\ 'description': 'Fix dune files with dune format',
\ },
\ 'fecs': {
\ 'function': 'ale#fixers#fecs#Fix',
\ 'suggested_filetypes': ['javascript', 'css', 'html'],
@ -131,6 +141,11 @@ let s:default_registry = {
\ 'description': 'Apply prettier-eslint to a file.',
\ 'aliases': ['prettier-eslint'],
\ },
\ 'pyflyby': {
\ 'function': 'ale#fixers#pyflyby#Fix',
\ 'suggested_filetypes': ['python'],
\ 'description': 'Tidy Python imports with pyflyby.',
\ },
\ 'importjs': {
\ 'function': 'ale#fixers#importjs#Fix',
\ 'suggested_filetypes': ['javascript'],
@ -191,6 +206,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['ruby'],
\ 'description': 'Fix ruby files with standardrb --fix',
\ },
\ 'statix': {
\ 'function': 'ale#fixers#statix#Fix',
\ 'suggested_filetypes': ['nix'],
\ 'description': 'Fix common Nix antipatterns with statix fix',
\ },
\ 'stylelint': {
\ 'function': 'ale#fixers#stylelint#Fix',
\ 'suggested_filetypes': ['css', 'sass', 'scss', 'sugarss', 'stylus'],
@ -216,6 +236,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['php'],
\ 'description': 'Fix PHP files with php-cs-fixer.',
\ },
\ 'pint': {
\ 'function': 'ale#fixers#pint#Fix',
\ 'suggested_filetypes': ['php'],
\ 'description': 'Fix PHP files with Laravel Pint.',
\ },
\ 'astyle': {
\ 'function': 'ale#fixers#astyle#Fix',
\ 'suggested_filetypes': ['c', 'cpp'],
@ -246,6 +271,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['go'],
\ 'description': 'Fix Go files with go fmt.',
\ },
\ 'gofumpt': {
\ 'function': 'ale#fixers#gofumpt#Fix',
\ 'suggested_filetypes': ['go'],
\ 'description': 'Fix Go files with gofumpt, a stricter go fmt.',
\ },
\ 'goimports': {
\ 'function': 'ale#fixers#goimports#Fix',
\ 'suggested_filetypes': ['go'],
@ -421,6 +451,16 @@ let s:default_registry = {
\ 'suggested_filetypes': ['hcl', 'terraform'],
\ 'description': 'Fix tf and hcl files with terraform fmt.',
\ },
\ 'packer': {
\ 'function': 'ale#fixers#packer#Fix',
\ 'suggested_filetypes': ['hcl', 'packer'],
\ 'description': 'Fix Packer HCL files with packer fmt.',
\ },
\ 'crystal': {
\ 'function': 'ale#fixers#crystal#Fix',
\ 'suggested_filetypes': ['cr'],
\ 'description': 'Fix cr (crystal).',
\ },
\ 'ktlint': {
\ 'function': 'ale#fixers#ktlint#Fix',
\ 'suggested_filetypes': ['kt', 'kotlin'],
@ -481,6 +521,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['lua'],
\ 'description': 'Fix Lua files with luafmt.',
\ },
\ 'dprint': {
\ 'function': 'ale#fixers#dprint#Fix',
\ 'suggested_filetypes': ['javascript', 'typescript', 'json', 'markdown'],
\ 'description': 'Pluggable and configurable code formatting platform',
\ },
\ 'stylua': {
\ 'function': 'ale#fixers#stylua#Fix',
\ 'suggested_filetypes': ['lua'],
@ -501,10 +546,20 @@ let s:default_registry = {
\ 'suggested_filetypes': ['pascal'],
\ 'description': 'Fix Pascal files with ptop.',
\ },
\ 'opafmt': {
\ 'function': 'ale#fixers#opafmt#Fix',
\ 'suggested_filetypes': ['rego'],
\ 'description': 'Fix rego files with opa fmt.',
\ },
\ 'vfmt': {
\ 'function': 'ale#fixers#vfmt#Fix',
\ 'suggested_filetypes': ['v'],
\ 'description': 'A formatter for V source code.',
\ },
\ 'zigfmt': {
\ 'function': 'ale#fixers#zigfmt#Fix',
\ 'suggested_filetypes': ['zig'],
\ 'description': 'Official formatter for Zig',
\ }
\}

View File

@ -0,0 +1,12 @@
" Author: Alex McKinney <alexmckinney01@gmail.com>
" Description: Run buf format.
call ale#Set('proto_buf_format_executable', 'buf')
function! ale#fixers#buf_format#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'proto_buf_format_executable')
return {
\ 'command': ale#Escape(l:executable) . ' format %t',
\}
endfunction

View File

@ -0,0 +1,14 @@
call ale#Set('crystal_format_executable', 'crystal')
call ale#Set('crystal_format_options', '')
function! ale#fixers#crystal#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'crystal_format_executable')
let l:options = ale#Var(a:buffer, 'crystal_format_options')
return {
\ 'command': ale#Escape(l:executable)
\ . ' tool format'
\ . ale#Pad(l:options)
\ . ' -'
\}
endfunction

View File

@ -0,0 +1,29 @@
call ale#Set('dprint_executable', 'dprint')
call ale#Set('dprint_executable_override', 0)
call ale#Set('dprint_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('dprint_options', '')
call ale#Set('dprint_config', 'dprint.json')
function! ale#fixers#dprint#Fix(buffer) abort
let l:executable = ale#path#FindExecutable(a:buffer, 'dprint', ['dprint'])
let l:executable_override = ale#Var(a:buffer, 'dprint_executable_override')
if !executable(l:executable) && !l:executable_override
return 0
endif
let l:options = ale#Var(a:buffer, 'dprint_options')
let l:config = ale#path#FindNearestFile(a:buffer, ale#Var(a:buffer, 'dprint_config'))
if !empty(l:config)
let l:options = l:options . ' -c ' . ale#Escape(l:config)
endif
let l:options = l:options . ' --stdin %s'
return {
\ 'command': ale#Escape(l:executable)
\ . ' fmt '
\ . l:options
\}
endfunction

View File

@ -0,0 +1,16 @@
" Author: Albert Peschar <albert@peschar.net>
" Description: Fix files with dune format.
call ale#Set('ocaml_dune_executable', 'dune')
call ale#Set('ocaml_dune_options', '')
function! ale#fixers#dune#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'ocaml_dune_executable')
let l:options = ale#Var(a:buffer, 'ocaml_dune_options')
return {
\ 'command': ale#Escape(l:executable)
\ . ' format'
\ . (empty(l:options) ? '' : ' ' . l:options),
\}
endfunction

View File

@ -0,0 +1,17 @@
" Author: David Houston <houstdav000>
" Description: A stricter gofmt implementation.
call ale#Set('go_gofumpt_executable', 'gofumpt')
call ale#Set('go_gofumpt_options', '')
function! ale#fixers#gofumpt#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'go_gofumpt_executable')
let l:options = ale#Var(a:buffer, 'go_gofumpt_options')
return {
\ 'command': ale#Escape(l:executable)
\ . ale#Pad(l:options)
\ . ' -w -- %t',
\ 'read_temporary_file': 1,
\}
endfunction

View File

@ -0,0 +1,15 @@
" Description: Fixer for rego files
call ale#Set('opa_fmt_executable', 'opa')
call ale#Set('opa_fmt_options', '')
function! ale#fixers#opafmt#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'opa_fmt_executable')
let l:options = ale#Var(a:buffer, 'opa_fmt_options')
return {
\ 'command': ale#Escape(l:executable)
\ . ' fmt'
\ . (empty(l:options) ? '' : ' ' . l:options)
\}
endfunction

View File

@ -0,0 +1,17 @@
" Author: Zhuoyun Wei <wzyboy@wzyboy.org>
" Description: Fixer for Packer HCL files
call ale#Set('packer_fmt_executable', 'packer')
call ale#Set('packer_fmt_options', '')
function! ale#fixers#packer#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'packer_fmt_executable')
let l:options = ale#Var(a:buffer, 'packer_fmt_options')
return {
\ 'command': ale#Escape(l:executable)
\ . ' fmt'
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ' -'
\}
endfunction

View File

@ -0,0 +1,25 @@
" Author: Michael Dyrynda <michael@dyrynda.com.au>
" Description: Fixing files with Laravel Pint.
call ale#Set('php_pint_executable', 'pint')
call ale#Set('php_pint_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('php_pint_options', '')
function! ale#fixers#pint#GetExecutable(buffer) abort
return ale#path#FindExecutable(a:buffer, 'php_pint', [
\ 'vendor/bin/pint',
\ 'pint'
\])
endfunction
function! ale#fixers#pint#Fix(buffer) abort
let l:executable = ale#fixers#pint#GetExecutable(a:buffer)
return {
\ 'command': ale#Escape(l:executable)
\ . ' ' . ale#Var(a:buffer, 'php_pint_options')
\ . ' %t',
\ 'read_temporary_file': 1,
\}
endfunction

View File

@ -0,0 +1,41 @@
" Author: infokiller <joweill@icloud.com>
" Description: Tidy imports using pyflyby's tidy-import script
" https://github.com/deshaw/pyflyby
call ale#Set('python_pyflyby_executable', 'tidy-imports')
call ale#Set('python_pyflyby_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_pyflyby_options', '')
call ale#Set('python_pyflyby_auto_pipenv', 0)
call ale#Set('python_pyflyby_auto_poetry', 0)
function! ale#fixers#pyflyby#GetExecutable(buffer) abort
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyflyby_auto_pipenv'))
\ && ale#python#PipenvPresent(a:buffer)
return 'pipenv'
endif
if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pyflyby_auto_poetry'))
\ && ale#python#PoetryPresent(a:buffer)
return 'poetry'
endif
return ale#python#FindExecutable(a:buffer, 'python_pyflyby', ['tidy-imports'])
endfunction
function! ale#fixers#pyflyby#Fix(buffer) abort
" let l:executable = ale#fixers#pyflyby#GetExecutable(a:buffer)
let l:executable = ale#fixers#pyflyby#GetExecutable(a:buffer)
let l:cmd = [ale#Escape(l:executable)]
if l:executable =~? 'pipenv\|poetry$'
call extend(l:cmd, ['run', 'tidy-imports'])
endif
let l:options = ale#Var(a:buffer, 'python_pyflyby_options')
if !empty(l:options)
call add(l:cmd, l:options)
endif
return {'command': join(l:cmd, ' ')}
endfunction

View File

@ -5,27 +5,13 @@ scriptencoding utf-8
call ale#Set('sh_shfmt_executable', 'shfmt')
call ale#Set('sh_shfmt_options', '')
function! s:DefaultOption(buffer) abort
if getbufvar(a:buffer, '&expandtab') == 0
" Tab is used by default
return ''
endif
let l:tabsize = getbufvar(a:buffer, '&shiftwidth')
if l:tabsize == 0
let l:tabsize = getbufvar(a:buffer, '&tabstop')
endif
return ' -i ' . l:tabsize
endfunction
function! ale#fixers#shfmt#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'sh_shfmt_executable')
let l:options = ale#Var(a:buffer, 'sh_shfmt_options')
return {
\ 'command': ale#Escape(l:executable)
\ . (empty(l:options) ? s:DefaultOption(a:buffer) : ' ' . l:options)
\ . ' -filename=%s'
\ . (empty(l:options) ? '' : ' ' . l:options)
\}
endfunction

View File

@ -0,0 +1,17 @@
" Author: David Houston <houstdav000>
" Description: Provide statix fix as a fixer for simple Nix antipatterns.
call ale#Set('nix_statix_fix_executable', 'statix')
call ale#Set('nix_statix_fix_options', '')
function! ale#fixers#statix#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'nix_statix_fix_executable')
let l:options = ale#Var(a:buffer, 'nix_statix_fix_options')
return {
\ 'command': ale#Escape(l:executable)
\ . ale#Pad('fix')
\ . ale#Pad('--stdin')
\ . ale#Pad(l:options),
\}
endfunction

View File

@ -4,13 +4,30 @@
call ale#Set('c_uncrustify_executable', 'uncrustify')
call ale#Set('c_uncrustify_options', '')
let s:languages = {
\ 'c': 'C',
\ 'cpp': 'CPP',
\ 'cs': 'CS',
\ 'objc': 'OC',
\ 'objcpp': 'OC+',
\ 'd': 'D',
\ 'java': 'JAVA',
\ 'vala': 'VALA',
\ 'p': 'PAWN',
\}
function! ale#fixers#uncrustify#Language(buffer) abort
return get(s:languages, &filetype, 'C')
endfunction
function! ale#fixers#uncrustify#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'c_uncrustify_executable')
let l:options = ale#Var(a:buffer, 'c_uncrustify_options')
return {
\ 'command': ale#Escape(l:executable)
\ . ' --no-backup'
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ' --no-backup '
\ . '-l' . ale#Pad(ale#fixers#uncrustify#Language(a:buffer))
\ . ale#Pad(l:options)
\}
endfunction

View File

@ -0,0 +1,14 @@
scriptencoding utf-8
" Author: Arash Mousavi <arash-m>
" Description: Official formatter for Zig.
call ale#Set('zig_zigfmt_executable', 'zig')
function! ale#fixers#zigfmt#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'zig_zigfmt_executable')
return {
\ 'command': ale#Escape(l:executable) . ' fmt %t',
\ 'read_temporary_file': 1,
\}
endfunction

View File

@ -7,7 +7,8 @@
function! ale#floating_preview#Show(lines, ...) abort
if !exists('*nvim_open_win') && !has('popupwin')
execute 'echom ''Floating windows not supported in this vim instance.'''
" no-custom-checks
echom 'Floating windows not supported in this vim instance.'
return
endif
@ -105,18 +106,20 @@ function! s:NvimPrepareWindowContent(lines) abort
let l:width += 2
let l:height += 2
let l:hor = g:ale_floating_window_border[0]
let l:top = g:ale_floating_window_border[1]
let l:top_left = g:ale_floating_window_border[2]
let l:top_right = g:ale_floating_window_border[3]
let l:bottom_right = g:ale_floating_window_border[4]
let l:bottom_left = g:ale_floating_window_border[5]
let l:left = get(g:ale_floating_window_border, 0, '|')
let l:top = get(g:ale_floating_window_border, 1, '-')
let l:top_left = get(g:ale_floating_window_border, 2, '+')
let l:top_right = get(g:ale_floating_window_border, 3, '+')
let l:bottom_right = get(g:ale_floating_window_border, 4, '+')
let l:bottom_left = get(g:ale_floating_window_border, 5, '+')
let l:right = get(g:ale_floating_window_border, 6, l:left)
let l:bottom = get(g:ale_floating_window_border, 7, l:top)
let l:lines = [l:top_left . repeat(l:top, l:width - 2) . l:top_right]
for l:line in a:lines
let l:line_width = strchars(l:line)
let l:lines = add(l:lines, l:hor . l:line . repeat(' ', l:width - l:line_width - 2). l:hor)
let l:lines = add(l:lines, l:left . l:line . repeat(' ', l:width - l:line_width - 2). l:right)
endfor
" Truncate the lines
@ -124,7 +127,7 @@ function! s:NvimPrepareWindowContent(lines) abort
let l:lines = l:lines[0:l:max_height]
endif
let l:lines = add(l:lines, l:bottom_left . repeat(l:top, l:width - 2) . l:bottom_right)
let l:lines = add(l:lines, l:bottom_left . repeat(l:bottom, l:width - 2) . l:bottom_right)
return [l:lines, l:width, l:height]
endfunction
@ -157,14 +160,14 @@ function! s:VimCreate(options) abort
\ 'padding': [0, 1, 0, 1],
\ 'border': [],
\ 'borderchars': empty(g:ale_floating_window_border) ? [' '] : [
\ g:ale_floating_window_border[1],
\ g:ale_floating_window_border[0],
\ g:ale_floating_window_border[1],
\ g:ale_floating_window_border[0],
\ g:ale_floating_window_border[2],
\ g:ale_floating_window_border[3],
\ g:ale_floating_window_border[4],
\ g:ale_floating_window_border[5],
\ get(g:ale_floating_window_border, 1, '-'),
\ get(g:ale_floating_window_border, 6, '|'),
\ get(g:ale_floating_window_border, 7, '-'),
\ get(g:ale_floating_window_border, 0, '|'),
\ get(g:ale_floating_window_border, 2, '+'),
\ get(g:ale_floating_window_border, 3, '+'),
\ get(g:ale_floating_window_border, 4, '+'),
\ get(g:ale_floating_window_border, 5, '+'),
\ ],
\ 'moved': 'any',
\ })

View File

@ -0,0 +1,36 @@
function! ale#handlers#actionlint#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'yaml_actionlint_options')
" automatically add --no-color option if not defined
if l:options !~# '--no-color'
let l:options .= ' --no-color'
endif
" automatically add --oneline option if not defined
if l:options !~# '--oneline'
let l:options .= ' --oneline'
endif
return '%e ' . l:options . ' %t'
endfunction
function! ale#handlers#actionlint#Handle(buffer, lines) abort
" Matches patterns line the following:
".github/workflows/main.yml:19:0: could not parse as YAML: yaml: line 19: mapping values are not allowed in this context [yaml-syntax]
let l:pattern = '\v^.*:(\d+):(\d+): (.+) \[(.+)\]$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:item = {
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[3],
\ 'code': l:match[4],
\ 'type': 'E',
\}
call add(l:output, l:item)
endfor
return l:output
endfunction

Some files were not shown because too many files have changed in this diff Show More