MCPcopy Index your code
hub / github.com/Acode-Foundation/Acode / configureLspForFile

Function configureLspForFile

src/lib/editorManager.js:724–754  ·  view source on GitHub ↗
(file)

Source from the content-addressed store, hash-verified

722 }
723
724 async function configureLspForFile(file) {
725 const metadata = buildLspMetadata(file);
726 const token = ++lspRequestToken;
727 if (!metadata) {
728 detachActiveLsp();
729 editor.dispatch({ effects: lspCompartment.reconfigure([]) });
730 return;
731 }
732 if (metadata.uri !== lastLspUri) {
733 detachActiveLsp();
734 }
735 try {
736 const extensions =
737 (await lspClientManager.getExtensionsForFile(metadata)) || [];
738 if (token !== lspRequestToken) return;
739 if (!extensions.length) {
740 lastLspUri = null;
741 editor.dispatch({ effects: lspCompartment.reconfigure([]) });
742 return;
743 }
744 lastLspUri = metadata.uri;
745 editor.dispatch({
746 effects: lspCompartment.reconfigure(extensions),
747 });
748 } catch (error) {
749 if (token !== lspRequestToken) return;
750 console.error("Failed to configure LSP", error);
751 lastLspUri = null;
752 editor.dispatch({ effects: lspCompartment.reconfigure([]) });
753 }
754 }
755
756 function detachLspForFile(file) {
757 if (!file || file.type !== "editor") return;

Callers 3

scheduleLspForFileFunction · 0.85
restartLspFunction · 0.85
EditorManagerFunction · 0.85

Calls 4

buildLspMetadataFunction · 0.85
detachActiveLspFunction · 0.85
getExtensionsForFileMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected