All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: Fred Emmott <fe@fb.com>
2 " Description: Hack support via `hhast lsp`
4 call ale#Set('hack_hhast_executable', 'vendor/bin/hhast-lint')
6 function! ale_linters#hack#hhast#GetProjectRoot(buffer) abort
7 " Find the hack root, then figure out if it's also an HHAST root.
8 " Don't try to use lint configurations from vendor/foo/bar/hhast-lint.json
9 let l:hhconfig = ale#path#FindNearestFile(a:buffer, '.hhconfig')
15 let l:root = fnamemodify(l:hhconfig, ':h')
16 let l:hhast_config = findfile('hhast-lint.json', l:root)
18 return !empty(l:hhast_config) ? l:root : ''
21 function! ale_linters#hack#hhast#GetExecutable(buffer) abort
22 let l:root = ale_linters#hack#hhast#GetProjectRoot(a:buffer)
23 let l:relative = ale#Var(a:buffer, 'hack_hhast_executable')
24 let l:absolute = findfile(l:relative, l:root)
26 return !empty(l:absolute) ? l:absolute : ''
29 function! ale_linters#hack#hhast#GetInitializationOptions(buffer) abort
30 return {'lintMode': 'open-files'}
33 call ale#linter#Define('hack', {
36 \ 'executable': function('ale_linters#hack#hhast#GetExecutable'),
37 \ 'command': '%e --mode lsp --from vim-ale',
38 \ 'project_root': function('ale_linters#hack#hhast#GetProjectRoot'),
39 \ 'initialization_options': function('ale_linters#hack#hhast#GetInitializationOptions'),