mirror of
https://github.com/dense-analysis/ale.git
synced 2026-03-01 12:56:57 +08:00
Suggested changes
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
" Author: Fred Emmott <fe@fb.com>
|
" Author: Fred Emmott <fe@fb.com>
|
||||||
" Description: Hack support via `hack lsp`
|
" Description: Hack support via `hack lsp`
|
||||||
|
|
||||||
call ale#Set('hack_hhclient_executable', 'hh_client')
|
call ale#Set('hack_hack_executable', 'hh_client')
|
||||||
|
|
||||||
function! ale_linters#hack#hack#GetProjectRoot(buffer) abort
|
function! ale_linters#hack#hack#GetProjectRoot(buffer) abort
|
||||||
let l:hhconfig = ale#path#FindNearestFile(a:buffer, '.hhconfig')
|
let l:hhconfig = ale#path#FindNearestFile(a:buffer, '.hhconfig')
|
||||||
@@ -10,20 +10,13 @@ function! ale_linters#hack#hack#GetProjectRoot(buffer) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#hack#hack#GetExecutable(buffer) abort
|
function! ale_linters#hack#hack#GetExecutable(buffer) abort
|
||||||
return ale#Var(a:buffer, 'hack_hhclient_executable')
|
return ale#Var(a:buffer, 'hack_hack_executable')
|
||||||
endfunction
|
|
||||||
|
|
||||||
|
|
||||||
function! ale_linters#hack#hack#GetCommand(buffer) abort
|
|
||||||
let l:executable = ale_linters#hack#hack#GetExecutable(a:buffer)
|
|
||||||
|
|
||||||
return ale#Escape(l:executable).' lsp --from vim-ale'
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('hack', {
|
call ale#linter#Define('hack', {
|
||||||
\ 'name': 'hack',
|
\ 'name': 'hack',
|
||||||
\ 'lsp': 'stdio',
|
\ 'lsp': 'stdio',
|
||||||
\ 'executable_callback': 'ale_linters#hack#hack#GetExecutable',
|
\ 'executable_callback': 'ale_linters#hack#hack#GetExecutable',
|
||||||
\ 'command_callback': 'ale_linters#hack#hack#GetCommand',
|
\ 'command': '%e lsp --from vim-ale',
|
||||||
\ 'project_root_callback': 'ale_linters#hack#hack#GetProjectRoot',
|
\ 'project_root_callback': 'ale_linters#hack#hack#GetProjectRoot',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -4,12 +4,15 @@
|
|||||||
call ale#Set('hack_hhast_executable', 'vendor/bin/hhast-lint')
|
call ale#Set('hack_hhast_executable', 'vendor/bin/hhast-lint')
|
||||||
|
|
||||||
function! ale_linters#hack#hhast#GetProjectRoot(buffer) abort
|
function! ale_linters#hack#hhast#GetProjectRoot(buffer) abort
|
||||||
let l:root = ale_linters#hack#hack#GetProjectRoot(a:buffer)
|
" Find the hack root, then figure out if it's also an HHAST root.
|
||||||
|
" Don't try to use lint configurations from vendor/foo/bar/hhast-lint.json
|
||||||
|
let l:hhconfig = ale#path#FindNearestFile(a:buffer, '.hhconfig')
|
||||||
|
|
||||||
if empty(l:root)
|
if empty(l:hhconfig)
|
||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let l:root = fnamemodify(l:hhconfig, ':h')
|
||||||
let l:hhast_config = findfile('hhast-lint.json', l:root)
|
let l:hhast_config = findfile('hhast-lint.json', l:root)
|
||||||
|
|
||||||
return !empty(l:hhast_config) ? l:root : ''
|
return !empty(l:hhast_config) ? l:root : ''
|
||||||
@@ -23,19 +26,10 @@ function! ale_linters#hack#hhast#GetExecutable(buffer) abort
|
|||||||
return !empty(l:absolute) ? l:absolute : ''
|
return !empty(l:absolute) ? l:absolute : ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! ale_linters#hack#hhast#GetCommand(buffer) abort
|
|
||||||
let l:executable = ale_linters#hack#hhast#GetExecutable(a:buffer)
|
|
||||||
|
|
||||||
return ale#Escape(l:executable).' --mode lsp --from vim-ale'
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function !
|
|
||||||
|
|
||||||
call ale#linter#Define('hack', {
|
call ale#linter#Define('hack', {
|
||||||
\ 'name': 'hhast',
|
\ 'name': 'hhast',
|
||||||
\ 'lsp': 'stdio',
|
\ 'lsp': 'stdio',
|
||||||
\ 'executable_callback': 'ale_linters#hack#hhast#GetExecutable',
|
\ 'executable_callback': 'ale_linters#hack#hhast#GetExecutable',
|
||||||
\ 'command_callback': 'ale_linters#hack#hhast#GetCommand',
|
\ 'command': '%e --mode lsp --from vim-ale',
|
||||||
\ 'project_root_callback': 'ale_linters#hack#hhast#GetProjectRoot',
|
\ 'project_root_callback': 'ale_linters#hack#hhast#GetProjectRoot',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ ALE Hack Integration *ale-hack-options*
|
|||||||
===============================================================================
|
===============================================================================
|
||||||
hack *ale-hack-hack*
|
hack *ale-hack-hack*
|
||||||
|
|
||||||
g:ale_hack_hhclient_executable *g:ale_hack_hhclient_executable*
|
g:ale_hack_hack_executable *g:ale_hack_hack_executable*
|
||||||
*b:ale_hack_hhclient_executable*
|
*b:ale_hack_hack_executable*
|
||||||
|
|
||||||
Type: |String|
|
Type: |String|
|
||||||
Default: `'hh_client'`
|
Default: `'hh_client'`
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
<?hh // strict
|
|
||||||
|
|
||||||
async function foo(): Awaitable<void> {
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user