1
0
mirror of https://github.com/amix/vimrc synced 2025-06-16 01:25:00 +08:00

Added missing commits

This commit is contained in:
Amir Salihefendic
2019-03-11 17:39:30 -03:00
parent f50b2142bc
commit bf7b5985f1
28 changed files with 1928 additions and 0 deletions

View File

@ -0,0 +1,9 @@
" Author: TANIGUCHI Masaya <ta2gch@gmail.com>
" Description: textlint for AsciiDoc files
call ale#linter#Define('asciidoc', {
\ 'name': 'textlint',
\ 'executable': function('ale#handlers#textlint#GetExecutable'),
\ 'command': function('ale#handlers#textlint#GetCommand'),
\ 'callback': 'ale#handlers#textlint#HandleTextlintOutput',
\})

View File

@ -0,0 +1,57 @@
" Author: Harrison Bachrach - https://github.com/HarrisonB
" Description: Ameba, a linter for crystal files
call ale#Set('crystal_ameba_executable', 'bin/ameba')
function! ale_linters#crystal#ameba#GetCommand(buffer) abort
let l:executable = ale#Var(a:buffer, 'crystal_ameba_executable')
return ale#Escape(l:executable)
\ . ' --format json '
\ . ale#Escape(expand('#' . a:buffer . ':p'))
endfunction
" Handle output from ameba
function! ale_linters#crystal#ameba#HandleAmebaOutput(buffer, lines) abort
if len(a:lines) == 0
return []
endif
let l:errors = ale#util#FuzzyJSONDecode(a:lines[0], {})
if !has_key(l:errors, 'summary')
\|| l:errors['summary']['issues_count'] == 0
\|| empty(l:errors['sources'])
return []
endif
let l:output = []
for l:error in l:errors['sources'][0]['issues']
let l:start_col = str2nr(l:error['location']['column'])
let l:end_col = str2nr(l:error['end_location']['column'])
if !l:end_col
let l:end_col = l:start_col + 1
endif
call add(l:output, {
\ 'lnum': str2nr(l:error['location']['line']),
\ 'col': l:start_col,
\ 'end_col': l:end_col,
\ 'code': l:error['rule_name'],
\ 'text': l:error['message'],
\ 'type': 'W',
\})
endfor
return l:output
endfunction
call ale#linter#Define('crystal', {
\ 'name': 'ameba',
\ 'executable': {b -> ale#Var(b, 'crystal_ameba_executable')},
\ 'command': function('ale_linters#crystal#ameba#GetCommand'),
\ 'callback': 'ale_linters#crystal#ameba#HandleAmebaOutput',
\ 'lint_file': 1,
\})

View File

@ -0,0 +1,26 @@
" Author: Francisco Lopes <francisco@oblita.com>
" Description: Linting for Neo4j's Cypher
function! ale_linters#cypher#cypher_lint#Handle(buffer, lines) abort
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+): (.*)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'text': l:match[4],
\ 'type': 'E',
\})
endfor
return l:output
endfunction
call ale#linter#Define('cypher', {
\ 'name': 'cypher_lint',
\ 'executable': 'cypher-lint',
\ 'command': 'cypher-lint',
\ 'output_stream': 'stderr',
\ 'callback': 'ale_linters#cypher#cypher_lint#Handle',
\})

View File

@ -0,0 +1,68 @@
" Author: Martino Pilia <martino.pilia@gmail.com>
" Description: bandit linting for python files
call ale#Set('python_bandit_executable', 'bandit')
call ale#Set('python_bandit_options', '')
call ale#Set('python_bandit_use_config', 1)
call ale#Set('python_bandit_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_bandit_auto_pipenv', 0)
function! ale_linters#python#bandit#GetExecutable(buffer) abort
if (
\ ale#Var(a:buffer, 'python_auto_pipenv')
\ || ale#Var(a:buffer, 'python_bandit_auto_pipenv')
\) && ale#python#PipenvPresent(a:buffer)
return 'pipenv'
endif
return ale#python#FindExecutable(a:buffer, 'python_bandit', ['bandit'])
endfunction
function! ale_linters#python#bandit#GetCommand(buffer) abort
let l:executable = ale_linters#python#bandit#GetExecutable(a:buffer)
let l:flags = ' --format custom'
\ . ' --msg-template "{line}:{test_id}:{severity}:{msg}" '
if ale#Var(a:buffer, 'python_bandit_use_config')
let l:config_path = ale#path#FindNearestFile(a:buffer, '.bandit')
if !empty(l:config_path)
let l:flags = ' --ini ' . ale#Escape(l:config_path) . l:flags
endif
endif
let l:exec_args = l:executable =~? 'pipenv$'
\ ? ' run bandit'
\ : ''
return ale#Escape(l:executable) . l:exec_args
\ . l:flags
\ . ale#Pad(ale#Var(a:buffer, 'python_bandit_options'))
\ . ' -'
endfunction
function! ale_linters#python#bandit#Handle(buffer, lines) abort
" Custom format defined in GetCommand via --msg-template
let l:pattern = '\v^([0-9]+):(B[0-9]+):([A-Z]+):(.*)$'
let l:severity = {'LOW': 'I', 'MEDIUM': 'W', 'HIGH': 'E'}
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': str2nr(l:match[1]),
\ 'code': l:match[2],
\ 'type': l:severity[l:match[3]],
\ 'text': l:match[4],
\})
endfor
return l:output
endfunction
call ale#linter#Define('python', {
\ 'name': 'bandit',
\ 'executable': function('ale_linters#python#bandit#GetExecutable'),
\ 'command': function('ale_linters#python#bandit#GetCommand'),
\ 'callback': 'ale_linters#python#bandit#Handle',
\})

