@@ -160,10 +160,23 @@ export class LspClientManager {
160160 if ( ! servers . length ) return [ ] ;
161161
162162 // Normalize the document URI for LSP (convert content:// to file://)
163- const normalizedUri = normalizeDocumentUri ( originalUri ) ;
163+ let normalizedUri = normalizeDocumentUri ( originalUri ) ;
164164 if ( ! normalizedUri ) {
165- console . warn ( `Cannot normalize document URI for LSP: ${ originalUri } ` ) ;
166- return [ ] ;
165+ // Fall back to cache file path for unrecognized URIs
166+ // This allows LSP to work with any file system provider using the local cache
167+ const cacheFile = file ?. cacheFile ;
168+ if ( cacheFile && typeof cacheFile === "string" ) {
169+ normalizedUri = buildFileUri ( cacheFile . replace ( / ^ f i l e : \/ \/ / , "" ) ) ;
170+ if ( normalizedUri ) {
171+ console . info (
172+ `LSP using cache path for unrecognized URI: ${ originalUri } -> ${ normalizedUri } ` ,
173+ ) ;
174+ }
175+ }
176+ if ( ! normalizedUri ) {
177+ console . warn ( `Cannot normalize document URI for LSP: ${ originalUri } ` ) ;
178+ return [ ] ;
179+ }
167180 }
168181
169182 const lspExtensions : Extension [ ] = [ ] ;
@@ -232,12 +245,18 @@ export class LspClientManager {
232245 const effectiveLang = safeString ( languageId ?? languageName ) . toLowerCase ( ) ;
233246 if ( ! effectiveLang || ! view ) return false ;
234247
235- const normalizedUri = normalizeDocumentUri ( originalUri ) ;
248+ let normalizedUri = normalizeDocumentUri ( originalUri ) ;
236249 if ( ! normalizedUri ) {
237- console . warn (
238- `Cannot normalize document URI for formatting: ${ originalUri } ` ,
239- ) ;
240- return false ;
250+ const cacheFile = file ?. cacheFile ;
251+ if ( cacheFile && typeof cacheFile === "string" ) {
252+ normalizedUri = buildFileUri ( cacheFile . replace ( / ^ f i l e : \/ \/ / , "" ) ) ;
253+ }
254+ if ( ! normalizedUri ) {
255+ console . warn (
256+ `Cannot normalize document URI for formatting: ${ originalUri } ` ,
257+ ) ;
258+ return false ;
259+ }
241260 }
242261
243262 const servers = serverRegistry . getServersForLanguage ( effectiveLang ) ;
0 commit comments