Skip to content

Commit bf7b598

Browse files
committed
Added missing commits
1 parent f50b214 commit bf7b598

File tree

28 files changed

+1928
-0
lines changed

28 files changed

+1928
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
" Author: TANIGUCHI Masaya <ta2gch@gmail.com>
2+
" Description: textlint for AsciiDoc files
3+
4+
call ale#linter#Define('asciidoc', {
5+
\ 'name': 'textlint',
6+
\ 'executable': function('ale#handlers#textlint#GetExecutable'),
7+
\ 'command': function('ale#handlers#textlint#GetCommand'),
8+
\ 'callback': 'ale#handlers#textlint#HandleTextlintOutput',
9+
\})
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
" Author: Harrison Bachrach - https://github.com/HarrisonB
2+
" Description: Ameba, a linter for crystal files
3+
4+
call ale#Set('crystal_ameba_executable', 'bin/ameba')
5+
6+
function! ale_linters#crystal#ameba#GetCommand(buffer) abort
7+
let l:executable = ale#Var(a:buffer, 'crystal_ameba_executable')
8+
9+
return ale#Escape(l:executable)
10+
\ . ' --format json '
11+
\ . ale#Escape(expand('#' . a:buffer . ':p'))
12+
endfunction
13+
14+
" Handle output from ameba
15+
function! ale_linters#crystal#ameba#HandleAmebaOutput(buffer, lines) abort
16+
if len(a:lines) == 0
17+
return []
18+
endif
19+
20+
let l:errors = ale#util#FuzzyJSONDecode(a:lines[0], {})
21+
22+
if !has_key(l:errors, 'summary')
23+
\|| l:errors['summary']['issues_count'] == 0
24+
\|| empty(l:errors['sources'])
25+
return []
26+
endif
27+
28+
let l:output = []
29+
30+
for l:error in l:errors['sources'][0]['issues']
31+
let l:start_col = str2nr(l:error['location']['column'])
32+
let l:end_col = str2nr(l:error['end_location']['column'])
33+
34+
if !l:end_col
35+
let l:end_col = l:start_col + 1
36+
endif
37+
38+
call add(l:output, {
39+
\ 'lnum': str2nr(l:error['location']['line']),
40+
\ 'col': l:start_col,
41+
\ 'end_col': l:end_col,
42+
\ 'code': l:error['rule_name'],
43+
\ 'text': l:error['message'],
44+
\ 'type': 'W',
45+
\})
46+
endfor
47+
48+
return l:output
49+
endfunction
50+
51+
call ale#linter#Define('crystal', {
52+
\ 'name': 'ameba',
53+
\ 'executable': {b -> ale#Var(b, 'crystal_ameba_executable')},
54+
\ 'command': function('ale_linters#crystal#ameba#GetCommand'),
55+
\ 'callback': 'ale_linters#crystal#ameba#HandleAmebaOutput',
56+
\ 'lint_file': 1,
57+
\})
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
" Author: Francisco Lopes <francisco@oblita.com>
2+
" Description: Linting for Neo4j's Cypher
3+
4+
function! ale_linters#cypher#cypher_lint#Handle(buffer, lines) abort
5+
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+): (.*)$'
6+
let l:output = []
7+
8+
for l:match in ale#util#GetMatches(a:lines, l:pattern)
9+
call add(l:output, {
10+
\ 'lnum': l:match[2] + 0,
11+
\ 'col': l:match[3] + 0,
12+
\ 'text': l:match[4],
13+
\ 'type': 'E',
14+
\})
15+
endfor
16+
17+
return l:output
18+
endfunction
19+
20+
call ale#linter#Define('cypher', {
21+
\ 'name': 'cypher_lint',
22+
\ 'executable': 'cypher-lint',
23+
\ 'command': 'cypher-lint',
24+
\ 'output_stream': 'stderr',
25+
\ 'callback': 'ale_linters#cypher#cypher_lint#Handle',
26+
\})
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
" Author: Martino Pilia <martino.pilia@gmail.com>
2+
" Description: bandit linting for python files
3+
4+
call ale#Set('python_bandit_executable', 'bandit')
5+
call ale#Set('python_bandit_options', '')
6+
call ale#Set('python_bandit_use_config', 1)
7+
call ale#Set('python_bandit_use_global', get(g:, 'ale_use_global_executables', 0))
8+
call ale#Set('python_bandit_auto_pipenv', 0)
9+
10+
function! ale_linters#python#bandit#GetExecutable(buffer) abort
11+
if (
12+
\ ale#Var(a:buffer, 'python_auto_pipenv')
13+
\ || ale#Var(a:buffer, 'python_bandit_auto_pipenv')
14+
\) && ale#python#PipenvPresent(a:buffer)
15+
return 'pipenv'
16+
endif
17+
18+
return ale#python#FindExecutable(a:buffer, 'python_bandit', ['bandit'])
19+
endfunction
20+
21+
function! ale_linters#python#bandit#GetCommand(buffer) abort
22+
let l:executable = ale_linters#python#bandit#GetExecutable(a:buffer)
23+
let l:flags = ' --format custom'
24+
\ . ' --msg-template "{line}:{test_id}:{severity}:{msg}" '
25+
26+
if ale#Var(a:buffer, 'python_bandit_use_config')
27+
let l:config_path = ale#path#FindNearestFile(a:buffer, '.bandit')
28+
29+
if !empty(l:config_path)
30+
let l:flags = ' --ini ' . ale#Escape(l:config_path) . l:flags
31+
endif
32+
endif
33+
34+
let l:exec_args = l:executable =~? 'pipenv$'
35+
\ ? ' run bandit'
36+
\ : ''
37+
38+
return ale#Escape(l:executable) . l:exec_args
39+
\ . l:flags
40+
\ . ale#Pad(ale#Var(a:buffer, 'python_bandit_options'))
41+
\ . ' -'
42+
endfunction
43+
44+
function! ale_linters#python#bandit#Handle(buffer, lines) abort
45+
" Custom format defined in GetCommand via --msg-template
46+
let l:pattern = '\v^([0-9]+):(B[0-9]+):([A-Z]+):(.*)$'
47+
let l:severity = {'LOW': 'I', 'MEDIUM': 'W', 'HIGH': 'E'}
48+
let l:output = []
49+
50+
for l:match in ale#util#GetMatches(a:lines, l:pattern)
51+
call add(l:output, {
52+
\ 'bufnr': a:buffer,
53+
\ 'lnum': str2nr(l:match[1]),
54+
\ 'code': l:match[2],
55+
\ 'type': l:severity[l:match[3]],
56+
\ 'text': l:match[4],
57+
\})
58+
endfor
59+
60+
return l:output
61+
endfunction
62+
63+
call ale#linter#Define('python', {
64+
\ 'name': 'bandit',
65+
\ 'executable': function('ale_linters#python#bandit#GetExecutable'),
66+
\ 'command': function('ale_linters#python#bandit#GetCommand'),
67+
\ 'callback': 'ale_linters#python#bandit#Handle',
68+
\})
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
" Author: Kevin Locke <kevin@kevinlocke.name>
2+
" Description: pylama for python files
3+
4+
call ale#Set('python_pylama_executable', 'pylama')
5+
call ale#Set('python_pylama_options', '')
6+
call ale#Set('python_pylama_use_global', get(g:, 'ale_use_global_executables', 0))
7+
call ale#Set('python_pylama_auto_pipenv', 0)
8+
call ale#Set('python_pylama_change_directory', 1)
9+
10+
function! ale_linters#python#pylama#GetExecutable(buffer) abort
11+
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pylama_auto_pipenv'))
12+
\ && ale#python#PipenvPresent(a:buffer)
13+
return 'pipenv'
14+
endif
15+
16+
return ale#python#FindExecutable(a:buffer, 'python_pylama', ['pylama'])
17+
endfunction
18+
19+
function! ale_linters#python#pylama#GetCommand(buffer) abort
20+
let l:cd_string = ''
21+
22+
if ale#Var(a:buffer, 'python_pylama_change_directory')
23+
" Pylama loads its configuration from the current directory only, and
24+
" applies file masks using paths relative to the current directory.
25+
" Run from project root, if found, otherwise buffer dir.
26+
let l:project_root = ale#python#FindProjectRoot(a:buffer)
27+
let l:cd_string = l:project_root isnot# ''
28+
\ ? ale#path#CdString(l:project_root)
29+
\ : ale#path#BufferCdString(a:buffer)
30+
endif
31+
32+
let l:executable = ale_linters#python#pylama#GetExecutable(a:buffer)
33+
let l:exec_args = l:executable =~? 'pipenv$'
34+
\ ? ' run pylama'
35+
\ : ''
36+
37+
" Note: Using %t to lint changes would be preferable, but many pylama
38+
" checks use surrounding paths (e.g. C0103 module name, E0402 relative
39+
" import beyond top, etc.). Neither is ideal.
40+
return l:cd_string
41+
\ . ale#Escape(l:executable) . l:exec_args
42+
\ . ale#Pad(ale#Var(a:buffer, 'python_pylama_options'))
43+
\ . ' %s'
44+
endfunction
45+
46+
function! ale_linters#python#pylama#Handle(buffer, lines) abort
47+
if empty(a:lines)
48+
return []
49+
endif
50+
51+
let l:output = ale#python#HandleTraceback(a:lines, 1)
52+
let l:pattern = '\v^.{-}:([0-9]+):([0-9]+): +%(([A-Z][0-9]+):? +)?(.*)$'
53+
54+
" First letter of error code is a pylint-compatible message type
55+
" http://pylint.pycqa.org/en/latest/user_guide/output.html#source-code-analysis-section
56+
" D is for Documentation (pydocstyle)
57+
let l:pylint_type_to_ale_type = {
58+
\ 'I': 'I',
59+
\ 'R': 'W',
60+
\ 'C': 'W',
61+
\ 'W': 'W',
62+
\ 'E': 'E',
63+
\ 'F': 'E',
64+
\ 'D': 'W',
65+
\}
66+
let l:pylint_type_to_ale_sub_type = {
67+
\ 'R': 'style',
68+
\ 'C': 'style',
69+
\ 'D': 'style',
70+
\}
71+
72+
for l:match in ale#util#GetMatches(a:lines, l:pattern)
73+
call add(l:output, {
74+
\ 'lnum': str2nr(l:match[1]),
75+
\ 'col': str2nr(l:match[2]),
76+
\ 'code': l:match[3],
77+
\ 'type': get(l:pylint_type_to_ale_type, l:match[3][0], 'W'),
78+
\ 'sub_type': get(l:pylint_type_to_ale_sub_type, l:match[3][0], ''),
79+
\ 'text': l:match[4],
80+
\})
81+
endfor
82+
83+
return l:output
84+
endfunction
85+
86+
call ale#linter#Define('python', {
87+
\ 'name': 'pylama',
88+
\ 'executable': function('ale_linters#python#pylama#GetExecutable'),
89+
\ 'command': function('ale_linters#python#pylama#GetCommand'),
90+
\ 'callback': 'ale_linters#python#pylama#Handle',
91+
\ 'lint_file': 1,
92+
\})
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
" Author: aqui18 <https://github.com/aqui18>
2+
" Description: This file adds support for checking Racket code with raco.
3+
" This is the same form of syntax-checking used by DrRacket as well. The
4+
" downside is that it will only catch the first error, but none of the
5+
" subsequent ones. This is due to how evaluation in Racket works.
6+
7+
function! ale_linters#racket#raco#Handle(buffer, lines) abort
8+
" Matches patterns
9+
" <file>:<line>:<column> <message>
10+
" eg:
11+
" info.rkt:4:0: infotab-module: not a well-formed definition
12+
let l:pattern = '^\(\s\)\@!\(.\+\):\(\d\+\):\(\d\+\): \(.\+\)$'
13+
let l:output = []
14+
15+
for l:match in ale#util#GetMatches(a:lines, l:pattern)
16+
call add(l:output, {
17+
\ 'lnum': l:match[3] + 0,
18+
\ 'col': l:match[4] + 0,
19+
\ 'type': 'E',
20+
\ 'text': l:match[5],
21+
\})
22+
endfor
23+
24+
return l:output
25+
endfunction
26+
27+
call ale#linter#Define('racket', {
28+
\ 'name': 'raco',
29+
\ 'executable': 'raco',
30+
\ 'output_stream': 'stderr',
31+
\ 'command': 'raco expand %s',
32+
\ 'callback': 'ale_linters#racket#raco#Handle',
33+
\})
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
" Author: hokorobi <hokorobi.hokorobi@gmail.com>
2+
" Description: textlint, a proofreading tool (https://textlint.github.io/)
3+
4+
call ale#linter#Define('rst', {
5+
\ 'name': 'textlint',
6+
\ 'executable': function('ale#handlers#textlint#GetExecutable'),
7+
\ 'command': function('ale#handlers#textlint#GetCommand'),
8+
\ 'callback': 'ale#handlers#textlint#HandleTextlintOutput',
9+
\})
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
" Author: toastal <toastal@protonmail.com>
2+
" Description: `stylelint` linter for SugarSS files
3+
4+
call ale#Set('sugarss_stylelint_executable', 'stylelint')
5+
call ale#Set('sugarss_stylelint_options', '')
6+
call ale#Set('sugarss_stylelint_use_global', get(g:, 'ale_use_global_executables', 0))
7+
8+
function! ale_linters#sugarss#stylelint#GetCommand(buffer) abort
9+
return '%e ' . ale#Pad(ale#Var(a:buffer, 'sugarss_stylelint_options'))
10+
\ . ' --syntax=sugarss'
11+
\ . ' --stdin-filename %s'
12+
endfunction
13+
14+
call ale#linter#Define('sugarss', {
15+
\ 'name': 'stylelint',
16+
\ 'executable': {b -> ale#node#FindExecutable(b, 'sugarss_stylelint', [
17+
\ 'node_modules/.bin/stylelint',
18+
\ ])},
19+
\ 'command': function('ale_linters#sugarss#stylelint#GetCommand'),
20+
\ 'callback': 'ale#handlers#css#HandleStyleLintFormat',
21+
\})
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
" Author: TANIGUCHI Masaya <ta2gch@gmail.com>
2+
" Description: textlint for LaTeX files
3+
4+
call ale#linter#Define('tex', {
5+
\ 'name': 'textlint',
6+
\ 'executable': function('ale#handlers#textlint#GetExecutable'),
7+
\ 'command': function('ale#handlers#textlint#GetCommand'),
8+
\ 'callback': 'ale#handlers#textlint#HandleTextlintOutput',
9+
\})
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
" Author: John Gentile <johncgentile17@gmail.com>
2+
" Description: Adds support for Mentor Graphics Questa/ModelSim `vlog` Verilog compiler/checker
3+
4+
call ale#Set('verilog_vlog_executable', 'vlog')
5+
" See `$ vlog -h` for more options
6+
call ale#Set('verilog_vlog_options', '-quiet -lint')
7+
8+
function! ale_linters#verilog#vlog#GetCommand(buffer) abort
9+
return '%e ' . ale#Pad(ale#Var(a:buffer, 'verilog_vlog_options')) . ' %t'
10+
endfunction
11+
12+
function! ale_linters#verilog#vlog#Handle(buffer, lines) abort
13+
"Matches patterns like the following:
14+
"** Warning: add.v(7): (vlog-2623) Undefined variable: C.
15+
"** Error: file.v(1): (vlog-13294) Identifier must be declared with a port mode: C.
16+
let l:pattern = '^**\s\(\w*\):[a-zA-Z0-9\-\.\_\/ ]\+(\(\d\+\)):\s\+\(.*\)'
17+
let l:output = []
18+
19+
for l:match in ale#util#GetMatches(a:lines, l:pattern)
20+
call add(l:output, {
21+
\ 'lnum': l:match[2] + 0,
22+
\ 'type': l:match[1] is? 'Error' ? 'E' : 'W',
23+
\ 'text': l:match[3],
24+
\})
25+
endfor
26+
27+
return l:output
28+
endfunction
29+
30+
call ale#linter#Define('verilog', {
31+
\ 'name': 'vlog',
32+
\ 'output_stream': 'stdout',
33+
\ 'executable': {b -> ale#Var(b, 'verilog_vlog_executable')},
34+
\ 'command': function('ale_linters#verilog#vlog#GetCommand'),
35+
\ 'callback': 'ale_linters#verilog#vlog#Handle',
36+
\})

0 commit comments

Comments
 (0)