@@ -168,91 +168,25 @@ impl zed::Extension for PhpcsLspExtension {
168168 . ok ( )
169169 . and_then ( |lsp_settings| lsp_settings. settings . clone ( ) ) ;
170170
171- // Check for user-configured PHPCS path from settings.json
172- let mut found_phpcs_path = false ;
173- if let Some ( settings) = user_settings. as_ref ( ) {
174- if let Some ( phpcs_path) = settings. get ( "phpcsPath" ) . and_then ( |v| v. as_str ( ) ) {
175- if !phpcs_path. trim ( ) . is_empty ( ) {
176- eprintln ! ( "PHPCS LSP: Using custom PHPCS path from settings: {}" , phpcs_path) ;
177- options. insert ( "phpcsPath" . to_string ( ) , zed:: serde_json:: Value :: String ( phpcs_path. to_string ( ) ) ) ;
178- found_phpcs_path = true ;
179- }
180- }
181- }
182-
183- // Fall back to environment variable if no settings configured
184- if !found_phpcs_path {
185- if let Ok ( custom_phpcs_path) = env:: var ( "PHPCS_PATH" ) {
186- if !custom_phpcs_path. trim ( ) . is_empty ( ) {
187- eprintln ! ( "PHPCS LSP: Using custom PHPCS path from PHPCS_PATH env: {}" , custom_phpcs_path) ;
188- options. insert ( "phpcsPath" . to_string ( ) , zed:: serde_json:: Value :: String ( custom_phpcs_path) ) ;
189- found_phpcs_path = true ;
190- }
191- }
192- }
193-
194- // Fall back to auto-discovery if no custom path specified
195- if !found_phpcs_path {
196- if let Some ( phpcs_path) = Self :: find_phpcs_binary ( worktree) {
197- eprintln ! ( "PHPCS LSP: Found PHPCS: {}" , phpcs_path) ;
198- options. insert ( "phpcsPath" . to_string ( ) , zed:: serde_json:: Value :: String ( phpcs_path) ) ;
199- } else {
200- // Try to download PHPCS PHAR
201- eprintln ! ( "PHPCS LSP: No local PHPCS found, attempting to download..." ) ;
202- match Self :: download_phar_if_needed ( "phpcs.phar" ) {
203- Ok ( _phar_path) => {
204- eprintln ! ( "PHPCS LSP: Downloaded PHPCS successfully" ) ;
205- // Since the LSP server runs from the version directory, just provide the filename
206- options. insert ( "phpcsPath" . to_string ( ) , zed:: serde_json:: Value :: String ( "phpcs.phar" . to_string ( ) ) ) ;
207- }
208- Err ( e) => {
209- eprintln ! ( "PHPCS LSP: Failed to download PHPCS: {}" , e) ;
210- }
211- }
171+ // Download PHPCS PHAR to LSP server directory - LSP server will find it automatically
172+ eprintln ! ( "PHPCS LSP: Ensuring PHPCS PHAR is available in LSP server directory..." ) ;
173+ match Self :: download_phar_if_needed ( "phpcs.phar" ) {
174+ Ok ( _phar_path) => {
175+ eprintln ! ( "PHPCS LSP: PHPCS PHAR available for LSP server" ) ;
212176 }
213- }
214-
215- // Check for user-configured PHPCBF path from settings.json
216- let mut found_phpcbf_path = false ;
217- if let Some ( settings) = user_settings. as_ref ( ) {
218- if let Some ( phpcbf_path) = settings. get ( "phpcbfPath" ) . and_then ( |v| v. as_str ( ) ) {
219- if !phpcbf_path. trim ( ) . is_empty ( ) {
220- eprintln ! ( "PHPCS LSP: Using custom PHPCBF path from settings: {}" , phpcbf_path) ;
221- options. insert ( "phpcbfPath" . to_string ( ) , zed:: serde_json:: Value :: String ( phpcbf_path. to_string ( ) ) ) ;
222- found_phpcbf_path = true ;
223- }
177+ Err ( e) => {
178+ eprintln ! ( "PHPCS LSP: Failed to download PHPCS PHAR: {}" , e) ;
224179 }
225180 }
226181
227- // Fall back to environment variable if no settings configured
228- if !found_phpcbf_path {
229- if let Ok ( custom_phpcbf_path) = env:: var ( "PHPCBF_PATH" ) {
230- if !custom_phpcbf_path. trim ( ) . is_empty ( ) {
231- eprintln ! ( "PHPCS LSP: Using custom PHPCBF path from PHPCBF_PATH env: {}" , custom_phpcbf_path) ;
232- options. insert ( "phpcbfPath" . to_string ( ) , zed:: serde_json:: Value :: String ( custom_phpcbf_path) ) ;
233- found_phpcbf_path = true ;
234- }
182+ // Download PHPCBF PHAR to LSP server directory - LSP server will find it automatically
183+ eprintln ! ( "PHPCS LSP: Ensuring PHPCBF PHAR is available in LSP server directory..." ) ;
184+ match Self :: download_phar_if_needed ( "phpcbf.phar" ) {
185+ Ok ( _phar_path) => {
186+ eprintln ! ( "PHPCS LSP: PHPCBF PHAR available for LSP server" ) ;
235187 }
236- }
237-
238- // Fall back to auto-discovery if no custom path specified
239- if !found_phpcbf_path {
240- if let Some ( phpcbf_path) = Self :: find_phpcbf_binary ( worktree) {
241- eprintln ! ( "PHPCS LSP: Found PHPCBF: {}" , phpcbf_path) ;
242- options. insert ( "phpcbfPath" . to_string ( ) , zed:: serde_json:: Value :: String ( phpcbf_path) ) ;
243- } else {
244- // Try to download PHPCBF PHAR
245- eprintln ! ( "PHPCS LSP: No local PHPCBF found, attempting to download..." ) ;
246- match Self :: download_phar_if_needed ( "phpcbf.phar" ) {
247- Ok ( _phar_path) => {
248- eprintln ! ( "PHPCS LSP: Downloaded PHPCBF successfully" ) ;
249- // Since the LSP server runs from the version directory, just provide the filename
250- options. insert ( "phpcbfPath" . to_string ( ) , zed:: serde_json:: Value :: String ( "phpcbf.phar" . to_string ( ) ) ) ;
251- }
252- Err ( e) => {
253- eprintln ! ( "PHPCS LSP: Failed to download PHPCBF: {}" , e) ;
254- }
255- }
188+ Err ( e) => {
189+ eprintln ! ( "PHPCS LSP: Failed to download PHPCBF PHAR: {}" , e) ;
256190 }
257191 }
258192
0 commit comments