mirror of
https://github.com/amix/vimrc
synced 2025-06-16 09:35:01 +08:00
Removed syntastic and replaced it with ale
Read more here: https://github.com/w0rp/ale
This commit is contained in:
28
sources_non_forked/ale/ale_linters/php/hack.vim
Normal file
28
sources_non_forked/ale/ale_linters/php/hack.vim
Normal file
@ -0,0 +1,28 @@
|
||||
" Author: Zefei Xuan <https://github.com/zefei>
|
||||
" Description: Hack type checking (http://hacklang.org/)
|
||||
|
||||
function! ale_linters#php#hack#Handle(buffer, lines) abort
|
||||
let l:pattern = '^\(.*\):\(\d\+\):\(\d\+\),\(\d\+\): \(.\+])\)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
if a:buffer != bufnr(l:match[1])
|
||||
continue
|
||||
endif
|
||||
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'col': l:match[3] + 0,
|
||||
\ 'text': l:match[5],
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('php', {
|
||||
\ 'name': 'hack',
|
||||
\ 'executable': 'hh_client',
|
||||
\ 'command': 'hh_client --retries 0 --retry-if-init false',
|
||||
\ 'callback': 'ale_linters#php#hack#Handle',
|
||||
\})
|
34
sources_non_forked/ale/ale_linters/php/langserver.vim
Normal file
34
sources_non_forked/ale/ale_linters/php/langserver.vim
Normal file
@ -0,0 +1,34 @@
|
||||
" Author: Eric Stern <eric@ericstern.com>
|
||||
" Description: PHP Language server integration for ALE
|
||||
|
||||
call ale#Set('php_langserver_executable', 'php-language-server.php')
|
||||
call ale#Set('php_langserver_use_global', 0)
|
||||
|
||||
function! ale_linters#php#langserver#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'php_langserver', [
|
||||
\ 'vendor/bin/php-language-server.php',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#langserver#GetCommand(buffer) abort
|
||||
return 'php ' . ale#Escape(ale_linters#php#langserver#GetExecutable(a:buffer))
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#langserver#GetLanguage(buffer) abort
|
||||
return 'php'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#langserver#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('php', {
|
||||
\ 'name': 'langserver',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable_callback': 'ale_linters#php#langserver#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#php#langserver#GetCommand',
|
||||
\ 'language_callback': 'ale_linters#php#langserver#GetLanguage',
|
||||
\ 'project_root_callback': 'ale_linters#php#langserver#GetProjectRoot',
|
||||
\})
|
36
sources_non_forked/ale/ale_linters/php/phan.vim
Normal file
36
sources_non_forked/ale/ale_linters/php/phan.vim
Normal file
@ -0,0 +1,36 @@
|
||||
" Author: diegoholiveira <https://github.com/diegoholiveira>
|
||||
" Description: static analyzer for PHP
|
||||
|
||||
" Define the minimum severity
|
||||
let g:ale_php_phan_minimum_severity = get(g:, 'ale_php_phan_minimum_severity', 0)
|
||||
|
||||
function! ale_linters#php#phan#GetCommand(buffer) abort
|
||||
return 'phan -y '
|
||||
\ . ale#Var(a:buffer, 'php_phan_minimum_severity')
|
||||
\ . ' %s'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#phan#Handle(buffer, lines) abort
|
||||
" Matches against lines like the following:
|
||||
"
|
||||
" /path/to/some-filename.php:18 ERRORTYPE message
|
||||
let l:pattern = '^.*:\(\d\+\)\s\(\w\+\)\s\(.\+\)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'text': l:match[3],
|
||||
\ 'type': 'W',
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('php', {
|
||||
\ 'name': 'phan',
|
||||
\ 'executable': 'phan',
|
||||
\ 'command_callback': 'ale_linters#php#phan#GetCommand',
|
||||
\ 'callback': 'ale_linters#php#phan#Handle',
|
||||
\})
|
37
sources_non_forked/ale/ale_linters/php/php.vim
Normal file
37
sources_non_forked/ale/ale_linters/php/php.vim
Normal file
@ -0,0 +1,37 @@
|
||||
" Author: Spencer Wood <https://github.com/scwood>, Adriaan Zonnenberg <amz@adriaan.xyz>
|
||||
" Description: This file adds support for checking PHP with php-cli
|
||||
|
||||
function! ale_linters#php#php#Handle(buffer, lines) abort
|
||||
" Matches patterns like the following:
|
||||
"
|
||||
" PHP 7.1<= - Parse error: syntax error, unexpected ';', expecting ']' in - on line 15
|
||||
" PHP 7.2>= - Parse error: syntax error, unexpected ';', expecting ']' in Standard input code on line 15
|
||||
let l:pattern = '\v^%(Fatal|Parse) error:\s+(.+unexpected ''(.+)%(expecting.+)@<!''.*|.+) in %(-|Standard input code) on line (\d+)'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:col = empty(l:match[2]) ? 0 : stridx(getline(l:match[3]), l:match[2]) + 1
|
||||
|
||||
let l:obj = {
|
||||
\ 'lnum': l:match[3] + 0,
|
||||
\ 'col': l:col,
|
||||
\ 'text': l:match[1],
|
||||
\}
|
||||
|
||||
if l:col != 0
|
||||
let l:obj.end_col = l:col + strlen(l:match[2]) - 1
|
||||
endif
|
||||
|
||||
call add(l:output, l:obj)
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('php', {
|
||||
\ 'name': 'php',
|
||||
\ 'executable': 'php',
|
||||
\ 'output_stream': 'stdout',
|
||||
\ 'command': 'php -l -d error_reporting=E_ALL -d display_errors=1 -d log_errors=0 --',
|
||||
\ 'callback': 'ale_linters#php#php#Handle',
|
||||
\})
|
56
sources_non_forked/ale/ale_linters/php/phpcs.vim
Normal file
56
sources_non_forked/ale/ale_linters/php/phpcs.vim
Normal file
@ -0,0 +1,56 @@
|
||||
" Author: jwilliams108 <https://github.com/jwilliams108>, Eric Stern <https://github.com/firehed>
|
||||
" Description: phpcs for PHP files
|
||||
|
||||
let g:ale_php_phpcs_standard = get(g:, 'ale_php_phpcs_standard', '')
|
||||
|
||||
call ale#Set('php_phpcs_executable', 'phpcs')
|
||||
call ale#Set('php_phpcs_use_global', 0)
|
||||
|
||||
function! ale_linters#php#phpcs#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'php_phpcs', [
|
||||
\ 'vendor/bin/phpcs',
|
||||
\ 'phpcs'
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#phpcs#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#php#phpcs#GetExecutable(a:buffer)
|
||||
|
||||
let l:standard = ale#Var(a:buffer, 'php_phpcs_standard')
|
||||
let l:standard_option = !empty(l:standard)
|
||||
\ ? '--standard=' . l:standard
|
||||
\ : ''
|
||||
|
||||
return ale#Escape(l:executable)
|
||||
\ . ' -s --report=emacs --stdin-path=%s ' . l:standard_option
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#phpcs#Handle(buffer, lines) abort
|
||||
" Matches against lines like the following:
|
||||
"
|
||||
" /path/to/some-filename.php:18:3: error - Line indented incorrectly; expected 4 spaces, found 2 (Generic.WhiteSpace.ScopeIndent.IncorrectExact)
|
||||
let l:pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\) - \(.\+\) (\(.\+\))$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:code = l:match[5]
|
||||
let l:text = l:match[4] . ' (' . l:code . ')'
|
||||
let l:type = l:match[3]
|
||||
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'col': l:match[2] + 0,
|
||||
\ 'text': l:text,
|
||||
\ 'type': l:type is# 'error' ? 'E' : 'W',
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('php', {
|
||||
\ 'name': 'phpcs',
|
||||
\ 'executable_callback': 'ale_linters#php#phpcs#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#php#phpcs#GetCommand',
|
||||
\ 'callback': 'ale_linters#php#phpcs#Handle',
|
||||
\})
|
45
sources_non_forked/ale/ale_linters/php/phpmd.vim
Normal file
45
sources_non_forked/ale/ale_linters/php/phpmd.vim
Normal file
@ -0,0 +1,45 @@
|
||||
" Author: medains <https://github.com/medains>, David Sierra <https://github.com/davidsierradz>
|
||||
" Description: phpmd for PHP files
|
||||
|
||||
let g:ale_php_phpmd_executable = get(g:, 'ale_php_phpmd_executable', 'phpmd')
|
||||
|
||||
" Set to change the ruleset
|
||||
let g:ale_php_phpmd_ruleset = get(g:, 'ale_php_phpmd_ruleset', 'cleancode,codesize,controversial,design,naming,unusedcode')
|
||||
|
||||
function! ale_linters#php#phpmd#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'php_phpmd_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#phpmd#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#php#phpmd#GetExecutable(a:buffer)
|
||||
|
||||
return ale#Escape(l:executable)
|
||||
\ . ' %s text '
|
||||
\ . ale#Var(a:buffer, 'php_phpmd_ruleset')
|
||||
\ . ' --ignore-violations-on-exit %t'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#phpmd#Handle(buffer, lines) abort
|
||||
" Matches against lines like the following:
|
||||
"
|
||||
" /path/to/some-filename.php:18 message
|
||||
let l:pattern = '^.*:\(\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,
|
||||
\ 'text': l:match[2],
|
||||
\ 'type': 'W',
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('php', {
|
||||
\ 'name': 'phpmd',
|
||||
\ 'executable_callback': 'ale_linters#php#phpmd#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#php#phpmd#GetCommand',
|
||||
\ 'callback': 'ale_linters#php#phpmd#Handle',
|
||||
\})
|
53
sources_non_forked/ale/ale_linters/php/phpstan.vim
Normal file
53
sources_non_forked/ale/ale_linters/php/phpstan.vim
Normal file
@ -0,0 +1,53 @@
|
||||
" Author: medains <https://github.com/medains>, ardis <https://github.com/ardisdreelath>
|
||||
" Description: phpstan for PHP files
|
||||
|
||||
" Set to change the ruleset
|
||||
let g:ale_php_phpstan_executable = get(g:, 'ale_php_phpstan_executable', 'phpstan')
|
||||
let g:ale_php_phpstan_level = get(g:, 'ale_php_phpstan_level', '4')
|
||||
let g:ale_php_phpstan_configuration = get(g:, 'ale_php_phpstan_configuration', '')
|
||||
|
||||
function! ale_linters#php#phpstan#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'php_phpstan_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#phpstan#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#php#phpstan#GetExecutable(a:buffer)
|
||||
|
||||
let l:configuration = ale#Var(a:buffer, 'php_phpstan_configuration')
|
||||
let l:configuration_option = !empty(l:configuration)
|
||||
\ ? ' -c ' . l:configuration
|
||||
\ : ''
|
||||
|
||||
return ale#Escape(l:executable)
|
||||
\ . ' analyze -l'
|
||||
\ . ale#Var(a:buffer, 'php_phpstan_level')
|
||||
\ . ' --errorFormat raw'
|
||||
\ . l:configuration_option
|
||||
\ . ' %s'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#phpstan#Handle(buffer, lines) abort
|
||||
" Matches against lines like the following:
|
||||
"
|
||||
" filename.php:15:message
|
||||
" C:\folder\filename.php:15:message
|
||||
let l:pattern = '^\([a-zA-Z]:\)\?[^:]\+:\(\d\+\):\(.*\)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'text': l:match[3],
|
||||
\ 'type': 'W',
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('php', {
|
||||
\ 'name': 'phpstan',
|
||||
\ 'executable_callback': 'ale_linters#php#phpstan#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#php#phpstan#GetCommand',
|
||||
\ 'callback': 'ale_linters#php#phpstan#Handle',
|
||||
\})
|
Reference in New Issue
Block a user