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: Yen3 <yen3rc@gmail.com>
2 " Description: A language server for haskell
3 " The file is based on hie.vim (author: Luxed
4 " <devildead13@gmail.com>). It search more project root files.
6 call ale#Set('haskell_hls_executable', 'haskell-language-server-wrapper')
7 call ale#Set('haskell_hls_config', {})
9 function! ale_linters#haskell#hls#FindRootFile(buffer) abort
10 let l:serach_root_files = [
17 for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h'))
18 for l:root_file in l:serach_root_files
19 if filereadable(l:path . '/' . l:root_file)
20 " Add on / so fnamemodify(..., ':h') below keeps the path.
29 function! ale_linters#haskell#hls#GetProjectRoot(buffer) abort
30 " Search for the project file first
31 let l:project_file = ale_linters#haskell#hls#FindRootFile(a:buffer)
33 " If it's empty, search for the cabal file
34 if empty(l:project_file)
35 " Search all of the paths except for the root filesystem path.
37 \ ale#path#Upwards(expand('#' . a:buffer . ':p:h'))[:-2],
40 let l:project_file = globpath(l:paths, '*.cabal')
43 " If we still can't find one, use the current file.
44 if empty(l:project_file)
45 let l:project_file = expand('#' . a:buffer . ':p')
48 return fnamemodify(l:project_file, ':h')
51 function! ale_linters#haskell#hls#GetCommand(buffer) abort
52 let l:executable = ale#Var(a:buffer, 'haskell_hls_executable')
54 return ale#handlers#haskell_stack#EscapeExecutable(l:executable,
55 \ 'haskell-language-server-wrapper')
59 call ale#linter#Define('haskell', {
62 \ 'command': function('ale_linters#haskell#hls#GetCommand'),
63 \ 'executable': {b -> ale#Var(b, 'haskell_hls_executable')},
64 \ 'project_root': function('ale_linters#haskell#hls#GetProjectRoot'),
65 \ 'lsp_config': {b -> ale#Var(b, 'haskell_hls_config')},