mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated plugins
This commit is contained in:
32
sources_non_forked/ale/ale_linters/php/intelephense.vim
Normal file
32
sources_non_forked/ale/ale_linters/php/intelephense.vim
Normal file
@ -0,0 +1,32 @@
|
||||
" Author: Eric Stern <eric@ericstern.com>,
|
||||
" Arnold Chand <creativenull@outlook.com>
|
||||
" Description: Intelephense language server integration for ALE
|
||||
|
||||
call ale#Set('php_intelephense_executable', 'intelephense')
|
||||
call ale#Set('php_intelephense_use_global', 1)
|
||||
call ale#Set('php_intelephense_config', {})
|
||||
|
||||
function! ale_linters#php#intelephense#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
|
||||
|
||||
function! ale_linters#php#intelephense#GetInitializationOptions() abort
|
||||
return ale#Get('php_intelephense_config')
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('php', {
|
||||
\ 'name': 'intelephense',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'initialization_options': function('ale_linters#php#intelephense#GetInitializationOptions'),
|
||||
\ 'executable': {b -> ale#node#FindExecutable(b, 'php_intelephense', [])},
|
||||
\ 'command': '%e --stdio',
|
||||
\ 'project_root': function('ale_linters#php#intelephense#GetProjectRoot'),
|
||||
\})
|
@ -23,7 +23,7 @@ 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:pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\) - \(.\+\) (\(.\+\)).*$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
|
@ -1,9 +1,9 @@
|
||||
" Author: Matt Brown <https://github.com/muglug>
|
||||
" Description: plugin for Psalm, static analyzer for PHP
|
||||
|
||||
call ale#Set('psalm_langserver_executable', 'psalm')
|
||||
call ale#Set('psalm_langserver_options', '')
|
||||
call ale#Set('psalm_langserver_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('php_psalm_executable', 'psalm')
|
||||
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:git_path = ale#path#FindNearestDirectory(a:buffer, '.git')
|
||||
@ -12,13 +12,13 @@ function! ale_linters#php#psalm#GetProjectRoot(buffer) abort
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#psalm#GetCommand(buffer) abort
|
||||
return '%e --language-server' . ale#Pad(ale#Var(a:buffer, 'psalm_langserver_options'))
|
||||
return '%e --language-server' . ale#Pad(ale#Var(a:buffer, 'php_psalm_options'))
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('php', {
|
||||
\ 'name': 'psalm',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': {b -> ale#node#FindExecutable(b, 'psalm_langserver', [
|
||||
\ 'executable': {b -> ale#node#FindExecutable(b, 'php_psalm', [
|
||||
\ 'vendor/bin/psalm',
|
||||
\ ])},
|
||||
\ 'command': function('ale_linters#php#psalm#GetCommand'),
|
||||
|
80
sources_non_forked/ale/ale_linters/php/tlint.vim
Normal file
80
sources_non_forked/ale/ale_linters/php/tlint.vim
Normal file
@ -0,0 +1,80 @@
|
||||
" Author: Jose Soto <jose@tighten.co>
|
||||
"
|
||||
" Description: Tighten Opinionated PHP Linting
|
||||
" Website: https://github.com/tightenco/tlint
|
||||
|
||||
call ale#Set('php_tlint_executable', 'tlint')
|
||||
call ale#Set('php_tlint_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('php_tlint_options', '')
|
||||
|
||||
function! ale_linters#php#tlint#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
|
||||
|
||||
function! ale_linters#php#tlint#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'php_tlint', [
|
||||
\ 'vendor/bin/tlint',
|
||||
\ 'tlint',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#tlint#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#php#tlint#GetExecutable(a:buffer)
|
||||
let l:options = ale#Var(a:buffer, 'php_tlint_options')
|
||||
|
||||
return ale#node#Executable(a:buffer, l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' lint %s'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#tlint#Handle(buffer, lines) abort
|
||||
" Matches against lines like the following:
|
||||
"
|
||||
" ! There should be 1 space around `.` concatenations, and additional lines should always start with a `.`
|
||||
" 22 : ` $something = 'a'.'name';`
|
||||
"
|
||||
let l:loop_count = 0
|
||||
let l:messages_pattern = '^\! \(.*\)'
|
||||
let l:output = []
|
||||
let l:pattern = '^\(\d\+\) \:'
|
||||
let l:temp_messages = []
|
||||
|
||||
for l:message in ale#util#GetMatches(a:lines, l:messages_pattern)
|
||||
call add(l:temp_messages, l:message)
|
||||
endfor
|
||||
|
||||
let l:loop_count = 0
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:num = l:match[1]
|
||||
let l:text = l:temp_messages[l:loop_count]
|
||||
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:num,
|
||||
\ 'col': 0,
|
||||
\ 'text': l:text,
|
||||
\ 'type': 'W',
|
||||
\ 'sub_type': 'style',
|
||||
\})
|
||||
|
||||
let l:loop_count += 1
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('php', {
|
||||
\ 'name': 'tlint',
|
||||
\ 'executable': function('ale_linters#php#tlint#GetExecutable'),
|
||||
\ 'command': function('ale_linters#php#tlint#GetCommand'),
|
||||
\ 'callback': 'ale_linters#php#tlint#Handle',
|
||||
\ 'project_root': function('ale_linters#php#tlint#GetProjectRoot'),
|
||||
\})
|
Reference in New Issue
Block a user