@@ -15,6 +15,10 @@ let lsClient: LanguageClient | undefined;
1515
1616
1717export async function activate ( context : vscode . ExtensionContext ) {
18+ // Create output channel first so we can log everything
19+ const outputChannel = createOutputChannel ( "Finecode LSP Server" ) ;
20+ outputChannel . info ( '=== Finecode extension activation started ===' ) ;
21+
1822 console . log (
1923 'Congratulations, your extension "finecode-vscode" is now active!'
2024 ) ;
@@ -25,6 +29,8 @@ export async function activate(context: vscode.ExtensionContext) {
2529 vscode . workspace . workspaceFolders . length > 0
2630 ? vscode . workspace . workspaceFolders [ 0 ] . uri . fsPath
2731 : "" ; // : undefined; // TODO
32+
33+ outputChannel . info ( `Workspace root path: ${ rootPath } ` ) ;
2834 const actionsProvider = new FineCodeActionsProvider ( rootPath ) ;
2935
3036
@@ -50,7 +56,7 @@ export async function activate(context: vscode.ExtensionContext) {
5056 return Promise . resolve ( [ ] ) ;
5157 } ,
5258 resolveTask ( _task : vscode . Task ) : vscode . Task | undefined {
53- console . log ( "resolve" , _task ) ;
59+ outputChannel . debug ( "resolve task " , _task ) ;
5460 return _task ;
5561 // const task = _task.definition.task;
5662 // if (task) {
@@ -68,15 +74,14 @@ export async function activate(context: vscode.ExtensionContext) {
6874 } ,
6975 } ;
7076
71- // default output channel causes multiple loggers on restart of language server. Use own one
72- // to avoid this problem
73- const outputChannel = createOutputChannel ( "Finecode LSP Server" ) ;
77+ outputChannel . info ( 'Starting workspace manager...' ) ;
7478 await runWorkspaceManager ( outputChannel , actionsProvider ) ;
7579
80+ outputChannel . info ( 'Registering commands and providers...' ) ;
7681 context . subscriptions . push (
7782 vscode . window . registerTreeDataProvider ( "fineCodeActions" , actionsProvider ) ,
7883 vscode . commands . registerCommand ( 'finecode.restartWorkspaceManager' , async ( ) => {
79- console . log ( 'Restarting workspace manager' ) ;
84+ outputChannel . info ( 'Restarting workspace manager' ) ;
8085 stopWorkspaceManager ( ) ;
8186 runWorkspaceManager ( outputChannel , actionsProvider ) ;
8287 } ) ,
@@ -133,6 +138,8 @@ export async function activate(context: vscode.ExtensionContext) {
133138 }
134139 } )
135140 ) ;
141+
142+ outputChannel . info ( '=== Finecode extension activation complete ===' ) ;
136143}
137144
138145export async function deactivate ( ) {
@@ -141,24 +148,31 @@ export async function deactivate() {
141148
142149const runWorkspaceManager = async ( outputChannel : vscode . LogOutputChannel , actionsProvider : FineCodeActionsProvider ) => {
143150 if ( ! vscode . workspace . workspaceFolders ) {
144- console . log ( "No workspace folders, add one and restart extension. Autoreload is not supported yet " ) ;
151+ outputChannel . error ( "No workspace folders found. Please open a workspace folder and restart the extension. " ) ;
145152 return ;
146153 }
147154
155+ outputChannel . info ( `Found ${ vscode . workspace . workspaceFolders . length } workspace folder(s)` ) ;
156+
148157 let devWorkspacePythonPath : string | undefined = undefined ;
149158 let wsDir : string | undefined = undefined ;
150159 let finecodeFound = false ;
151160 for ( const folder of vscode . workspace . workspaceFolders ) {
152161 const dirPath = folder . uri . path ;
153162 devWorkspacePythonPath = dirPath + '/.venvs/dev_workspace/bin/python' ;
163+ outputChannel . info ( `Checking for Python at: ${ devWorkspacePythonPath } ` ) ;
154164 if ( fs . existsSync ( devWorkspacePythonPath ) ) {
165+ outputChannel . info ( `Found dev_workspace Python at: ${ devWorkspacePythonPath } ` ) ;
155166 finecodeFound = true ;
167+ } else {
168+ outputChannel . warn ( `Python not found at: ${ devWorkspacePythonPath } ` ) ;
156169 }
157170 break ;
158171 }
159172
160173 if ( ! finecodeFound ) {
161- console . log ( 'No dev_workspace found in workspace folders. Add one and restart the extension. Autoreload is not supported yet' ) ;
174+ outputChannel . error ( 'No dev_workspace found in workspace folders. Expected path: .venvs/dev_workspace/bin/python' ) ;
175+ outputChannel . error ( 'Please create the virtual environment and restart the extension.' ) ;
162176 return ;
163177 }
164178
@@ -181,6 +195,9 @@ const runWorkspaceManager = async (outputChannel: vscode.LogOutputChannel, actio
181195 transport : TransportKind . stdio
182196 } ;
183197
198+ outputChannel . info ( `Starting language server with command: ${ finecodeCmdSplit [ 0 ] } ` ) ;
199+ outputChannel . info ( `Args: ${ JSON . stringify ( [ ...finecodeCmdSplit . slice ( 1 ) , '-m' , 'finecode.cli' , ...wmArgs ] ) } ` ) ;
200+
184201 // Options to control the language client
185202 const clientOptions : LanguageClientOptions = {
186203 // TODO: dynamic or for all?
@@ -200,7 +217,14 @@ const runWorkspaceManager = async (outputChannel: vscode.LogOutputChannel, actio
200217 // Start the client. This will also launch the server
201218 // waiting on start server is required, otherwise we will get empty response on first request
202219 // like action list
203- await lsClient . start ( ) ;
220+ outputChannel . info ( 'Starting language client...' ) ;
221+ try {
222+ await lsClient . start ( ) ;
223+ outputChannel . info ( 'Language server started successfully!' ) ;
224+ } catch ( error ) {
225+ outputChannel . error ( `Failed to start language server: ${ error } ` ) ;
226+ throw error ;
227+ }
204228
205229 lsClient . onRequest ( 'editor/documentMeta' , ( ) => {
206230 console . log ( 'editor/documentMeta request' ) ;
0 commit comments