diff --git a/apps/docs/.dumi/tsconfig.json b/apps/docs/.dumi/tsconfig.json index af2a6b6e..e3decbb9 100644 --- a/apps/docs/.dumi/tsconfig.json +++ b/apps/docs/.dumi/tsconfig.json @@ -1,6 +1,6 @@ { "extends": "../tsconfig.json", "compilerOptions": { - "rootDir": "/", - }, + "rootDir": "/" + } } diff --git a/apps/docs/tsconfig.json b/apps/docs/tsconfig.json index dff20382..c9da781c 100644 --- a/apps/docs/tsconfig.json +++ b/apps/docs/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/package.json b/package.json index efd240f8..6087877c 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "build": "nx run-many --target=build", "lint": "nx run-many --target=lint:prettier,lint", "lint:prettier": "prettier --check --ignore-unknown .", + "prettier": "prettier --ignore-unknown . --write", "lint-staged": "lint-staged", "test": "nx run-many --target=test", "ci:setup": "nx run-many --target=setup", diff --git a/packages/libro-code-cell/tsconfig.json b/packages/libro-code-cell/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-code-cell/tsconfig.json +++ b/packages/libro-code-cell/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-code-editor/tsconfig.json b/packages/libro-code-editor/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-code-editor/tsconfig.json +++ b/packages/libro-code-editor/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-codemirror/src/auto-complete/state.ts b/packages/libro-codemirror/src/auto-complete/state.ts index 12ad4508..304ce6c4 100644 --- a/packages/libro-codemirror/src/auto-complete/state.ts +++ b/packages/libro-codemirror/src/auto-complete/state.ts @@ -167,9 +167,10 @@ export class CompletionState { const sources = conf.override || state - .languageDataAt< - CompletionSource | readonly (string | Completion)[] - >('autocomplete', cur(state)) + .languageDataAt( + 'autocomplete', + cur(state), + ) .map(asSource); let active: readonly ActiveSource[] = sources.map((source) => { const value = diff --git a/packages/libro-codemirror/tsconfig.json b/packages/libro-codemirror/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-codemirror/tsconfig.json +++ b/packages/libro-codemirror/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-cofine-editor-contribution/tsconfig.json b/packages/libro-cofine-editor-contribution/tsconfig.json index 39496be6..a18e7b25 100644 --- a/packages/libro-cofine-editor-contribution/tsconfig.json +++ b/packages/libro-cofine-editor-contribution/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src", "typings"], + "include": ["src", "typings"] } diff --git a/packages/libro-cofine-editor-core/tsconfig.json b/packages/libro-cofine-editor-core/tsconfig.json index 592b9512..b76b3969 100644 --- a/packages/libro-cofine-editor-core/tsconfig.json +++ b/packages/libro-cofine-editor-core/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": ".", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src", "typings", "package.json"], + "include": ["src", "typings", "package.json"] } diff --git a/packages/libro-cofine-editor/tsconfig.json b/packages/libro-cofine-editor/tsconfig.json index 39496be6..a18e7b25 100644 --- a/packages/libro-cofine-editor/tsconfig.json +++ b/packages/libro-cofine-editor/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src", "typings"], + "include": ["src", "typings"] } diff --git a/packages/libro-cofine-textmate/tsconfig.json b/packages/libro-cofine-textmate/tsconfig.json index 39496be6..a18e7b25 100644 --- a/packages/libro-cofine-textmate/tsconfig.json +++ b/packages/libro-cofine-textmate/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src", "typings"], + "include": ["src", "typings"] } diff --git a/packages/libro-common/tsconfig.json b/packages/libro-common/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-common/tsconfig.json +++ b/packages/libro-common/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-core/tsconfig.json b/packages/libro-core/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-core/tsconfig.json +++ b/packages/libro-core/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-jupyter/tsconfig.json b/packages/libro-jupyter/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-jupyter/tsconfig.json +++ b/packages/libro-jupyter/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-kernel/tsconfig.json b/packages/libro-kernel/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-kernel/tsconfig.json +++ b/packages/libro-kernel/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-l10n/tsconfig.json b/packages/libro-l10n/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-l10n/tsconfig.json +++ b/packages/libro-l10n/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-lab/src/kernel-and-terminal-panel/kernel-and-terminal-panel-view.tsx b/packages/libro-lab/src/kernel-and-terminal-panel/kernel-and-terminal-panel-view.tsx index a075ec3a..08e46ed0 100644 --- a/packages/libro-lab/src/kernel-and-terminal-panel/kernel-and-terminal-panel-view.tsx +++ b/packages/libro-lab/src/kernel-and-terminal-panel/kernel-and-terminal-panel-view.tsx @@ -1,7 +1,6 @@ import { LibroKernelManager, LibroSessionManager } from '@difizen/libro-kernel'; -import { DocumentConnectionManager } from '@difizen/libro-lsp'; -import type { ILanguageServerManager } from '@difizen/libro-lsp'; -import type { ILSPDocumentConnectionManager } from '@difizen/libro-lsp'; +import type { ILanguageServerManager, TLanguageServerId } from '@difizen/libro-lsp'; +import { ILSPDocumentConnectionManager } from '@difizen/libro-lsp'; import { TerminalManager } from '@difizen/libro-terminal'; import { BaseView, @@ -31,8 +30,13 @@ const PanelRender: React.FC = () => { const instance = useInject(ViewInstance); const openedTabView = instance.getAllOpenedTabView(); - const { libroKernelManager, libroSessionManager, terminalManager, lspManager } = - instance; + const { + libroKernelManager, + libroSessionManager, + terminalManager, + lspManager, + lspConnectionManager, + } = instance; const [kernelItems, setKernelItems] = useState< LibroPanelCollapseKernelItem[] | undefined @@ -57,7 +61,8 @@ const PanelRender: React.FC = () => { items.push({ id: key, name: `${key} (${session.spec.languages.join('/')})`, - shutdown: async () => lspManager.shutdown(key), + shutdown: async () => + lspConnectionManager.disconnectServer(key as TLanguageServerId), }); }); @@ -160,7 +165,7 @@ const PanelRender: React.FC = () => { lspManager.shutdownAll()} + shutdownAll={async () => lspConnectionManager.disconnectAllServers()} /> ); @@ -178,13 +183,14 @@ export class KernelAndTerminalPanelView extends BaseView { libroKernelManager: LibroKernelManager; libroSessionManager: LibroSessionManager; terminalManager: TerminalManager; + lspConnectionManager: ILSPDocumentConnectionManager; lspManager: ILanguageServerManager; constructor( @inject(LibroKernelManager) libroKernelManager: LibroKernelManager, @inject(LibroSessionManager) libroSessionManager: LibroSessionManager, @inject(TerminalManager) terminalManager: TerminalManager, - @inject(DocumentConnectionManager) + @inject(ILSPDocumentConnectionManager) lspDocumentConnectionManager: ILSPDocumentConnectionManager, ) { super(); @@ -194,6 +200,7 @@ export class KernelAndTerminalPanelView extends BaseView { this.libroKernelManager = libroKernelManager; this.libroSessionManager = libroSessionManager; this.terminalManager = terminalManager; + this.lspConnectionManager = lspDocumentConnectionManager; this.lspManager = lspDocumentConnectionManager.languageServerManager; } diff --git a/packages/libro-lab/tsconfig.json b/packages/libro-lab/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-lab/tsconfig.json +++ b/packages/libro-lab/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-lsp/src/connection-manager.ts b/packages/libro-lsp/src/connection-manager.ts index ea797da1..fbcadf28 100644 --- a/packages/libro-lsp/src/connection-manager.ts +++ b/packages/libro-lsp/src/connection-manager.ts @@ -58,14 +58,24 @@ export class DocumentConnectionManager implements ILSPDocumentConnectionManager private _connections: Map = new Map(); - protected disconnectServer(languageServerId: TLanguageServerId): void { + disconnectServer(languageServerId: TLanguageServerId): void { const connection = this._connections.get(languageServerId); if (connection) { connection.close(); this._connections.delete(languageServerId); + this.languageServerManager.refreshRunning(); } } + disconnectAllServers(): void { + this.connections.forEach((connection, languageServerId) => { + connection.close(); + this._connections.delete(languageServerId as TLanguageServerId); + }); + + this.languageServerManager.refreshRunning(); + } + /** * Return (or create and initialize) the WebSocket associated with the language */ diff --git a/packages/libro-lsp/src/manager.ts b/packages/libro-lsp/src/manager.ts index 8dddbfb6..761afc61 100644 --- a/packages/libro-lsp/src/manager.ts +++ b/packages/libro-lsp/src/manager.ts @@ -44,16 +44,7 @@ export class LanguageServerManager implements ILanguageServerManager { } async refreshRunning() { - // TODO: refreshRunning - } - - async shutdownAll() { - // TODO: shutdownAll - } - - // eslint-disable-next-line @typescript-eslint/no-unused-vars - async shutdown(key: string) { - // TODO: shutdown + this.fetchSessions(); } /** diff --git a/packages/libro-lsp/src/tokens.ts b/packages/libro-lsp/src/tokens.ts index 00cab631..de0ba074 100644 --- a/packages/libro-lsp/src/tokens.ts +++ b/packages/libro-lsp/src/tokens.ts @@ -82,10 +82,6 @@ export type TLanguageId = string; // export const ILanguageServerManager = Symbol('ILanguageServerManager'); export interface ILanguageServerManager extends Disposable { - shutdownAll: () => Promise; - - shutdown: (key: string) => Promise; - refreshRunning: () => Promise; /** @@ -364,6 +360,10 @@ export const ILSPDocumentConnectionManager = Symbol('ILSPDocumentConnectionManag * The LSP connection state manager */ export interface ILSPDocumentConnectionManager { + disconnectServer: (languageServerId: TLanguageServerId) => void; + + disconnectAllServers: () => void; + /** * The mapping of document uri to the connection to language server. */ diff --git a/packages/libro-lsp/tsconfig.json b/packages/libro-lsp/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-lsp/tsconfig.json +++ b/packages/libro-lsp/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-markdown-cell/tsconfig.json b/packages/libro-markdown-cell/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-markdown-cell/tsconfig.json +++ b/packages/libro-markdown-cell/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-markdown/tsconfig.json b/packages/libro-markdown/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-markdown/tsconfig.json +++ b/packages/libro-markdown/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-output/tsconfig.json b/packages/libro-output/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-output/tsconfig.json +++ b/packages/libro-output/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-prompt-cell/tsconfig.json b/packages/libro-prompt-cell/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-prompt-cell/tsconfig.json +++ b/packages/libro-prompt-cell/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-raw-cell/tsconfig.json b/packages/libro-raw-cell/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-raw-cell/tsconfig.json +++ b/packages/libro-raw-cell/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-rendermime/tsconfig.json b/packages/libro-rendermime/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-rendermime/tsconfig.json +++ b/packages/libro-rendermime/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-search-code-cell/tsconfig.json b/packages/libro-search-code-cell/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-search-code-cell/tsconfig.json +++ b/packages/libro-search-code-cell/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-search/tsconfig.json b/packages/libro-search/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-search/tsconfig.json +++ b/packages/libro-search/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-shared-model/tsconfig.json b/packages/libro-shared-model/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-shared-model/tsconfig.json +++ b/packages/libro-shared-model/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-terminal/tsconfig.json b/packages/libro-terminal/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-terminal/tsconfig.json +++ b/packages/libro-terminal/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-toc/tsconfig.json b/packages/libro-toc/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-toc/tsconfig.json +++ b/packages/libro-toc/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-virtualized/tsconfig.json b/packages/libro-virtualized/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-virtualized/tsconfig.json +++ b/packages/libro-virtualized/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] } diff --git a/packages/libro-widget/tsconfig.json b/packages/libro-widget/tsconfig.json index dff20382..c9da781c 100644 --- a/packages/libro-widget/tsconfig.json +++ b/packages/libro-widget/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "es", - "declarationDir": "es", + "declarationDir": "es" }, "types": ["jest"], "exclude": ["node_modules"], - "include": ["src"], + "include": ["src"] }