Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix collector script not working for different src folder #30

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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