remove configFile from LanguageDescription

This commit is contained in:
Qiming Zhao 2021-12-25 18:33:00 +08:00
parent 8f96c72ad3
commit cd7c05d4a2
No known key found for this signature in database
GPG key ID: 9722CD0E8D4DCB8C
4 changed files with 25 additions and 25 deletions

View file

@ -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 path from 'path'
import { Disposable, Location } from 'vscode-languageserver-protocol'
import TypeScriptServiceClient from '../typescriptServiceClient' import TypeScriptServiceClient from '../typescriptServiceClient'
const countRegex = /Found\s+(\d+)\s+error/ const countRegex = /Found\s+(\d+)\s+error/
const errorRegex = /^(.+)\((\d+),(\d+)\):\s(\w+)\sTS(\d+):\s*(.+)$/ 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 { export default class WatchProject implements Disposable {
private disposables: Disposable[] = [] private disposables: Disposable[] = []
public static readonly id: string = 'tsserver.watchBuild' public static readonly id: string = 'tsserver.watchBuild'
@ -119,7 +105,7 @@ export default class WatchProject implements Disposable {
return return
} }
const tsconfigPath = workspace.getConfiguration('tsserver').get<string>('tsconfigPath', 'tsconfig.json'); const tsconfigPath = workspace.getConfiguration('tsserver').get<string>('tsconfigPath', 'tsconfig.json')
let find = await workspace.findUp([tsconfigPath]) let find = await workspace.findUp([tsconfigPath])
if (!find) { if (!find) {
window.showMessage(`${tsconfigPath} not found!`, 'error') window.showMessage(`${tsconfigPath} not found!`, 'error')

View file

@ -19,17 +19,17 @@ import FormattingProvider from './features/formatting'
import HoverProvider from './features/hover' import HoverProvider from './features/hover'
import ImplementationsCodeLensProvider from './features/implementationsCodeLens' import ImplementationsCodeLensProvider from './features/implementationsCodeLens'
import ImportfixProvider from './features/importFix' import ImportfixProvider from './features/importFix'
import TypeScriptInlayHintsProvider from './features/inlayHints'
import InstallModuleProvider from './features/moduleInstall' import InstallModuleProvider from './features/moduleInstall'
import QuickfixProvider from './features/quickfix' import QuickfixProvider from './features/quickfix'
import RefactorProvider from './features/refactor' import RefactorProvider from './features/refactor'
import ReferenceProvider from './features/references' import ReferenceProvider from './features/references'
import ReferencesCodeLensProvider from './features/referencesCodeLens' import ReferencesCodeLensProvider from './features/referencesCodeLens'
import RenameProvider from './features/rename' import RenameProvider from './features/rename'
import SignatureHelpProvider from './features/signatureHelp'
import SemanticTokensProvider from './features/semanticTokens' import SemanticTokensProvider from './features/semanticTokens'
import SignatureHelpProvider from './features/signatureHelp'
import SmartSelection from './features/smartSelect' import SmartSelection from './features/smartSelect'
import TagClosing from './features/tagClosing' import TagClosing from './features/tagClosing'
import TypeScriptInlayHintsProvider from './features/inlayHints'
import UpdateImportsOnFileRenameHandler from './features/updatePathOnRename' import UpdateImportsOnFileRenameHandler from './features/updatePathOnRename'
import { OrganizeImportsCodeActionProvider } from './organizeImports' import { OrganizeImportsCodeActionProvider } from './organizeImports'
import TypeScriptServiceClient from './typescriptServiceClient' import TypeScriptServiceClient from './typescriptServiceClient'

View file

@ -3,13 +3,14 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as languageModeIds from './languageModeIds' import * as languageModeIds from './languageModeIds'
import path from 'path'
import { Uri } from 'coc.nvim'
export interface LanguageDescription { export interface LanguageDescription {
readonly id: string readonly id: string
readonly diagnosticSource: string readonly diagnosticSource: string
readonly diagnosticLanguage: DiagnosticLanguage readonly diagnosticLanguage: DiagnosticLanguage
readonly modeIds: string[] readonly modeIds: string[]
readonly configFile?: string
readonly isExternal?: boolean readonly isExternal?: boolean
readonly diagnosticOwner: string readonly diagnosticOwner: string
readonly configFilePattern?: RegExp readonly configFilePattern?: RegExp
@ -26,10 +27,8 @@ export const standardLanguageDescriptions: LanguageDescription[] = [
id: 'typescript', id: 'typescript',
diagnosticSource: 'ts', diagnosticSource: 'ts',
diagnosticOwner: 'typescript', diagnosticOwner: 'typescript',
modeIds: [languageModeIds.typescript, languageModeIds.typescriptreact,
languageModeIds.typescripttsx, languageModeIds.typescriptjsx],
diagnosticLanguage: DiagnosticLanguage.TypeScript, diagnosticLanguage: DiagnosticLanguage.TypeScript,
configFile: 'tsconfig.json', modeIds: [languageModeIds.typescript, languageModeIds.typescriptreact, languageModeIds.typescripttsx, languageModeIds.typescriptjsx],
configFilePattern: /^tsconfig(\..*)?\.json$/gi, configFilePattern: /^tsconfig(\..*)?\.json$/gi,
standardFileExtensions: [ standardFileExtensions: [
'ts', 'ts',
@ -42,9 +41,7 @@ export const standardLanguageDescriptions: LanguageDescription[] = [
id: 'javascript', id: 'javascript',
diagnosticSource: 'ts', diagnosticSource: 'ts',
diagnosticOwner: 'typescript', diagnosticOwner: 'typescript',
modeIds: [languageModeIds.javascript, languageModeIds.javascriptreact, languageModeIds.javascriptjsx], modeIds: [languageModeIds.javascript, languageModeIds.javascriptreact, languageModeIds.javascriptjsx], diagnosticLanguage: DiagnosticLanguage.JavaScript,
diagnosticLanguage: DiagnosticLanguage.JavaScript,
configFile: 'jsconfig.json',
configFilePattern: /^jsconfig(\..*)?\.json$/gi, configFilePattern: /^jsconfig(\..*)?\.json$/gi,
standardFileExtensions: [ standardFileExtensions: [
'js', '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)
}

View file

@ -8,6 +8,7 @@
"allowUnreachableCode": true, "allowUnreachableCode": true,
"allowUnusedLabels": true, "allowUnusedLabels": true,
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"noEmit": true,
"noImplicitAny": false, "noImplicitAny": false,
"noImplicitReturns": false, "noImplicitReturns": false,
"noUnusedLocals": false, "noUnusedLocals": false,