From c02adb498ecd0abfafa635b45976989a78738ed9 Mon Sep 17 00:00:00 2001 From: Maikel Martens Date: Wed, 19 Jun 2024 08:09:20 +0200 Subject: [PATCH] Fix collector script not working for different src folder Resolves #29 --- djlsp/server.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/djlsp/server.py b/djlsp/server.py index 38d273a..b77a20b 100644 --- a/djlsp/server.py +++ b/djlsp/server.py @@ -4,6 +4,7 @@ import shutil import subprocess import uuid +from functools import cached_property from lsprotocol.types import ( INITIALIZE, @@ -55,10 +56,13 @@ def __init__(self, *args): self.workspace_index = WorkspaceIndex() self.workspace_index.update(FALLBACK_DJANGO_DATA) - @property + @cached_property def project_src_path(self): - if os.path.isdir(os.path.join(self.workspace.root_path, "src")): - return os.path.join(self.workspace.root_path, "src") + """Root path to src files, auto detect based on manage.py file""" + for name in os.listdir(self.workspace.root_path): + src_path = os.path.join(self.workspace.root_path, name) + if os.path.exists(os.path.join(src_path, "manage.py")): + return src_path return self.workspace.root_path @property