Skip to content

Commit

Permalink
Fix collector script not working for different src folder
Browse files Browse the repository at this point in the history
Resolves #29
  • Loading branch information
krukas committed Jun 19, 2024
1 parent b401044 commit c02adb4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions djlsp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shutil
import subprocess
import uuid
from functools import cached_property

from lsprotocol.types import (
INITIALIZE,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c02adb4

Please sign in to comment.