View File

@ -0,0 +1,92 @@
" Author: Kevin Locke <kevin@kevinlocke.name>
" Description: pylama for python files
call ale#Set('python_pylama_executable', 'pylama')
call ale#Set('python_pylama_options', '')
call ale#Set('python_pylama_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_pylama_auto_pipenv', 0)
call ale#Set('python_pylama_change_directory', 1)
function! ale_linters#python#pylama#GetExecutable(buffer) abort
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pylama_auto_pipenv'))
\ && ale#python#PipenvPresent(a:buffer)
return 'pipenv'
endif
return ale#python#FindExecutable(a:buffer, 'python_pylama', ['pylama'])
endfunction
function! ale_linters#python#pylama#GetCommand(buffer) abort
let l:cd_string = ''
if ale#Var(a:buffer, 'python_pylama_change_directory')
" Pylama loads its configuration from the current directory only, and
" applies file masks using paths relative to the current directory.
" Run from project root, if found, otherwise buffer dir.
let l:project_root = ale#python#FindProjectRoot(a:buffer)
let l:cd_string = l:project_root isnot# ''
\ ? ale#path#CdString(l:project_root)
\ : ale#path#BufferCdString(a:buffer)
endif
let l:executable = ale_linters#python#pylama#GetExecutable(a:buffer)
let l:exec_args = l:executable =~? 'pipenv$'
\ ? ' run pylama'
\ : ''
" 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 l:cd_string
\ . ale#Escape(l:executable) . l:exec_args
\ . ale#Pad(ale#Var(a:buffer, 'python_pylama_options'))
\ . ' %s'
endfunction
function! ale_linters#python#pylama#Handle(buffer, 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
" D is for Documentation (pydocstyle)
let l:pylint_type_to_ale_type = {
\ 'I': 'I',
\ 'R': 'W',
\ 'C': 'W',
\ 'W': 'W',
\ 'E': 'E',
\ 'F': 'E',
\ 'D': 'W',
\}
let l:pylint_type_to_ale_sub_type = {
\ 'R': 'style',
\ 'C': 'style',
\ '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
return l:output
endfunction
call ale#linter#Define('python', {
\ 'name': 'pylama',
\ 'executable': function('ale_linters#python#pylama#GetExecutable'),
\ 'command': function('ale_linters#python#pylama#GetCommand'),
\ 'callback': 'ale_linters#python#pylama#Handle',
\ 'lint_file': 1,
\})

View File

@ -0,0 +1,33 @@
" Author: aqui18 <https://github.com/aqui18>
" Description: This file adds support for checking Racket code with raco.
" This is the same form of syntax-checking used by DrRacket as well. The
" downside is that it will only catch the first error, but none of the
" subsequent ones. This is due to how evaluation in Racket works.
function! ale_linters#racket#raco#Handle(buffer, lines) abort
" Matches patterns
" <file>:<line>:<column> <message>
" eg:
" info.rkt:4:0: infotab-module: not a well-formed definition
let l:pattern = '^\(\s\)\@!\(.\+\):\(\d\+\):\(\d\+\): \(.\+\)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[3] + 0,
\ 'col': l:match[4] + 0,
\ 'type': 'E',
\ 'text': l:match[5],
\})
endfor
return l:output
endfunction
call ale#linter#Define('racket', {
\ 'name': 'raco',
\ 'executable': 'raco',
\ 'output_stream': 'stderr',
\ 'command': 'raco expand %s',
\ 'callback': 'ale_linters#racket#raco#Handle',
\})

View File

@ -0,0 +1,9 @@
" Author: hokorobi <hokorobi.hokorobi@gmail.com>
" Description: textlint, a proofreading tool (https://textlint.github.io/)
call ale#linter#Define('rst', {
\ 'name': 'textlint',
\ 'executable': function('ale#handlers#textlint#GetExecutable'),
\ 'command': function('ale#handlers#textlint#GetCommand'),
\ 'callback': 'ale#handlers#textlint#HandleTextlintOutput',
\})

