From 55ecdbda227728fdd39a54ef1354b8f87bdf0b0f Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sun, 17 Jul 2022 23:58:47 +0300 Subject: fix(hls): wrong root dir for multi-package projects #2010 Problem: In haskell multi-package projects there is *.cabal file in every package folder, so util.root_pattern always find root of the package but not project. Solution: Adjust the condition. --- lua/lspconfig/server_configurations/hls.lua | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'lua') diff --git a/lua/lspconfig/server_configurations/hls.lua b/lua/lspconfig/server_configurations/hls.lua index 32b3ea22..54b45e98 100644 --- a/lua/lspconfig/server_configurations/hls.lua +++ b/lua/lspconfig/server_configurations/hls.lua @@ -4,7 +4,12 @@ return { default_config = { cmd = { 'haskell-language-server-wrapper', '--lsp' }, filetypes = { 'haskell', 'lhaskell' }, - root_dir = util.root_pattern('*.cabal', 'stack.yaml', 'cabal.project', 'package.yaml', 'hie.yaml'), + root_dir = function(filepath) + return ( + util.root_pattern('hie.yaml', 'stack.yaml', 'cabal.project')(filepath) + or util.root_pattern('*.cabal', 'package.yaml')(filepath) + ) + end, single_file_support = true, settings = { haskell = { @@ -34,10 +39,17 @@ return { https://github.com/haskell/haskell-language-server Haskell Language Server - ]], + ]], default_config = { - root_dir = [[root_pattern("*.cabal", "stack.yaml", "cabal.project", "package.yaml", "hie.yaml")]], + root_dir = [[ +function (filepath) + return ( + util.root_pattern('hie.yaml', 'stack.yaml', 'cabal.project')(filepath) + or util.root_pattern('*.cabal', 'package.yaml')(filepath) + ) +end + ]], }, }, } -- cgit v1.2.3-70-g09d2