Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/cm/lsp/clientManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ export class LspClientManager {
rootUri,
} = metadata;

if (!this.#canUseLspForWorkspace(metadata)) {
logLspInfo(
`Skipping LSP for non-terminal-accessible workspace: ${rootUri || originalUri}`,
);
return [];
}

const effectiveLang = safeString(languageId ?? languageName).toLowerCase();
if (!effectiveLang) return [];

Expand Down Expand Up @@ -320,6 +327,8 @@ export class LspClientManager {
options: FormattingOptions = {},
): Promise<boolean> {
const { uri: originalUri, languageId, languageName, view, file } = metadata;
if (!this.#canUseLspForWorkspace(metadata)) return false;

const effectiveLang = safeString(languageId ?? languageName).toLowerCase();
if (!effectiveLang || !view) return false;

Expand Down Expand Up @@ -379,6 +388,12 @@ export class LspClientManager {
return false;
}

#canUseLspForWorkspace(metadata: FileMetadata): boolean {
if (this.options.allowNonTerminalWorkspace === true) return true;
if (metadata.file?.SAFMode) return false;
return isTerminalAccessibleLspUri(metadata.rootUri || metadata.uri);
}

detach(uri: string, view: EditorView): void {
for (const state of this.#clients.values()) {
state.detach(uri, view);
Expand Down Expand Up @@ -1087,6 +1102,19 @@ function normalizeRootUriForServer(
return { normalizedRootUri: rootUri, originalRootUri: rootUri };
}

function isTerminalAccessibleLspUri(uri: string | null | undefined): boolean {
if (!uri || typeof uri !== "string") return false;

const schemeMatch = /^([a-zA-Z][\w+\-.]*):/.exec(uri);
const scheme = schemeMatch ? schemeMatch[1].toLowerCase() : null;

if (!scheme) return uri.startsWith("/");
if (scheme === "file" || scheme === "untitled") return true;
if (scheme !== "content") return false;

return /^content:\/\/com\.foxdebug\.acode(?:free)?\.documents\//i.test(uri);
}

function normalizeDocumentUri(uri: string | null | undefined): string | null {
if (!uri || typeof uri !== "string") return null;

Expand Down
1 change: 1 addition & 0 deletions src/cm/lsp/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ export interface ClientManagerOptions {
openFile?: (uri: string) => Promise<EditorView | null>;
resolveLanguageId?: (uri: string) => string | null;
onClientIdle?: (info: ClientIdleInfo) => void;
allowNonTerminalWorkspace?: boolean;
}

export interface ClientIdleInfo {
Expand Down
6 changes: 4 additions & 2 deletions src/lang/ar-ye.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@
"settings-info-preview-use-current-file": "Prefer the current file when starting preview.",
"settings-info-terminal-convert-eol": "Convert line endings when pasting or rendering terminal output.",
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. They work best with folders that Acode's built-in terminal can access directly, such as terminal/public folders. SAF, external, and remote locations are skipped by default because they may use cached or virtual paths; enable the compatibility option only if you want to try them.",
"search result label singular": "result",
"search result label plural": "results",
"pin tab": "Pin tab",
Expand Down Expand Up @@ -749,5 +749,7 @@
"copying items": "Copying {count} items...",
"cannot paste folder into itself": "Cannot paste a folder into itself",
"folder already exists": "Folder already exists",
"file already exists force named": "'{name}' already exists. Overwrite?"
"file already exists force named": "'{name}' already exists. Overwrite?",
"lsp-allow-non-terminal-workspace": "Run LSP on external folders",
"settings-info-lsp-allow-non-terminal-workspace": "Allow language servers for SAF, external, and remote locations. LSP runs in Acode's built-in terminal, which cannot access those locations, so features may not work correctly. As it will connect to a virtual path or cache location."
}
6 changes: 4 additions & 2 deletions src/lang/be-by.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@
"settings-info-preview-use-current-file": "Prefer the current file when starting preview.",
"settings-info-terminal-convert-eol": "Convert line endings when pasting or rendering terminal output.",
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. They work best with folders that Acode's built-in terminal can access directly, such as terminal/public folders. SAF, external, and remote locations are skipped by default because they may use cached or virtual paths; enable the compatibility option only if you want to try them.",
"search result label singular": "result",
"search result label plural": "results",
"pin tab": "Pin tab",
Expand Down Expand Up @@ -749,5 +749,7 @@
"copying items": "Copying {count} items...",
"cannot paste folder into itself": "Cannot paste a folder into itself",
"folder already exists": "Folder already exists",
"file already exists force named": "'{name}' already exists. Overwrite?"
"file already exists force named": "'{name}' already exists. Overwrite?",
"lsp-allow-non-terminal-workspace": "Run LSP on external folders",
"settings-info-lsp-allow-non-terminal-workspace": "Allow language servers for SAF, external, and remote locations. LSP runs in Acode's built-in terminal, which cannot access those locations, so features may not work correctly. As it will connect to a virtual path or cache location."
}
6 changes: 4 additions & 2 deletions src/lang/bn-bd.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@
"settings-info-preview-use-current-file": "Prefer the current file when starting preview.",
"settings-info-terminal-convert-eol": "Convert line endings when pasting or rendering terminal output.",
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. They work best with folders that Acode's built-in terminal can access directly, such as terminal/public folders. SAF, external, and remote locations are skipped by default because they may use cached or virtual paths; enable the compatibility option only if you want to try them.",
"search result label singular": "result",
"search result label plural": "results",
"pin tab": "Pin tab",
Expand Down Expand Up @@ -749,5 +749,7 @@
"copying items": "Copying {count} items...",
"cannot paste folder into itself": "Cannot paste a folder into itself",
"folder already exists": "Folder already exists",
"file already exists force named": "'{name}' already exists. Overwrite?"
"file already exists force named": "'{name}' already exists. Overwrite?",
"lsp-allow-non-terminal-workspace": "Run LSP on external folders",
"settings-info-lsp-allow-non-terminal-workspace": "Allow language servers for SAF, external, and remote locations. LSP runs in Acode's built-in terminal, which cannot access those locations, so features may not work correctly. As it will connect to a virtual path or cache location."
}
6 changes: 4 additions & 2 deletions src/lang/cs-cz.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@
"settings-info-preview-use-current-file": "Prefer the current file when starting preview.",
"settings-info-terminal-convert-eol": "Convert line endings when pasting or rendering terminal output.",
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. They work best with folders that Acode's built-in terminal can access directly, such as terminal/public folders. SAF, external, and remote locations are skipped by default because they may use cached or virtual paths; enable the compatibility option only if you want to try them.",
"search result label singular": "result",
"search result label plural": "results",
"pin tab": "Pin tab",
Expand Down Expand Up @@ -749,5 +749,7 @@
"copying items": "Copying {count} items...",
"cannot paste folder into itself": "Cannot paste a folder into itself",
"folder already exists": "Folder already exists",
"file already exists force named": "'{name}' already exists. Overwrite?"
"file already exists force named": "'{name}' already exists. Overwrite?",
"lsp-allow-non-terminal-workspace": "Run LSP on external folders",
"settings-info-lsp-allow-non-terminal-workspace": "Allow language servers for SAF, external, and remote locations. LSP runs in Acode's built-in terminal, which cannot access those locations, so features may not work correctly. As it will connect to a virtual path or cache location."
}
6 changes: 4 additions & 2 deletions src/lang/de-de.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@
"settings-info-preview-use-current-file": "Prefer the current file when starting preview.",
"settings-info-terminal-convert-eol": "Convert line endings when pasting or rendering terminal output.",
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. They work best with folders that Acode's built-in terminal can access directly, such as terminal/public folders. SAF, external, and remote locations are skipped by default because they may use cached or virtual paths; enable the compatibility option only if you want to try them.",
"search result label singular": "result",
"search result label plural": "results",
"pin tab": "Pin tab",
Expand Down Expand Up @@ -749,5 +749,7 @@
"copying items": "Copying {count} items...",
"cannot paste folder into itself": "Cannot paste a folder into itself",
"folder already exists": "Folder already exists",
"file already exists force named": "'{name}' already exists. Overwrite?"
"file already exists force named": "'{name}' already exists. Overwrite?",
"lsp-allow-non-terminal-workspace": "Run LSP on external folders",
"settings-info-lsp-allow-non-terminal-workspace": "Allow language servers for SAF, external, and remote locations. LSP runs in Acode's built-in terminal, which cannot access those locations, so features may not work correctly. As it will connect to a virtual path or cache location."
}
4 changes: 3 additions & 1 deletion src/lang/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@
"settings-info-editor-teardrop-size": "Set the cursor handle size for touch editing.",
"settings-info-editor-text-wrap": "Wrap long lines inside the editor.",
"settings-info-lsp-add-custom-server": "Register a custom language server with install, update, and launch commands.",
"settings-info-lsp-allow-non-terminal-workspace": "Allow language servers for SAF, external, and remote locations. LSP runs in Acode's built-in terminal, which cannot access those locations, so features may not work correctly because it connects to a virtual path or cache location.",
"settings-info-lsp-edit-init-options": "Edit initialization options as JSON.",
"settings-info-lsp-install-server": "Install or repair this language server.",
"settings-info-lsp-remove-custom-server": "Remove this custom language server from Acode.",
Expand Down Expand Up @@ -725,7 +726,8 @@
"settings-info-preview-use-current-file": "Prefer the current file when starting preview.",
"settings-info-terminal-convert-eol": "Convert line endings when pasting or rendering terminal output.",
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. They work best with folders that Acode's built-in terminal can access directly, such as terminal/public folders. SAF, external, and remote locations are skipped by default because they may use cached or virtual paths; enable the compatibility option only if you want to try them.",
"lsp-allow-non-terminal-workspace": "Run LSP on external folders",
"search result label singular": "result",
"search result label plural": "results",
"pin tab": "Pin tab",
Expand Down
6 changes: 4 additions & 2 deletions src/lang/es-sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@
"settings-info-preview-use-current-file": "Prefer the current file when starting preview.",
"settings-info-terminal-convert-eol": "Convert line endings when pasting or rendering terminal output.",
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. They work best with folders that Acode's built-in terminal can access directly, such as terminal/public folders. SAF, external, and remote locations are skipped by default because they may use cached or virtual paths; enable the compatibility option only if you want to try them.",
"search result label singular": "result",
"search result label plural": "results",
"pin tab": "Pin tab",
Expand Down Expand Up @@ -749,5 +749,7 @@
"copying items": "Copying {count} items...",
"cannot paste folder into itself": "Cannot paste a folder into itself",
"folder already exists": "Folder already exists",
"file already exists force named": "'{name}' already exists. Overwrite?"
"file already exists force named": "'{name}' already exists. Overwrite?",
"lsp-allow-non-terminal-workspace": "Run LSP on external folders",
"settings-info-lsp-allow-non-terminal-workspace": "Allow language servers for SAF, external, and remote locations. LSP runs in Acode's built-in terminal, which cannot access those locations, so features may not work correctly. As it will connect to a virtual path or cache location."
}
6 changes: 4 additions & 2 deletions src/lang/fr-fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@
"settings-info-preview-use-current-file": "Prefer the current file when starting preview.",
"settings-info-terminal-convert-eol": "Convert line endings when pasting or rendering terminal output.",
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. They work best with folders that Acode's built-in terminal can access directly, such as terminal/public folders. SAF, external, and remote locations are skipped by default because they may use cached or virtual paths; enable the compatibility option only if you want to try them.",
"search result label singular": "result",
"search result label plural": "results",
"pin tab": "Pin tab",
Expand Down Expand Up @@ -749,5 +749,7 @@
"copying items": "Copying {count} items...",
"cannot paste folder into itself": "Cannot paste a folder into itself",
"folder already exists": "Folder already exists",
"file already exists force named": "'{name}' already exists. Overwrite?"
"file already exists force named": "'{name}' already exists. Overwrite?",
"lsp-allow-non-terminal-workspace": "Run LSP on external folders",
"settings-info-lsp-allow-non-terminal-workspace": "Allow language servers for SAF, external, and remote locations. LSP runs in Acode's built-in terminal, which cannot access those locations, so features may not work correctly. As it will connect to a virtual path or cache location."
}
6 changes: 4 additions & 2 deletions src/lang/he-il.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@
"settings-info-preview-use-current-file": "Prefer the current file when starting preview.",
"settings-info-terminal-convert-eol": "Convert line endings when pasting or rendering terminal output.",
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. They work best with folders that Acode's built-in terminal can access directly, such as terminal/public folders. SAF, external, and remote locations are skipped by default because they may use cached or virtual paths; enable the compatibility option only if you want to try them.",
"search result label singular": "result",
"search result label plural": "results",
"pin tab": "Pin tab",
Expand Down Expand Up @@ -749,5 +749,7 @@
"copying items": "Copying {count} items...",
"cannot paste folder into itself": "Cannot paste a folder into itself",
"folder already exists": "Folder already exists",
"file already exists force named": "'{name}' already exists. Overwrite?"
"file already exists force named": "'{name}' already exists. Overwrite?",
"lsp-allow-non-terminal-workspace": "Run LSP on external folders",
"settings-info-lsp-allow-non-terminal-workspace": "Allow language servers for SAF, external, and remote locations. LSP runs in Acode's built-in terminal, which cannot access those locations, so features may not work correctly. As it will connect to a virtual path or cache location."
}
6 changes: 4 additions & 2 deletions src/lang/hi-in.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@
"settings-info-preview-use-current-file": "Prefer the current file when starting preview.",
"settings-info-terminal-convert-eol": "Convert line endings when pasting or rendering terminal output.",
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. They work best with folders that Acode's built-in terminal can access directly, such as terminal/public folders. SAF, external, and remote locations are skipped by default because they may use cached or virtual paths; enable the compatibility option only if you want to try them.",
"search result label singular": "result",
"search result label plural": "results",
"pin tab": "Pin tab",
Expand Down Expand Up @@ -749,5 +749,7 @@
"copying items": "Copying {count} items...",
"cannot paste folder into itself": "Cannot paste a folder into itself",
"folder already exists": "Folder already exists",
"file already exists force named": "'{name}' already exists. Overwrite?"
"file already exists force named": "'{name}' already exists. Overwrite?",
"lsp-allow-non-terminal-workspace": "Run LSP on external folders",
"settings-info-lsp-allow-non-terminal-workspace": "Allow language servers for SAF, external, and remote locations. LSP runs in Acode's built-in terminal, which cannot access those locations, so features may not work correctly. As it will connect to a virtual path or cache location."
}
Loading