mirror of
https://github.com/amix/vimrc
synced 2025-06-16 09:35:01 +08:00
Updated plugins
This commit is contained in:
@ -4,8 +4,7 @@
|
||||
call ale#Set('haskell_cabal_ghc_options', '-fno-code -v0')
|
||||
|
||||
function! ale_linters#haskell#cabal_ghc#GetCommand(buffer) abort
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . 'cabal exec -- ghc '
|
||||
return 'cabal exec -- ghc '
|
||||
\ . ale#Var(a:buffer, 'haskell_cabal_ghc_options')
|
||||
\ . ' %t'
|
||||
endfunction
|
||||
@ -15,6 +14,7 @@ call ale#linter#Define('haskell', {
|
||||
\ 'aliases': ['cabal-ghc'],
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': 'cabal',
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': function('ale_linters#haskell#cabal_ghc#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
|
||||
\})
|
||||
|
63
sources_non_forked/ale/ale_linters/haskell/hls.vim
Normal file
63
sources_non_forked/ale/ale_linters/haskell/hls.vim
Normal file
@ -0,0 +1,63 @@
|
||||
" Author: Yen3 <yen3rc@gmail.com>
|
||||
" Description: A language server for haskell
|
||||
" The file is based on hie.vim (author: Luxed
|
||||
" <devildead13@gmail.com>). It search more project root files.
|
||||
"
|
||||
call ale#Set('haskell_hls_executable', 'haskell-language-server-wrapper')
|
||||
|
||||
function! ale_linters#haskell#hls#FindRootFile(buffer) abort
|
||||
let l:serach_root_files = [
|
||||
\ 'stack.yaml',
|
||||
\ 'cabal.project',
|
||||
\ 'package.yaml',
|
||||
\ 'hie.yaml'
|
||||
\ ]
|
||||
|
||||
for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h'))
|
||||
for l:root_file in l:serach_root_files
|
||||
if filereadable(l:path . l:root_file)
|
||||
return l:path
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! ale_linters#haskell#hls#GetProjectRoot(buffer) abort
|
||||
" Search for the project file first
|
||||
let l:project_file = ale_linters#haskell#hls#FindRootFile(a:buffer)
|
||||
|
||||
" If it's empty, search for the cabal file
|
||||
if empty(l:project_file)
|
||||
" Search all of the paths except for the root filesystem path.
|
||||
let l:paths = join(
|
||||
\ ale#path#Upwards(expand('#' . a:buffer . ':p:h'))[:-2],
|
||||
\ ','
|
||||
\)
|
||||
let l:project_file = globpath(l:paths, '*.cabal')
|
||||
endif
|
||||
|
||||
" If we still can't find one, use the current file.
|
||||
if empty(l:project_file)
|
||||
let l:project_file = expand('#' . a:buffer . ':p')
|
||||
endif
|
||||
|
||||
return fnamemodify(l:project_file, ':h')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#haskell#hls#GetCommand(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'haskell_hls_executable')
|
||||
|
||||
return ale#handlers#haskell_stack#EscapeExecutable(l:executable,
|
||||
\ 'haskell-language-server-wrapper')
|
||||
\ . ' --lsp'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('haskell', {
|
||||
\ 'name': 'hls',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'command': function('ale_linters#haskell#hls#GetCommand'),
|
||||
\ 'executable': {b -> ale#Var(b, 'haskell_hls_executable')},
|
||||
\ 'project_root': function('ale_linters#haskell#hls#GetProjectRoot'),
|
||||
\})
|
@ -4,8 +4,7 @@
|
||||
call ale#Set('haskell_stack_ghc_options', '-fno-code -v0')
|
||||
|
||||
function! ale_linters#haskell#stack_ghc#GetCommand(buffer) abort
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#handlers#haskell#GetStackExecutable(a:buffer)
|
||||
return ale#handlers#haskell#GetStackExecutable(a:buffer)
|
||||
\ . ' ghc -- '
|
||||
\ . ale#Var(a:buffer, 'haskell_stack_ghc_options')
|
||||
\ . ' %t'
|
||||
@ -16,6 +15,7 @@ call ale#linter#Define('haskell', {
|
||||
\ 'aliases': ['stack-ghc'],
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': function('ale#handlers#haskell#GetStackExecutable'),
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': function('ale_linters#haskell#stack_ghc#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
|
||||
\})
|
||||
|
Reference in New Issue
Block a user