mirror of
https://github.com/amix/vimrc
synced 2025-06-16 09:35:01 +08:00
Updated plugins
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
" 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)
|
||||
call ale#Set('php_langserver_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
|
||||
function! ale_linters#php#langserver#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'php_langserver', [
|
||||
@ -14,10 +14,6 @@ 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')
|
||||
|
||||
@ -29,6 +25,6 @@ call ale#linter#Define('php', {
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable_callback': 'ale_linters#php#langserver#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#php#langserver#GetCommand',
|
||||
\ 'language_callback': 'ale_linters#php#langserver#GetLanguage',
|
||||
\ 'language': 'php',
|
||||
\ 'project_root_callback': 'ale_linters#php#langserver#GetProjectRoot',
|
||||
\})
|
||||
|
@ -1,28 +1,65 @@
|
||||
" Author: diegoholiveira <https://github.com/diegoholiveira>
|
||||
" Author: diegoholiveira <https://github.com/diegoholiveira>, haginaga <https://github.com/haginaga>
|
||||
" Description: static analyzer for PHP
|
||||
|
||||
" Define the minimum severity
|
||||
let g:ale_php_phan_minimum_severity = get(g:, 'ale_php_phan_minimum_severity', 0)
|
||||
|
||||
let g:ale_php_phan_executable = get(g:, 'ale_php_phan_executable', 'phan')
|
||||
let g:ale_php_phan_use_client = get(g:, 'ale_php_phan_use_client', 0)
|
||||
|
||||
function! ale_linters#php#phan#GetExecutable(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'php_phan_executable')
|
||||
|
||||
if ale#Var(a:buffer, 'php_phan_use_client') == 1 && l:executable is# 'phan'
|
||||
let l:executable = 'phan_client'
|
||||
endif
|
||||
|
||||
return l:executable
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#phan#GetCommand(buffer) abort
|
||||
return 'phan -y '
|
||||
\ . ale#Var(a:buffer, 'php_phan_minimum_severity')
|
||||
\ . ' %s'
|
||||
if ale#Var(a:buffer, 'php_phan_use_client') == 1
|
||||
let l:args = '-l '
|
||||
\ . ' %s'
|
||||
else
|
||||
let l:args = '-y '
|
||||
\ . ale#Var(a:buffer, 'php_phan_minimum_severity')
|
||||
\ . ' %s'
|
||||
endif
|
||||
|
||||
let l:executable = ale_linters#php#phan#GetExecutable(a:buffer)
|
||||
|
||||
return ale#Escape(l:executable) . ' ' . l:args
|
||||
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\(.\+\)$'
|
||||
if ale#Var(a:buffer, 'php_phan_use_client') == 1
|
||||
" Phan error: ERRORTYPE: message in /path/to/some-filename.php on line nnn
|
||||
let l:pattern = '^Phan error: \(\w\+\): \(.\+\) in \(.\+\) on line \(\d\+\)$'
|
||||
else
|
||||
" /path/to/some-filename.php:18 ERRORTYPE message
|
||||
let l:pattern = '^.*:\(\d\+\)\s\(\w\+\)\s\(.\+\)$'
|
||||
endif
|
||||
|
||||
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',
|
||||
\})
|
||||
if ale#Var(a:buffer, 'php_phan_use_client') == 1
|
||||
let l:dict = {
|
||||
\ 'lnum': l:match[4] + 0,
|
||||
\ 'text': l:match[2],
|
||||
\ 'type': 'W',
|
||||
\}
|
||||
else
|
||||
let l:dict = {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'text': l:match[3],
|
||||
\ 'type': 'W',
|
||||
\}
|
||||
endif
|
||||
|
||||
call add(l:output, l:dict)
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
@ -30,7 +67,7 @@ endfunction
|
||||
|
||||
call ale#linter#Define('php', {
|
||||
\ 'name': 'phan',
|
||||
\ 'executable': 'phan',
|
||||
\ 'executable_callback': 'ale_linters#php#phan#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#php#phan#GetCommand',
|
||||
\ 'callback': 'ale_linters#php#phan#Handle',
|
||||
\})
|
||||
|
@ -4,7 +4,7 @@
|
||||
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)
|
||||
call ale#Set('php_phpcs_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
|
||||
function! ale_linters#php#phpcs#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'php_phpcs', [
|
||||
|
Reference in New Issue
Block a user