Close #4541 - Fix Haskell project root detection

We weren't joining and returning paths correctly for detecting project
roots for Haskell projects, and now we are.

Co-authored-by: Rodrigo Mesquita <rodrigo.m.mesquita@gmail.com>
This commit is contained in:
w0rp 2023-09-16 23:25:39 +01:00
parent dca621b675
commit bd9fc580a1
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
7 changed files with 13 additions and 2 deletions

View File

@ -16,8 +16,9 @@ function! ale_linters#haskell#hls#FindRootFile(buffer) abort
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
if filereadable(l:path . '/' . l:root_file)
" Add on / so fnamemodify(..., ':h') below keeps the path.
return l:path . '/'
endif
endfor
endfor

View File

@ -30,3 +30,13 @@ Execute(Should accept configuration settings):
AssertLSPConfig {}
let b:ale_haskell_hls_config = {'haskell': {'maxCompletions': 250}}
AssertLSPConfig {'haskell': {'maxCompletions': 250}}
Execute(We should detect the root with cabal.project files, preferred over *.cabal files):
call ale#test#SetFilename('../test-files/haskell/haskell-packages-project/package-a/src/folder/dummy.hs')
AssertLSPProject ale#test#GetFilename('../test-files/haskell/haskell-packages-project')
Execute(We should a project root with *.cabal files):
call ale#test#SetFilename('../test-files/haskell/haskell-simple-package/package-a/src/folder/dummy.hs')
AssertLSPProject ale#test#GetFilename('../test-files/haskell/haskell-simple-package/package-a')