]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/haskell/hie.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Do not set EDITOR/VISUAL for shell
[etc/vim.git] / .vim / bundle / ale / ale_linters / haskell / hie.vim
1 " Author: Luxed <devildead13@gmail.com>
2 " Description: A language server for Haskell
3
4 call ale#Set('haskell_hie_executable', 'hie')
5
6 function! ale_linters#haskell#hie#GetProjectRoot(buffer) abort
7     " Search for the stack file first
8     let l:project_file = ale#path#FindNearestFile(a:buffer, 'stack.yaml')
9
10     " If it's empty, search for the cabal file
11     if empty(l:project_file)
12         " Search all of the paths except for the root filesystem path.
13         let l:paths = join(
14         \   ale#path#Upwards(expand('#' . a:buffer . ':p:h'))[:-2],
15         \   ','
16         \)
17         let l:project_file = globpath(l:paths, '*.cabal')
18     endif
19
20     " If we still can't find one, use the current file.
21     if empty(l:project_file)
22         let l:project_file = expand('#' . a:buffer . ':p')
23     endif
24
25     return fnamemodify(l:project_file, ':h')
26 endfunction
27
28 function! ale_linters#haskell#hie#GetCommand(buffer) abort
29     let l:executable = ale#Var(a:buffer, 'haskell_hie_executable')
30
31     return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'hie')
32     \   . ' --lsp'
33 endfunction
34
35 call ale#linter#Define('haskell', {
36 \   'name': 'hie',
37 \   'lsp': 'stdio',
38 \   'command': function('ale_linters#haskell#hie#GetCommand'),
39 \   'executable': {b -> ale#Var(b, 'haskell_hie_executable')},
40 \   'project_root': function('ale_linters#haskell#hie#GetProjectRoot'),
41 \})