@@ -207,6 +207,34 @@ def get_config_suggestions(_params: any) -> dict[str, any]:
207207 formatter_suggestions , default_formatter = get_suggestions (CommonSections .formatter_cmds )
208208 get_valid_subdirs .cache_clear ()
209209
210+ # Provide sensible fallbacks when no subdirectories are found
211+ # Only suggest directories that actually exist in the workspace
212+ if not module_root_suggestions :
213+ cwd = Path .cwd ()
214+ common_module_dirs = ["src" , "lib" , "app" ]
215+ module_root_suggestions = ["." ] # Always include current directory
216+
217+ # Add common patterns only if they exist
218+ for dir_name in common_module_dirs :
219+ if (cwd / dir_name ).is_dir ():
220+ module_root_suggestions .append (dir_name )
221+
222+ default_module_root = "."
223+
224+ if not tests_root_suggestions :
225+ cwd = Path .cwd ()
226+ common_test_dirs = ["tests" , "test" , "__tests__" ]
227+ tests_root_suggestions = []
228+
229+ # Add common test directories only if they exist
230+ for dir_name in common_test_dirs :
231+ if (cwd / dir_name ).is_dir ():
232+ tests_root_suggestions .append (dir_name )
233+
234+ # Always include current directory as fallback
235+ tests_root_suggestions .append ("." )
236+ default_tests_root = tests_root_suggestions [0 ] if tests_root_suggestions else "."
237+
210238 try :
211239 configured_module_root = (
212240 Path (server .args .module_root ).relative_to (Path .cwd ()) if server .args .module_root else None
0 commit comments