4343 get_project_config ,
4444 parse_cli_args ,
4545)
46- from vectorcode .common import get_client , get_collection , try_server
46+ from vectorcode .common import ClientManager , get_collection , try_server
4747from vectorcode .subcommands .ls import get_collection_list
4848from vectorcode .subcommands .query import build_query_results
4949
@@ -114,7 +114,7 @@ async def execute_command(ls: LanguageServer, args: list[str]):
114114 parsed_args .project_root
115115 ].merge_from (parsed_args )
116116 final_configs .pipe = True
117- client = await get_client (final_configs )
117+ client = ( await ClientManager (). get_client (final_configs )). client
118118 if final_configs .action in {CliAction .vectorise , CliAction .query }:
119119 collection = await get_collection (
120120 client = client ,
@@ -123,7 +123,7 @@ async def execute_command(ls: LanguageServer, args: list[str]):
123123 )
124124 else :
125125 final_configs = parsed_args
126- client = await get_client (parsed_args )
126+ client = ( await ClientManager (). get_client (final_configs )). client
127127 collection = None
128128 logger .info ("Merged final configs: %s" , final_configs )
129129 progress_token = str (uuid .uuid4 ())
@@ -266,9 +266,11 @@ async def lsp_start() -> int:
266266 logger .info (f"{ DEFAULT_PROJECT_ROOT = } " )
267267
268268 logger .info ("Parsed LSP server CLI arguments: %s" , args )
269- await asyncio .to_thread (server .start_io )
270-
271- return 0
269+ try :
270+ await asyncio .to_thread (server .start_io )
271+ finally :
272+ await ClientManager ().kill_servers ()
273+ return 0
272274
273275
274276def main (): # pragma: nocover
0 commit comments