View File

@ -0,0 +1,21 @@
" Author: toastal <toastal@protonmail.com>
" Description: `stylelint` linter for SugarSS files
call ale#Set('sugarss_stylelint_executable', 'stylelint')
call ale#Set('sugarss_stylelint_options', '')
call ale#Set('sugarss_stylelint_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#sugarss#stylelint#GetCommand(buffer) abort
return '%e ' . ale#Pad(ale#Var(a:buffer, 'sugarss_stylelint_options'))
\ . ' --syntax=sugarss'
\ . ' --stdin-filename %s'
endfunction
call ale#linter#Define('sugarss', {
\ 'name': 'stylelint',
\ 'executable': {b -> ale#node#FindExecutable(b, 'sugarss_stylelint', [
\ 'node_modules/.bin/stylelint',
\ ])},
\ 'command': function('ale_linters#sugarss#stylelint#GetCommand'),
\ 'callback': 'ale#handlers#css#HandleStyleLintFormat',
\})

View File

@ -0,0 +1,9 @@
" Author: TANIGUCHI Masaya <ta2gch@gmail.com>
" Description: textlint for LaTeX files
call ale#linter#Define('tex', {
\ 'name': 'textlint',
\ 'executable': function('ale#handlers#textlint#GetExecutable'),
\ 'command': function('ale#handlers#textlint#GetCommand'),
\ 'callback': 'ale#handlers#textlint#HandleTextlintOutput',
\})

View File

@ -0,0 +1,36 @@
" Author: John Gentile <johncgentile17@gmail.com>
" Description: Adds support for Mentor Graphics Questa/ModelSim `vlog` Verilog compiler/checker
call ale#Set('verilog_vlog_executable', 'vlog')
" See `$ vlog -h` for more options
call ale#Set('verilog_vlog_options', '-quiet -lint')
function! ale_linters#verilog#vlog#GetCommand(buffer) abort
return '%e ' . ale#Pad(ale#Var(a:buffer, 'verilog_vlog_options')) . ' %t'
endfunction
function! ale_linters#verilog#vlog#Handle(buffer, lines) abort
"Matches patterns like the following:
"** Warning: add.v(7): (vlog-2623) Undefined variable: C.
"** Error: file.v(1): (vlog-13294) Identifier must be declared with a port mode: C.
let l:pattern = '^**\s\(\w*\):[a-zA-Z0-9\-\.\_\/ ]\+(\(\d\+\)):\s\+\(.*\)'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[2] + 0,
\ 'type': l:match[1] is? 'Error' ? 'E' : 'W',
\ 'text': l:match[3],
\})
endfor
return l:output
endfunction
call ale#linter#Define('verilog', {
\ 'name': 'vlog',
\ 'output_stream': 'stdout',
\ 'executable': {b -> ale#Var(b, 'verilog_vlog_executable')},
\ 'command': function('ale_linters#verilog#vlog#GetCommand'),
\ 'callback': 'ale_linters#verilog#vlog#Handle',
\})

View File

@ -0,0 +1,35 @@
" Author: John Gentile <johncgentile17@gmail.com>
" Description: Adds support for Xilinx Vivado `xvlog` Verilog compiler/checker
call ale#Set('verilog_xvlog_executable', 'xvlog')
call ale#Set('verilog_xvlog_options', '')
function! ale_linters#verilog#xvlog#GetCommand(buffer) abort
return '%e ' . ale#Pad(ale#Var(a:buffer, 'verilog_xvlog_options')) . ' %t'
endfunction
function! ale_linters#verilog#xvlog#Handle(buffer, lines) abort
"Matches patterns like the following:
" ERROR: [VRFC 10-1412] syntax error near output [/path/to/file.v:5]
let l:pattern = '^ERROR:\s\+\(\[.*\)\[.*:\([0-9]\+\)\]'
let l:output = []
" NOTE: `xvlog` only prints 'INFO' and 'ERROR' messages
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[2] + 0,
\ 'type': 'E',
\ 'text': l:match[1],
\})
endfor
return l:output
endfunction
call ale#linter#Define('verilog', {
\ 'name': 'xvlog',
\ 'output_stream': 'stdout',
\ 'executable': {b -> ale#Var(b, 'verilog_xvlog_executable')},
\ 'command': function('ale_linters#verilog#xvlog#GetCommand'),
\ 'callback': 'ale_linters#verilog#xvlog#Handle',
\})

View File

