diff --git a/src/server/features/watchBuild.ts b/src/server/features/watchBuild.ts index ea40c7b..7ea12c3 100644 --- a/src/server/features/watchBuild.ts +++ b/src/server/features/watchBuild.ts @@ -1,24 +1,10 @@ -import { commands, disposeAll, StatusBarItem, TaskOptions, Uri, window, workspace } from 'coc.nvim' +import { commands, Disposable, disposeAll, StatusBarItem, TaskOptions, Uri, window, workspace } from 'coc.nvim' import path from 'path' -import { Disposable, Location } from 'vscode-languageserver-protocol' import TypeScriptServiceClient from '../typescriptServiceClient' const countRegex = /Found\s+(\d+)\s+error/ const errorRegex = /^(.+)\((\d+),(\d+)\):\s(\w+)\sTS(\d+):\s*(.+)$/ -interface ErrorItem { - location: Location - text: string - type: string -} - -enum TscStatus { - INIT, - COMPILING, - RUNNING, - ERROR, -} - export default class WatchProject implements Disposable { private disposables: Disposable[] = [] public static readonly id: string = 'tsserver.watchBuild' @@ -119,7 +105,7 @@ export default class WatchProject implements Disposable { return } - const tsconfigPath = workspace.getConfiguration('tsserver').get('tsconfigPath', 'tsconfig.json'); + const tsconfigPath = workspace.getConfiguration('tsserver').get('tsconfigPath', 'tsconfig.json') let find = await workspace.findUp([tsconfigPath]) if (!find) { window.showMessage(`${tsconfigPath} not found!`, 'error') diff --git a/src/server/languageProvider.ts b/src/server/languageProvider.ts index 58a431d..70d6230 100644 --- a/src/server/languageProvider.ts +++ b/src/server/languageProvider.ts @@ -19,17 +19,17 @@ import FormattingProvider from './features/formatting' import HoverProvider from './features/hover' import ImplementationsCodeLensProvider from './features/implementationsCodeLens' import ImportfixProvider from './features/importFix' +import TypeScriptInlayHintsProvider from './features/inlayHints' import InstallModuleProvider from './features/moduleInstall' import QuickfixProvider from './features/quickfix' import RefactorProvider from './features/refactor' import ReferenceProvider from './features/references' import ReferencesCodeLensProvider from './features/referencesCodeLens' import RenameProvider from './features/rename' -import SignatureHelpProvider from './features/signatureHelp' import SemanticTokensProvider from './features/semanticTokens' +import SignatureHelpProvider from './features/signatureHelp' import SmartSelection from './features/smartSelect' import TagClosing from './features/tagClosing' -import TypeScriptInlayHintsProvider from './features/inlayHints' import UpdateImportsOnFileRenameHandler from './features/updatePathOnRename' import { OrganizeImportsCodeActionProvider } from './organizeImports' import TypeScriptServiceClient from './typescriptServiceClient' diff --git a/src/server/utils/languageDescription.ts b/src/server/utils/languageDescription.ts index c3a09af..a796a9a 100644 --- a/src/server/utils/languageDescription.ts +++ b/src/server/utils/languageDescription.ts @@ -3,13 +3,14 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import * as languageModeIds from './languageModeIds' +import path from 'path' +import { Uri } from 'coc.nvim' export interface LanguageDescription { readonly id: string readonly diagnosticSource: string readonly diagnosticLanguage: DiagnosticLanguage readonly modeIds: string[] - readonly configFile?: string readonly isExternal?: boolean readonly diagnosticOwner: string readonly configFilePattern?: RegExp @@ -26,10 +27,8 @@ export const standardLanguageDescriptions: LanguageDescription[] = [ id: 'typescript', diagnosticSource: 'ts', diagnosticOwner: 'typescript', - modeIds: [languageModeIds.typescript, languageModeIds.typescriptreact, - languageModeIds.typescripttsx, languageModeIds.typescriptjsx], diagnosticLanguage: DiagnosticLanguage.TypeScript, - configFile: 'tsconfig.json', + modeIds: [languageModeIds.typescript, languageModeIds.typescriptreact, languageModeIds.typescripttsx, languageModeIds.typescriptjsx], configFilePattern: /^tsconfig(\..*)?\.json$/gi, standardFileExtensions: [ 'ts', @@ -42,9 +41,7 @@ export const standardLanguageDescriptions: LanguageDescription[] = [ id: 'javascript', diagnosticSource: 'ts', diagnosticOwner: 'typescript', - modeIds: [languageModeIds.javascript, languageModeIds.javascriptreact, languageModeIds.javascriptjsx], - diagnosticLanguage: DiagnosticLanguage.JavaScript, - configFile: 'jsconfig.json', + modeIds: [languageModeIds.javascript, languageModeIds.javascriptreact, languageModeIds.javascriptjsx], diagnosticLanguage: DiagnosticLanguage.JavaScript, configFilePattern: /^jsconfig(\..*)?\.json$/gi, standardFileExtensions: [ 'js', @@ -56,3 +53,19 @@ export const standardLanguageDescriptions: LanguageDescription[] = [ ] } ] + +export function isTsConfigFileName(fileName: string): boolean { + return /^tsconfig\.(.+\.)?json$/i.test(path.basename(fileName)) +} + +export function isJsConfigOrTsConfigFileName(fileName: string): boolean { + return /^[jt]sconfig\.(.+\.)?json$/i.test(path.basename(fileName)) +} + +export function doesResourceLookLikeATypeScriptFile(resource: Uri): boolean { + return /\.(tsx?|mts|cts)$/i.test(resource.fsPath) +} + +export function doesResourceLookLikeAJavaScriptFile(resource: Uri): boolean { + return /\.(jsx?|mjs|cjs)$/i.test(resource.fsPath) +} diff --git a/tsconfig.json b/tsconfig.json index 6464e65..40d3beb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,6 +8,7 @@ "allowUnreachableCode": true, "allowUnusedLabels": true, "forceConsistentCasingInFileNames": true, + "noEmit": true, "noImplicitAny": false, "noImplicitReturns": false, "noUnusedLocals": false,