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 { 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<string>('tsconfigPath', 'tsconfig.json');
const tsconfigPath = workspace.getConfiguration('tsserver').get<string>('tsconfigPath', 'tsconfig.json')
let find = await workspace.findUp([tsconfigPath])
if (!find) {
window.showMessage(`${tsconfigPath} not found!`, 'error')

View file

@ -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'

View file

@ -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)
}

View file

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