@ -0,0 +1,37 @@
" Author: John Gentile <johncgentile17@gmail.com>
" Description: Adds support for `ghdl` VHDL compiler/checker
call ale#Set('vhdl_ghdl_executable', 'ghdl')
" Compile w/VHDL-2008 support
call ale#Set('vhdl_ghdl_options', '--std=08')
function! ale_linters#vhdl#ghdl#GetCommand(buffer) abort
return '%e -s ' . ale#Pad(ale#Var(a:buffer, 'vhdl_ghdl_options')) . ' %t'
endfunction
function! ale_linters#vhdl#ghdl#Handle(buffer, lines) abort
" Look for 'error' lines like the following:
" dff_en.vhd:41:5:error: 'begin' is expected instead of 'if'
" /path/to/file.vhdl:12:8: no declaration for "i0"
let l:pattern = '^[a-zA-Z0-9\-\.\_\/ ]\+:\(\d\+\):\(\d\+\):\(.*\)'
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,
\ 'text': l:match[3],
\ 'type': 'E',
\})
endfor
return l:output
endfunction
call ale#linter#Define('vhdl', {
\ 'name': 'ghdl',
\ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'vhdl_ghdl_executable')},
\ 'command': function('ale_linters#vhdl#ghdl#GetCommand'),
\ 'callback': 'ale_linters#vhdl#ghdl#Handle',
\})

View File

@ -0,0 +1,38 @@
" Author: John Gentile <johncgentile17@gmail.com>
" Description: Adds support for Mentor Graphics Questa/ModelSim `vcom` VHDL compiler/checker
call ale#Set('vhdl_vcom_executable', 'vcom')
" Use VHDL-2008. See `$ vcom -h` for more options
call ale#Set('vhdl_vcom_options', '-2008 -quiet -lint')
function! ale_linters#vhdl#vcom#GetCommand(buffer) abort
return '%e ' . ale#Pad(ale#Var(a:buffer, 'vhdl_vcom_options')) . ' %t'
endfunction
function! ale_linters#vhdl#vcom#Handle(buffer, lines) abort
"Matches patterns like the following:
"** Warning: ../path/to/file.vhd(218): (vcom-1236) Shared variables must be of a protected type.
"** Error: tb_file.vhd(73): (vcom-1136) Unknown identifier "aresetn".
"** Error: tb_file.vhd(73): Bad resolution function (STD_LOGIC) for type (error).
"** Error: tb_file.vhd(73): near ":": (vcom-1576) expecting ';' or ')'.
let l:pattern = '^**\s\(\w*\):[a-zA-Z0-9\-\.\_\/ ]\+(\(\d\+\)):\s\+\(.*\)'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[2] + 0,
\ 'type': l:match[1] is? 'Error' ? 'E' : 'W',
\ 'text': l:match[3],
\})
endfor
return l:output
endfunction
call ale#linter#Define('vhdl', {
\ 'name': 'vcom',
\ 'output_stream': 'stdout',
\ 'executable': {b -> ale#Var(b, 'vhdl_vcom_executable')},
\ 'command': function('ale_linters#vhdl#vcom#GetCommand'),
\ 'callback': 'ale_linters#vhdl#vcom#Handle',
\})

View File

@ -0,0 +1,37 @@
" Author: John Gentile <johncgentile17@gmail.com>
" Description: Adds support for Xilinx Vivado `xvhdl` VHDL compiler/checker
call ale#Set('vhdl_xvhdl_executable', 'xvhdl')
" Use VHDL-2008. See `$ xvhdl -h` for more options
call ale#Set('vhdl_xvhdl_options', '--2008')
function! ale_linters#vhdl#xvhdl#GetCommand(buffer) abort
return '%e ' . ale#Pad(ale#Var(a:buffer, 'vhdl_xvhdl_options')) . ' %t'
endfunction
function! ale_linters#vhdl#xvhdl#Handle(buffer, lines) abort
"Matches patterns like the following:
" ERROR: [VRFC 10-91] aresetn is not declared [/path/to/file.vhd:17]
" ERROR: [VRFC 10-91] m_axis_tx_tdata is not declared [/home/user/tx_data.vhd:128]
let l:pattern = '^ERROR:\s\+\(\[.*\)\[.*:\([0-9]\+\)\]'
let l:output = []
" NOTE: `xvhdl` only prints 'INFO' and 'ERROR' messages
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[2] + 0,
\ 'type': 'E',
\ 'text': l:match[1],
\})
endfor
return l:output
endfunction
call ale#linter#Define('vhdl', {
\ 'name': 'xvhdl',
\ 'output_stream': 'stdout',
\ 'executable': {b -> ale#Var(b, 'vhdl_xvhdl_executable')},
\ 'command': function('ale_linters#vhdl#xvhdl#GetCommand'),
\ 'callback': 'ale_linters#vhdl#xvhdl#Handle',
\})