diff options
author | w0rp <devw0rp@gmail.com> | 2023-09-16 23:25:39 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2023-09-16 23:25:39 +0100 |
commit | bd9fc580a1cda702e8aa3de0d06086468fdaf3f4 (patch) | |
tree | 76050b5ee39f943aee591cf16adc1a0d25878941 | |
parent | dca621b6755a47469c94ee8fd26f390e34804077 (diff) | |
download | ale-bd9fc580a1cda702e8aa3de0d06086468fdaf3f4.zip |
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>
7 files changed, 13 insertions, 2 deletions
diff --git a/ale_linters/haskell/hls.vim b/ale_linters/haskell/hls.vim index 7f9efc38..7f7f42e1 100644 --- a/ale_linters/haskell/hls.vim +++ b/ale_linters/haskell/hls.vim @@ -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 diff --git a/test/linter/test_haskell_hls.vader b/test/linter/test_haskell_hls.vader index 4452d53c..59a50078 100644 --- a/test/linter/test_haskell_hls.vader +++ b/test/linter/test_haskell_hls.vader @@ -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') diff --git a/test/test-files/haskell/haskell-packages-project/cabal.project b/test/test-files/haskell/haskell-packages-project/cabal.project new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/test-files/haskell/haskell-packages-project/cabal.project diff --git a/test/test-files/haskell/haskell-packages-project/package-a/package-a.cabal b/test/test-files/haskell/haskell-packages-project/package-a/package-a.cabal new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/test-files/haskell/haskell-packages-project/package-a/package-a.cabal diff --git a/test/test-files/haskell/haskell-packages-project/package-a/src/folder/dummy.hs b/test/test-files/haskell/haskell-packages-project/package-a/src/folder/dummy.hs new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/test-files/haskell/haskell-packages-project/package-a/src/folder/dummy.hs diff --git a/test/test-files/haskell/haskell-simple-package/package-a/package-a.cabal b/test/test-files/haskell/haskell-simple-package/package-a/package-a.cabal new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/test-files/haskell/haskell-simple-package/package-a/package-a.cabal diff --git a/test/test-files/haskell/haskell-simple-package/package-a/src/folder/dummy.hs b/test/test-files/haskell/haskell-simple-package/package-a/src/folder/dummy.hs new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/test-files/haskell/haskell-simple-package/package-a/src/folder/dummy.hs |