Skip to content

Commit ce7e89a

Browse files
committed
fix: do not start new lsp client for flutter dependency
1 parent 130ad29 commit ce7e89a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lua/flutter-tools/lsp/init.lua

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,14 @@ end
170170
function M.get_project_root_dir()
171171
local conf = require("flutter-tools.config")
172172
local current_buffer_path = path.current_buffer_path()
173-
local root_path = lsp_utils.is_valid_path(current_buffer_path)
174-
and path.find_root(conf.root_patterns, current_buffer_path)
175-
or nil
176-
177-
if root_path ~= nil then return root_path end
178-
173+
-- Check if path is flutter dependency. For dependencies we do not
174+
-- search for a root directory as they are not projects.
175+
if not path.is_flutter_dependency_path(current_buffer_path) then
176+
local root_path = lsp_utils.is_valid_path(current_buffer_path)
177+
and path.find_root(conf.root_patterns, current_buffer_path)
178+
or nil
179+
if root_path ~= nil then return root_path end
180+
end
179181
local client = lsp_utils.get_dartls_client()
180182
return client and client.config.root_dir or nil
181183
end

0 commit comments

Comments
 (0)