use next release of coc.nvim
This commit is contained in:
parent
a98c4808f8
commit
954e292f2f
39 changed files with 181 additions and 3337 deletions
13
package.json
13
package.json
|
@ -17,9 +17,8 @@
|
|||
"typescript"
|
||||
],
|
||||
"scripts": {
|
||||
"clean": "rimraf lib",
|
||||
"build": "webpack",
|
||||
"prepare": "webpack"
|
||||
"build": "npx webpack",
|
||||
"prepare": "npx webpack"
|
||||
},
|
||||
"activationEvents": [
|
||||
"onLanguage:javascript",
|
||||
|
@ -623,17 +622,13 @@
|
|||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "^10.12.0",
|
||||
"coc.nvim": "^0.0.79",
|
||||
"rimraf": "^3.0.2",
|
||||
"coc.nvim": "^0.0.79-next.18",
|
||||
"semver": "^7.3.2",
|
||||
"ts-loader": "^8.0.1",
|
||||
"vscode-languageserver-protocol": "^3.15.3",
|
||||
"vscode-languageserver-textdocument": "^1.0.1",
|
||||
"webpack": "^4.43.0",
|
||||
"webpack-cli": "^3.3.12",
|
||||
"which": "^2.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"typescript": "4.1.2"
|
||||
"typescript": "^4.1.3"
|
||||
}
|
||||
}
|
||||
|
|
22
src/index.ts
22
src/index.ts
|
@ -24,20 +24,20 @@ export async function activate(context: ExtensionContext): Promise<API> {
|
|||
registCommand(new OpenTsServerLogCommand(service))
|
||||
registCommand(new TypeScriptGoToProjectConfigCommand(service))
|
||||
registCommand(new OrganizeImportsCommand(service))
|
||||
registCommand({
|
||||
id: 'tsserver.restart',
|
||||
execute: (): void => {
|
||||
// tslint:disable-next-line:no-floating-promises
|
||||
service.stop().then(() => {
|
||||
setTimeout(() => {
|
||||
service.restart()
|
||||
}, 100)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
service.start().then(() => {
|
||||
subscriptions.push(services.regist(service))
|
||||
registCommand(commands.register({
|
||||
id: 'tsserver.restart',
|
||||
execute: (): void => {
|
||||
// tslint:disable-next-line:no-floating-promises
|
||||
service.stop().then(() => {
|
||||
setTimeout(() => {
|
||||
service.restart()
|
||||
}, 100)
|
||||
})
|
||||
}
|
||||
}))
|
||||
}, e => {
|
||||
logger.error(`Error on service start:`, e)
|
||||
})
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import { Uri as URI, diagnosticManager, workspace, commands, ServiceStat } from 'coc.nvim'
|
||||
import { CancellationToken, Diagnostic } from 'vscode-languageserver-protocol'
|
||||
import { commands, diagnosticManager, CancellationToken, Diagnostic, Disposable, ServiceStat, Uri as URI, window, workspace } from 'coc.nvim'
|
||||
import { Range, TextEdit } from 'vscode-languageserver-types'
|
||||
import TsserverService from '../server'
|
||||
import { PluginManager } from '../utils/plugins'
|
||||
import * as Proto from './protocol'
|
||||
import TypeScriptServiceClientHost from './typescriptServiceClientHost'
|
||||
import * as typeConverters from './utils/typeConverters'
|
||||
import { TextEdit, Range } from 'vscode-languageserver-types'
|
||||
import { installModules } from './utils/modules'
|
||||
import { nodeModules } from './utils/helper'
|
||||
import { PluginManager } from '../utils/plugins'
|
||||
import TsserverService from '../server'
|
||||
import { installModules } from './utils/modules'
|
||||
import * as typeConverters from './utils/typeConverters'
|
||||
|
||||
export interface Command {
|
||||
readonly id: string | string[]
|
||||
|
@ -19,12 +18,12 @@ export class ReloadProjectsCommand implements Command {
|
|||
|
||||
public constructor(
|
||||
private readonly service: TsserverService
|
||||
) { }
|
||||
) {}
|
||||
|
||||
public async execute(): Promise<void> {
|
||||
let client = await this.service.getClientHost()
|
||||
client.reloadProjects()
|
||||
workspace.showMessage('projects reloaded')
|
||||
window.showMessage('projects reloaded')
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +32,7 @@ export class OpenTsServerLogCommand implements Command {
|
|||
|
||||
public constructor(
|
||||
private readonly service: TsserverService
|
||||
) { }
|
||||
) {}
|
||||
|
||||
public async execute(): Promise<void> {
|
||||
let client = await this.service.getClientHost()
|
||||
|
@ -46,7 +45,7 @@ export class TypeScriptGoToProjectConfigCommand implements Command {
|
|||
|
||||
public constructor(
|
||||
private readonly service: TsserverService
|
||||
) { }
|
||||
) {}
|
||||
|
||||
public async execute(): Promise<void> {
|
||||
let client = await this.service.getClientHost()
|
||||
|
@ -70,7 +69,7 @@ async function goToProjectConfig(clientHost: TypeScriptServiceClientHost, uri: s
|
|||
// noop
|
||||
}
|
||||
if (!res || !res.body) {
|
||||
workspace.showMessage('Could not determine TypeScript or JavaScript project.', 'warning')
|
||||
window.showMessage('Could not determine TypeScript or JavaScript project.', 'warning')
|
||||
return
|
||||
}
|
||||
const { configFileName } = res.body
|
||||
|
@ -78,7 +77,7 @@ async function goToProjectConfig(clientHost: TypeScriptServiceClientHost, uri: s
|
|||
await workspace.openResource(URI.file(configFileName).toString())
|
||||
return
|
||||
}
|
||||
workspace.showMessage('Config file not found', 'warning')
|
||||
window.showMessage('Config file not found', 'warning')
|
||||
}
|
||||
|
||||
function isImplicitProjectConfigFile(configFileName: string): boolean {
|
||||
|
@ -110,7 +109,7 @@ export class AutoFixCommand implements Command {
|
|||
return
|
||||
}
|
||||
let file = client.serviceClient.toPath(document.uri)
|
||||
let diagnostics = diagnosticManager.getDiagnostics(document.uri)
|
||||
let diagnostics = diagnosticManager.getDiagnostics(document.uri).slice() as Diagnostic[]
|
||||
let missingDiagnostics = diagnostics.filter(o => o.code == 2307)
|
||||
if (missingDiagnostics.length) {
|
||||
let names = missingDiagnostics.map(o => {
|
||||
|
@ -178,9 +177,14 @@ export class ConfigurePluginCommand implements Command {
|
|||
|
||||
public constructor(
|
||||
private readonly pluginManager: PluginManager,
|
||||
) { }
|
||||
) {}
|
||||
|
||||
public execute(pluginId: string, configuration: any): void {
|
||||
this.pluginManager.setConfiguration(pluginId, configuration)
|
||||
}
|
||||
}
|
||||
|
||||
export function registCommand(cmd: Command): Disposable {
|
||||
let { id, execute } = cmd
|
||||
return commands.registerCommand(id as string, execute, cmd)
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { TextDocument } from 'coc.nvim'
|
||||
import { CodeLensProvider } from 'coc.nvim'
|
||||
import { CancellationToken, CodeLens, Emitter, Event, Range } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { CodeLensProvider } from 'coc.nvim/lib/provider'
|
||||
import * as Proto from '../protocol'
|
||||
import { ITypeScriptServiceClient } from '../typescriptService'
|
||||
import { escapeRegExp } from '../utils/regexp'
|
||||
|
@ -47,7 +47,7 @@ export abstract class TypeScriptBaseCodeLensProvider implements CodeLensProvider
|
|||
public constructor(
|
||||
protected client: ITypeScriptServiceClient,
|
||||
private cachedResponse: CachedNavTreeResponse
|
||||
) { }
|
||||
) {}
|
||||
|
||||
public get onDidChangeCodeLenses(): Event<void> {
|
||||
return this.onDidChangeCodeLensesEmitter.event
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
import { Uri, disposeAll, workspace } from 'coc.nvim'
|
||||
import { CancellationTokenSource, CancellationToken, Emitter, Event, DidChangeTextDocumentParams, Disposable, TextDocumentContentChangeEvent } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { TextDocument } from 'coc.nvim'
|
||||
import Proto from '../protocol'
|
||||
import { ITypeScriptServiceClient } from '../typescriptService'
|
||||
import API from '../utils/api'
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
import { commands, CompletionItemProvider, TextDocument, window, workspace } from 'coc.nvim'
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { CancellationToken, Command, CompletionContext, Range, CompletionItem, InsertTextFormat, MarkupContent, MarkupKind, Position, TextEdit, CompletionList } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { commands, workspace } from 'coc.nvim'
|
||||
import { CompletionItemProvider } from 'coc.nvim/lib/provider'
|
||||
import { CancellationToken, Command, CompletionContext, CompletionItem, CompletionList, InsertTextFormat, MarkupContent, MarkupKind, Position, Range, TextEdit } from 'vscode-languageserver-protocol'
|
||||
import Proto from '../protocol'
|
||||
import * as PConst from '../protocol.const'
|
||||
import { ITypeScriptServiceClient, ServerResponse } from '../typescriptService'
|
||||
import API from '../utils/api'
|
||||
import { applyCodeAction } from '../utils/codeAction'
|
||||
import { DotAccessorContext, convertCompletionEntry, getParameterListParts } from '../utils/completionItem'
|
||||
import { convertCompletionEntry, DotAccessorContext, getParameterListParts } from '../utils/completionItem'
|
||||
import * as Previewer from '../utils/previewer'
|
||||
import SnippetString from '../utils/SnippetString'
|
||||
import * as typeConverters from '../utils/typeConverters'
|
||||
import TypingsStatus from '../utils/typingsStatus'
|
||||
import FileConfigurationManager, { SuggestOptions } from './fileConfigurationManager'
|
||||
import SnippetString from '../utils/SnippetString'
|
||||
|
||||
// command center
|
||||
export interface CommandItem {
|
||||
|
@ -41,7 +39,7 @@ class ApplyCompletionCodeActionCommand implements CommandItem {
|
|||
await applyCodeAction(this.client, codeActions[0])
|
||||
return
|
||||
}
|
||||
const idx = await workspace.showQuickpick(codeActions.map(o => o.description), 'Select code action to apply')
|
||||
const idx = await window.showQuickpick(codeActions.map(o => o.description), 'Select code action to apply')
|
||||
if (idx < 0) return
|
||||
const action = codeActions[idx]
|
||||
await applyCodeAction(this.client, action)
|
||||
|
@ -62,7 +60,10 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP
|
|||
) {
|
||||
|
||||
this.setCompleteOption(languageId)
|
||||
commands.register(new ApplyCompletionCodeActionCommand(this.client))
|
||||
commands.registerCommand(ApplyCompletionCodeActionCommand.ID, async (codeActions) => {
|
||||
let cmd = new ApplyCompletionCodeActionCommand(this.client)
|
||||
await cmd.execute(codeActions)
|
||||
})
|
||||
workspace.onDidChangeConfiguration(_e => {
|
||||
this.setCompleteOption(languageId)
|
||||
})
|
||||
|
|
|
@ -2,15 +2,15 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { TextDocument } from 'coc.nvim'
|
||||
import { DefinitionProvider, ImplementationProvider, TypeDefinitionProvider } from 'coc.nvim'
|
||||
import { CancellationToken, Definition, Location, Position } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { DefinitionProvider, ImplementationProvider, TypeDefinitionProvider } from 'coc.nvim/lib/provider'
|
||||
import * as Proto from '../protocol'
|
||||
import { ITypeScriptServiceClient } from '../typescriptService'
|
||||
import * as typeConverters from '../utils/typeConverters'
|
||||
|
||||
export default class TypeScriptDefinitionProvider implements DefinitionProvider, TypeDefinitionProvider, ImplementationProvider {
|
||||
constructor(private client: ITypeScriptServiceClient) { }
|
||||
constructor(private client: ITypeScriptServiceClient) {}
|
||||
|
||||
protected async getSymbolLocations(
|
||||
definitionType: 'definition' | 'implementation' | 'typeDefinition',
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { DiagnosticCollection, languages, workspace } from 'coc.nvim'
|
||||
import { Diagnostic } from 'vscode-languageserver-protocol'
|
||||
import { workspace, languages, DiagnosticCollection } from 'coc.nvim'
|
||||
import { ResourceMap } from './resourceMap'
|
||||
|
||||
export class DiagnosticSet {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { CancellationToken, CompletionContext, CompletionItem, CompletionItemKind, CompletionList, Position, Range } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { TextDocument } from 'coc.nvim'
|
||||
import { workspace } from 'coc.nvim'
|
||||
import { ITypeScriptServiceClient } from '../typescriptService'
|
||||
import API from '../utils/api'
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { TextDocument } from 'coc.nvim'
|
||||
import { DocumentHighlightProvider } from 'coc.nvim'
|
||||
import { CancellationToken, DocumentHighlight, DocumentHighlightKind, Position } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { DocumentHighlightProvider } from 'coc.nvim/lib/provider'
|
||||
import { flatten } from '../../utils/arrays'
|
||||
import Proto from '../protocol'
|
||||
import { ITypeScriptServiceClient } from '../typescriptService'
|
||||
import * as typeConverters from '../utils/typeConverters'
|
||||
import { flatten } from '../../utils/arrays'
|
||||
|
||||
export default class TypeScriptDocumentHighlightProvider implements DocumentHighlightProvider {
|
||||
public constructor(private readonly client: ITypeScriptServiceClient) { }
|
||||
public constructor(private readonly client: ITypeScriptServiceClient) {}
|
||||
|
||||
public async provideDocumentHighlights(
|
||||
resource: TextDocument,
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { TextDocument } from 'coc.nvim'
|
||||
import { DocumentSymbolProvider } from 'coc.nvim'
|
||||
import { CancellationToken, DocumentSymbol, Range, SymbolKind } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { DocumentSymbolProvider } from 'coc.nvim/lib/provider'
|
||||
import * as Proto from '../protocol'
|
||||
import * as PConst from '../protocol.const'
|
||||
import { ITypeScriptServiceClient } from '../typescriptService'
|
||||
|
@ -46,7 +46,7 @@ const getSymbolKind = (kind: string): SymbolKind => {
|
|||
}
|
||||
|
||||
export default class TypeScriptDocumentSymbolProvider implements DocumentSymbolProvider {
|
||||
public constructor(private readonly client: ITypeScriptServiceClient) { }
|
||||
public constructor(private readonly client: ITypeScriptServiceClient) {}
|
||||
|
||||
public async provideDocumentSymbols(
|
||||
resource: TextDocument,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
import { workspace, WorkspaceConfiguration, disposeAll } from 'coc.nvim'
|
||||
import { CancellationToken, Disposable } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { TextDocument } from 'coc.nvim'
|
||||
import Proto from '../protocol'
|
||||
import { ITypeScriptServiceClient } from '../typescriptService'
|
||||
import API from '../utils/api'
|
||||
|
|
|
@ -3,17 +3,16 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { TextDocument, workspace } from 'coc.nvim'
|
||||
import { FoldingContext, FoldingRangeProvider } from 'coc.nvim'
|
||||
import { CancellationToken } from 'vscode-jsonrpc'
|
||||
import { FoldingRange } from 'vscode-languageserver-types'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { FoldingContext, FoldingRangeProvider } from 'coc.nvim/lib/provider'
|
||||
import { workspace } from 'coc.nvim'
|
||||
import Proto from '../protocol'
|
||||
import { ITypeScriptServiceClient } from '../typescriptService'
|
||||
import * as typeConverters from '../utils/typeConverters'
|
||||
|
||||
export default class TypeScriptFoldingProvider implements FoldingRangeProvider {
|
||||
public constructor(private readonly client: ITypeScriptServiceClient) { }
|
||||
public constructor(private readonly client: ITypeScriptServiceClient) {}
|
||||
|
||||
public async provideFoldingRanges(
|
||||
document: TextDocument,
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { workspace } from 'coc.nvim'
|
||||
import { DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider } from 'coc.nvim/lib/provider'
|
||||
import { TextDocument, workspace } from 'coc.nvim'
|
||||
import { DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider } from 'coc.nvim'
|
||||
import { CancellationToken, FormattingOptions, Position, Range, TextEdit } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import * as Proto from '../protocol'
|
||||
import { ITypeScriptServiceClient } from '../typescriptService'
|
||||
import * as typeConverters from '../utils/typeConverters'
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { TextDocument } from 'coc.nvim'
|
||||
import { HoverProvider } from 'coc.nvim'
|
||||
import { CancellationToken, Hover, MarkedString, Position } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { HoverProvider } from 'coc.nvim/lib/provider'
|
||||
import * as Proto from '../protocol'
|
||||
import { ITypeScriptServiceClient } from '../typescriptService'
|
||||
import { tagsMarkdownPreview } from '../utils/previewer'
|
||||
import * as typeConverters from '../utils/typeConverters'
|
||||
|
||||
export default class TypeScriptHoverProvider implements HoverProvider {
|
||||
public constructor(private readonly client: ITypeScriptServiceClient) { }
|
||||
public constructor(private readonly client: ITypeScriptServiceClient) {}
|
||||
|
||||
public async provideHover(
|
||||
document: TextDocument,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { CancellationToken, CodeLens, Command, Location, Range } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { TextDocument } from 'coc.nvim'
|
||||
import * as Proto from '../protocol'
|
||||
import * as PConst from '../protocol.const'
|
||||
import * as typeConverters from '../utils/typeConverters'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { CodeActionProvider, workspace } from 'coc.nvim'
|
||||
import BufferSyncSupport from './bufferSyncSupport'
|
||||
import { Range, CodeActionContext, CancellationToken, CodeAction } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { TextDocument } from 'coc.nvim'
|
||||
import { nodeModules } from '../utils/helper'
|
||||
import { WorkspaceEdit, Command, TextEdit } from 'vscode-languageserver-types'
|
||||
|
||||
|
|
|
@ -1,27 +1,14 @@
|
|||
import { Uri, commands } from 'coc.nvim'
|
||||
import { Command } from 'coc.nvim/lib/commands'
|
||||
import { CodeActionProvider } from 'coc.nvim/lib/provider'
|
||||
import { CodeActionProvider, commands, TextDocument, Uri } from 'coc.nvim'
|
||||
import { CancellationToken, CodeAction, CodeActionContext, CodeActionKind, Range } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { ITypeScriptServiceClient } from '../typescriptService'
|
||||
import { installModules } from '../utils/modules'
|
||||
|
||||
class InstallModuleCommand implements Command {
|
||||
public static readonly ID = '_tsserver.installModule'
|
||||
public readonly id = InstallModuleCommand.ID
|
||||
|
||||
public async execute(
|
||||
uri: string,
|
||||
name: string
|
||||
): Promise<void> {
|
||||
await installModules(uri, [name])
|
||||
}
|
||||
}
|
||||
|
||||
export default class InstallModuleProvider implements CodeActionProvider {
|
||||
|
||||
constructor(private readonly client: ITypeScriptServiceClient) {
|
||||
commands.register(new InstallModuleCommand(), true)
|
||||
commands.registerCommand('_tsserver.installModule', async (uri: string, name: string) => {
|
||||
await installModules(uri, [name])
|
||||
})
|
||||
}
|
||||
|
||||
public async provideCodeActions(
|
||||
|
@ -45,7 +32,7 @@ export default class InstallModuleProvider implements CodeActionProvider {
|
|||
let title = `install ${name}`
|
||||
let command = {
|
||||
title: `install ${name}`,
|
||||
command: InstallModuleCommand.ID,
|
||||
command: '_tsserver.installModule',
|
||||
arguments: [document.uri, name]
|
||||
}
|
||||
let codeAction = CodeAction.create(title, command, CodeActionKind.QuickFix)
|
||||
|
|
|
@ -2,11 +2,9 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { commands, workspace } from 'coc.nvim'
|
||||
import { Command } from 'coc.nvim/lib/commands'
|
||||
import { CodeActionProvider } from 'coc.nvim/lib/provider'
|
||||
import { CodeActionProvider, TextDocument, workspace } from 'coc.nvim'
|
||||
import { CancellationToken, CodeAction, CodeActionContext, CodeActionKind, Diagnostic, Range } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { Command, registCommand } from '../commands'
|
||||
import * as Proto from '../protocol'
|
||||
import { ITypeScriptServiceClient } from '../typescriptService'
|
||||
import API from '../utils/api'
|
||||
|
@ -21,7 +19,7 @@ class ApplyCodeActionCommand implements Command {
|
|||
constructor(
|
||||
private readonly client: ITypeScriptServiceClient,
|
||||
private readonly formattingConfigurationManager: FileConfigurationManager
|
||||
) { }
|
||||
) {}
|
||||
|
||||
public async execute(action: Proto.CodeFixAction): Promise<boolean> {
|
||||
return applyCodeActionCommands(this.client, action)
|
||||
|
@ -35,7 +33,7 @@ class ApplyFixAllCodeAction implements Command {
|
|||
constructor(
|
||||
private readonly client: ITypeScriptServiceClient,
|
||||
private readonly formattingConfigurationManager: FileConfigurationManager
|
||||
) { }
|
||||
) {}
|
||||
|
||||
public async execute(
|
||||
document: TextDocument,
|
||||
|
@ -100,7 +98,7 @@ class DiagnosticsSet {
|
|||
|
||||
private constructor(
|
||||
private readonly _values: Map<string, Diagnostic>
|
||||
) { }
|
||||
) {}
|
||||
|
||||
public get values(): Iterable<Diagnostic> {
|
||||
return this._values.values()
|
||||
|
@ -110,7 +108,7 @@ class DiagnosticsSet {
|
|||
class SupportedCodeActionProvider {
|
||||
private _supportedCodeActions?: Thenable<Set<number>>
|
||||
|
||||
public constructor(private readonly client: ITypeScriptServiceClient) { }
|
||||
public constructor(private readonly client: ITypeScriptServiceClient) {}
|
||||
|
||||
public async getFixableDiagnosticsForContext(
|
||||
context: CodeActionContext
|
||||
|
@ -148,13 +146,8 @@ export default class TypeScriptQuickFixProvider implements CodeActionProvider {
|
|||
private readonly client: ITypeScriptServiceClient,
|
||||
private readonly formattingConfigurationManager: FileConfigurationManager
|
||||
) {
|
||||
commands.register(
|
||||
new ApplyCodeActionCommand(client, formattingConfigurationManager)
|
||||
)
|
||||
commands.register(
|
||||
new ApplyFixAllCodeAction(client, formattingConfigurationManager)
|
||||
)
|
||||
|
||||
registCommand(new ApplyCodeActionCommand(client, formattingConfigurationManager))
|
||||
registCommand(new ApplyFixAllCodeAction(client, formattingConfigurationManager))
|
||||
this.supportedCodeActionProvider = new SupportedCodeActionProvider(client)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
import { CodeActionProvider, CodeActionProviderMetadata, commands, TextDocument, window, workspace } from 'coc.nvim'
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { CancellationToken, CodeAction, CodeActionContext, CodeActionKind, Range, WorkspaceEdit } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { Command } from 'coc.nvim/lib/commands'
|
||||
import { CodeActionProvider, CodeActionProviderMetadata } from 'coc.nvim/lib/provider'
|
||||
import { workspace, commands } from 'coc.nvim'
|
||||
import { Command, registCommand } from '../commands'
|
||||
import Proto from '../protocol'
|
||||
import { ITypeScriptServiceClient } from '../typescriptService'
|
||||
import * as typeConverters from '../utils/typeConverters'
|
||||
|
@ -22,7 +20,7 @@ class ApplyRefactoringCommand implements Command {
|
|||
public static readonly ID = '_typescript.applyRefactoring'
|
||||
public readonly id = ApplyRefactoringCommand.ID
|
||||
|
||||
constructor(private readonly client: ITypeScriptServiceClient) { }
|
||||
constructor(private readonly client: ITypeScriptServiceClient) {}
|
||||
|
||||
public async execute(
|
||||
document: TextDocument,
|
||||
|
@ -72,7 +70,7 @@ class SelectRefactorCommand implements Command {
|
|||
public static readonly ID = '_typescript.selectRefactoring'
|
||||
public readonly id = SelectRefactorCommand.ID
|
||||
|
||||
constructor(private readonly doRefactoring: ApplyRefactoringCommand) { }
|
||||
constructor(private readonly doRefactoring: ApplyRefactoringCommand) {}
|
||||
|
||||
public async execute(
|
||||
document: TextDocument,
|
||||
|
@ -81,7 +79,7 @@ class SelectRefactorCommand implements Command {
|
|||
range: Range
|
||||
): Promise<boolean> {
|
||||
let { actions } = info
|
||||
const idx = actions.length == 1 ? 0 : await workspace.showQuickpick(
|
||||
const idx = actions.length == 1 ? 0 : await window.showQuickpick(
|
||||
actions.map(action => action.description || action.name)
|
||||
)
|
||||
if (idx == -1) return false
|
||||
|
@ -106,10 +104,9 @@ export default class TypeScriptRefactorProvider implements CodeActionProvider {
|
|||
private readonly client: ITypeScriptServiceClient,
|
||||
private readonly formattingOptionsManager: FormattingOptionsManager,
|
||||
) {
|
||||
const doRefactoringCommand = commands.register(
|
||||
new ApplyRefactoringCommand(this.client)
|
||||
)
|
||||
commands.register(new SelectRefactorCommand(doRefactoringCommand))
|
||||
const doRefactoringCommand = new ApplyRefactoringCommand(this.client)
|
||||
registCommand(doRefactoringCommand)
|
||||
registCommand(new SelectRefactorCommand(doRefactoringCommand))
|
||||
}
|
||||
|
||||
public static readonly metadata: CodeActionProviderMetadata = {
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { TextDocument } from 'coc.nvim'
|
||||
import { ReferenceContext, ReferenceProvider } from 'coc.nvim'
|
||||
import { CancellationToken, Location, Position } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { ReferenceContext, ReferenceProvider } from 'coc.nvim/lib/provider'
|
||||
import { ITypeScriptServiceClient } from '../typescriptService'
|
||||
import * as typeConverters from '../utils/typeConverters'
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { CancellationToken, CodeLens, Range } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { TextDocument } from 'coc.nvim'
|
||||
import * as Proto from '../protocol'
|
||||
import * as PConst from '../protocol.const'
|
||||
import * as typeConverters from '../utils/typeConverters'
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
import { Uri, RenameProvider } from 'coc.nvim'
|
||||
import path from 'path'
|
||||
import { CancellationToken, Position, Range, TextEdit, WorkspaceEdit } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { TextDocument } from 'coc.nvim'
|
||||
import * as Proto from '../protocol'
|
||||
import { ITypeScriptServiceClient, ServerResponse } from '../typescriptService'
|
||||
import API from '../utils/api'
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { TextDocument } from 'coc.nvim'
|
||||
import { SignatureHelpProvider } from 'coc.nvim'
|
||||
import { CancellationToken, Position, SignatureHelp, SignatureInformation } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { SignatureHelpProvider } from 'coc.nvim/lib/provider'
|
||||
import * as Proto from '../protocol'
|
||||
import { ITypeScriptServiceClient } from '../typescriptService'
|
||||
import * as Previewer from '../utils/previewer'
|
||||
|
@ -13,7 +13,7 @@ import * as typeConverters from '../utils/typeConverters'
|
|||
export default class TypeScriptSignatureHelpProvider implements SignatureHelpProvider {
|
||||
public static readonly triggerCharacters = ['(', ',', '<']
|
||||
|
||||
public constructor(private readonly client: ITypeScriptServiceClient) { }
|
||||
public constructor(private readonly client: ITypeScriptServiceClient) {}
|
||||
|
||||
public async provideSignatureHelp(
|
||||
document: TextDocument,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import * as Proto from '../protocol'
|
||||
import { ITypeScriptServiceClient } from '../typescriptService'
|
||||
import { Range, Position, CancellationToken } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { TextDocument } from 'coc.nvim'
|
||||
import * as typeConverters from '../utils/typeConverters'
|
||||
import { SelectionRangeProvider } from 'coc.nvim'
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { TextDocument } from 'coc.nvim'
|
||||
import { CompletionItemProvider } from 'coc.nvim'
|
||||
import { CancellationToken, CompletionContext, CompletionItem, Position } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { CompletionItemProvider } from 'coc.nvim/lib/provider'
|
||||
import * as Proto from '../protocol'
|
||||
import { ITypeScriptServiceClient } from '../typescriptService'
|
||||
import * as typeConverters from '../utils/typeConverters'
|
||||
|
@ -12,7 +12,7 @@ import * as typeConverters from '../utils/typeConverters'
|
|||
export default class TypeScriptTagCompletion implements CompletionItemProvider {
|
||||
constructor(
|
||||
private readonly client: ITypeScriptServiceClient
|
||||
) { }
|
||||
) {}
|
||||
|
||||
public async provideCompletionItems(
|
||||
document: TextDocument,
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
import { disposeAll, TextDocument, Uri, window, workspace } from 'coc.nvim'
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { Disposable, WorkspaceEdit, CancellationToken } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { Uri, disposeAll, workspace } from 'coc.nvim'
|
||||
import { CancellationToken, Disposable, WorkspaceEdit } from 'vscode-languageserver-protocol'
|
||||
import * as Proto from '../protocol'
|
||||
import { ITypeScriptServiceClient } from '../typescriptService'
|
||||
import { Mutex } from '../utils/mutex'
|
||||
import * as typeConverters from '../utils/typeConverters'
|
||||
import FileConfigurationManager from './fileConfigurationManager'
|
||||
import { Mutex } from '../utils/mutex'
|
||||
|
||||
function wait(ms: number): Promise<void> {
|
||||
return new Promise(resolve => {
|
||||
|
@ -81,7 +80,7 @@ export default class UpdateImportsOnFileRenameHandler {
|
|||
}
|
||||
|
||||
private async promptUser(newResource: Uri): Promise<boolean> {
|
||||
return await workspace.showPrompt(`Update imports for moved file: ${newResource.fsPath}?`)
|
||||
return await window.showPrompt(`Update imports for moved file: ${newResource.fsPath}?`)
|
||||
}
|
||||
|
||||
private async getEditsForFileRename(document: TextDocument, oldFile: string, newFile: string): Promise<WorkspaceEdit> {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { disposeAll, commands, StatusBarItem, TaskOptions, Uri, workspace } from 'coc.nvim'
|
||||
import { commands, disposeAll, StatusBarItem, TaskOptions, Uri, window, workspace } from 'coc.nvim'
|
||||
import path from 'path'
|
||||
import { Disposable, Location } from 'vscode-languageserver-protocol'
|
||||
import TypeScriptServiceClient from '../typescriptServiceClient'
|
||||
|
@ -30,7 +30,7 @@ export default class WatchProject implements Disposable {
|
|||
public constructor(
|
||||
private client: TypeScriptServiceClient
|
||||
) {
|
||||
this.statusItem = workspace.createStatusBarItem(1, { progress: true })
|
||||
this.statusItem = window.createStatusBarItem(1, { progress: true })
|
||||
let task = this.task = workspace.createTask('TSC')
|
||||
this.disposables.push(commands.registerCommand(WatchProject.id, async () => {
|
||||
let opts = this.options = await this.getOptions()
|
||||
|
@ -38,7 +38,7 @@ export default class WatchProject implements Disposable {
|
|||
}))
|
||||
task.onExit(code => {
|
||||
if (code != 0) {
|
||||
workspace.showMessage(`TSC exit with code ${code}`, 'warning')
|
||||
window.showMessage(`TSC exit with code ${code}`, 'warning')
|
||||
}
|
||||
this.onStop()
|
||||
})
|
||||
|
@ -48,7 +48,7 @@ export default class WatchProject implements Disposable {
|
|||
}
|
||||
})
|
||||
task.onStderr(lines => {
|
||||
workspace.showMessage(`TSC error: ` + lines.join('\n'), 'error')
|
||||
window.showMessage(`TSC error: ` + lines.join('\n'), 'error')
|
||||
})
|
||||
this.disposables.push(Disposable.create(() => {
|
||||
task.dispose()
|
||||
|
@ -114,12 +114,12 @@ export default class WatchProject implements Disposable {
|
|||
public async getOptions(): Promise<TaskOptions> {
|
||||
let { tscPath } = this.client
|
||||
if (!tscPath) {
|
||||
workspace.showMessage(`Local & global tsc not found`, 'error')
|
||||
window.showMessage(`Local & global tsc not found`, 'error')
|
||||
return
|
||||
}
|
||||
let find = await workspace.findUp(['tsconfig.json'])
|
||||
if (!find) {
|
||||
workspace.showMessage('tsconfig.json not found!', 'error')
|
||||
window.showMessage('tsconfig.json not found!', 'error')
|
||||
return
|
||||
}
|
||||
let root = path.dirname(find)
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import {CancellationToken, Range, SymbolInformation, SymbolKind} from 'vscode-languageserver-protocol'
|
||||
import {WorkspaceSymbolProvider} from 'coc.nvim/lib/provider'
|
||||
import {workspace} from 'coc.nvim'
|
||||
import { workspace } from 'coc.nvim'
|
||||
import { WorkspaceSymbolProvider } from 'coc.nvim'
|
||||
import { CancellationToken, Range, SymbolInformation, SymbolKind } from 'vscode-languageserver-protocol'
|
||||
import * as Proto from '../protocol'
|
||||
import {ITypeScriptServiceClient} from '../typescriptService'
|
||||
import * as typeConverters from '../utils/typeConverters'
|
||||
import { ITypeScriptServiceClient } from '../typescriptService'
|
||||
import API from '../utils/api'
|
||||
import * as typeConverters from '../utils/typeConverters'
|
||||
|
||||
function getSymbolKind(item: Proto.NavtoItem): SymbolKind {
|
||||
switch (item.kind) {
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { DiagnosticKind, disposeAll, languages, Uri, workspace } from 'coc.nvim'
|
||||
import { disposeAll, languages, Uri, workspace } from 'coc.nvim'
|
||||
import path from 'path'
|
||||
import { CodeActionKind, Diagnostic, DiagnosticSeverity, Disposable, TextDocument } from 'vscode-languageserver-protocol'
|
||||
import { CachedNavTreeResponse } from './features/baseCodeLensProvider'
|
||||
import CompletionItemProvider from './features/completionItemProvider'
|
||||
import DefinitionProvider from './features/definitionProvider'
|
||||
import { DiagnosticKind } from './features/diagnostics'
|
||||
import DirectiveCommentCompletionProvider from './features/directiveCommentCompletions'
|
||||
import DocumentHighlight from './features/documentHighlight'
|
||||
import DocumentSymbolProvider from './features/documentSymbol'
|
||||
|
|
|
@ -2,15 +2,14 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { workspace, CodeActionProvider, CodeActionProviderMetadata } from 'coc.nvim'
|
||||
import { CancellationToken, Range, CodeActionContext, WorkspaceEdit, CodeActionKind, CodeAction, TextEdit } from 'vscode-languageserver-protocol'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import { Command } from './commands'
|
||||
import Proto from './protocol'
|
||||
import * as typeconverts from './utils/typeConverters'
|
||||
import FileConfigurationManager from './features/fileConfigurationManager'
|
||||
import TypeScriptServiceClient from './typescriptServiceClient'
|
||||
import { CodeActionProvider, CodeActionProviderMetadata, TextDocument, workspace } from 'coc.nvim'
|
||||
import { CancellationToken, CodeAction, CodeActionContext, CodeActionKind, Range, TextEdit, WorkspaceEdit } from 'vscode-languageserver-protocol'
|
||||
import TsserverService from '../server'
|
||||
import { Command } from './commands'
|
||||
import FileConfigurationManager from './features/fileConfigurationManager'
|
||||
import Proto from './protocol'
|
||||
import TypeScriptServiceClient from './typescriptServiceClient'
|
||||
import * as typeconverts from './utils/typeConverters'
|
||||
|
||||
export class OrganizeImportsCommand implements Command {
|
||||
public readonly id: string = 'tsserver.organizeImports'
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import cp from 'child_process'
|
||||
import { disposeAll, ServiceStat, Uri, workspace } from 'coc.nvim'
|
||||
import { ServiceStat, Uri, window, workspace } from 'coc.nvim'
|
||||
import fs from 'fs'
|
||||
import os from 'os'
|
||||
import path from 'path'
|
||||
|
@ -270,7 +270,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
|
|||
public ensureServiceStarted(): void {
|
||||
if (!this.servicePromise) {
|
||||
this.startService().catch(err => {
|
||||
workspace.showMessage(`TSServer start failed: ${err.message}`, 'error')
|
||||
window.showMessage(`TSServer start failed: ${err.message}`, 'error')
|
||||
this.error(`Service start failed: ${err.stack}`)
|
||||
})
|
||||
}
|
||||
|
@ -285,9 +285,9 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
|
|||
}
|
||||
if (!currentVersion || !currentVersion.isValid) {
|
||||
if (this.configuration.globalTsdk) {
|
||||
workspace.showMessage(`Can not find typescript module, in 'tsserver.tsdk': ${this.configuration.globalTsdk}`, 'error')
|
||||
window.showMessage(`Can not find typescript module, in 'tsserver.tsdk': ${this.configuration.globalTsdk}`, 'error')
|
||||
} else {
|
||||
workspace.showMessage(`Can not find typescript module, run ':CocInstall coc-tsserver' to fix it!`, 'error')
|
||||
window.showMessage(`Can not find typescript module, run ':CocInstall coc-tsserver' to fix it!`, 'error')
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
|
|||
this.lastError = err
|
||||
this.error('TSServer errored with error.', err)
|
||||
this.error(`TSServer log file: ${this.tsServerLogFile || ''}`)
|
||||
workspace.showMessage(`TSServer errored with error. ${err.message}`, 'error')
|
||||
window.showMessage(`TSServer errored with error. ${err.message}`, 'error')
|
||||
this.serviceExited(false)
|
||||
})
|
||||
handle.onExit((code: any) => {
|
||||
|
@ -371,7 +371,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
|
|||
public async openTsServerLogFile(): Promise<boolean> {
|
||||
const isRoot = process.getuid && process.getuid() == 0
|
||||
let echoErr = (msg: string) => {
|
||||
workspace.showMessage(msg, 'error')
|
||||
window.showMessage(msg, 'error')
|
||||
}
|
||||
if (isRoot) {
|
||||
echoErr('Log disabled for root user.')
|
||||
|
@ -463,10 +463,10 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
|
|||
if (diff < 10 * 1000 /* 10 seconds */) {
|
||||
this.lastStart = Date.now()
|
||||
startService = false
|
||||
workspace.showMessage('The TypeScript language service died 5 times right after it got started.', 'error') // tslint:disable-line
|
||||
window.showMessage('The TypeScript language service died 5 times right after it got started.', 'error') // tslint:disable-line
|
||||
} else if (diff < 60 * 1000 /* 1 Minutes */) {
|
||||
this.lastStart = Date.now()
|
||||
workspace.showMessage('The TypeScript language service died unexpectedly 5 times in the last 5 Minutes.', 'error') // tslint:disable-line
|
||||
window.showMessage('The TypeScript language service died unexpectedly 5 times in the last 5 Minutes.', 'error') // tslint:disable-line
|
||||
}
|
||||
}
|
||||
if (startService) {
|
||||
|
|
|
@ -2,21 +2,21 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { Uri, DiagnosticKind, disposeAll, workspace, languages } from 'coc.nvim'
|
||||
import { Range, Diagnostic, DiagnosticSeverity, Disposable, Position, CancellationToken, DiagnosticRelatedInformation } from 'vscode-languageserver-protocol'
|
||||
import { disposeAll, languages, TextDocument, Uri, workspace } from 'coc.nvim'
|
||||
import { CancellationToken, Diagnostic, DiagnosticRelatedInformation, DiagnosticSeverity, Disposable, Position, Range } from 'vscode-languageserver-protocol'
|
||||
import { flatten } from '../utils/arrays'
|
||||
import { PluginManager } from '../utils/plugins'
|
||||
import { DiagnosticKind } from './features/diagnostics'
|
||||
import FileConfigurationManager from './features/fileConfigurationManager'
|
||||
import WatchBuild from './features/watchBuild'
|
||||
import WorkspaceSymbolProvider from './features/workspaceSymbols'
|
||||
import LanguageProvider from './languageProvider'
|
||||
import * as Proto from './protocol'
|
||||
import * as PConst from './protocol.const'
|
||||
import FileConfigurationManager from './features/fileConfigurationManager'
|
||||
import TypeScriptServiceClient from './typescriptServiceClient'
|
||||
import { DiagnosticLanguage, LanguageDescription } from './utils/languageDescription'
|
||||
import * as typeConverters from './utils/typeConverters'
|
||||
import TypingsStatus, { AtaProgressReporter } from './utils/typingsStatus'
|
||||
import { PluginManager } from '../utils/plugins'
|
||||
import { flatten } from '../utils/arrays'
|
||||
import WatchBuild from './features/watchBuild'
|
||||
import WorkspaceSymbolProvider from './features/workspaceSymbols'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
|
||||
// Style check diagnostics that can be reported as warnings
|
||||
const styleCheckDiagnostics = [
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { OutputChannel, workspace } from 'coc.nvim'
|
||||
import { OutputChannel, window } from 'coc.nvim'
|
||||
import * as is from './is'
|
||||
|
||||
export default class Logger {
|
||||
|
@ -14,7 +9,7 @@ export default class Logger {
|
|||
if (this._channel) {
|
||||
return this._channel
|
||||
}
|
||||
this._channel = workspace.createOutputChannel('tsserver')
|
||||
this._channel = window.createOutputChannel('tsserver')
|
||||
return this._channel
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { exec } from 'child_process'
|
||||
import { workspace, Uri } from 'coc.nvim'
|
||||
import { Uri, window, workspace } from 'coc.nvim'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
|
@ -28,12 +28,6 @@ async function getManager(): Promise<string> {
|
|||
return res.endsWith('yarn.lock') ? 'yarn' : 'npm'
|
||||
}
|
||||
|
||||
async function getRoot(): Promise<string | null> {
|
||||
let res = await workspace.findUp(['package.json'])
|
||||
if (!res) return null
|
||||
return path.dirname(res)
|
||||
}
|
||||
|
||||
export async function moduleExists(name: string): Promise<boolean> {
|
||||
try {
|
||||
let content = await runCommand(`npm info ${name} --json`, process.cwd())
|
||||
|
@ -76,11 +70,11 @@ export async function installModules(uri: string, names: string[]): Promise<void
|
|||
let workspaceFolder = workspace.getWorkspaceFolder(uri)
|
||||
let root = workspaceFolder ? Uri.parse(workspaceFolder.uri).fsPath : undefined
|
||||
if (!root || !fs.existsSync(path.join(root, 'package.json'))) {
|
||||
workspace.showMessage(`package.json not found from workspaceFolder: ${root}`, 'error')
|
||||
window.showMessage(`package.json not found from workspaceFolder: ${root}`, 'error')
|
||||
return
|
||||
}
|
||||
let arr = names.concat(names.map(s => `@types/${s}`))
|
||||
let statusItem = workspace.createStatusBarItem(99, { progress: true })
|
||||
let statusItem = window.createStatusBarItem(99, { progress: true })
|
||||
statusItem.text = `Checking module ${arr.join(' ')}`
|
||||
statusItem.show()
|
||||
let exists = await Promise.all(arr.map(name => {
|
||||
|
@ -101,9 +95,9 @@ export async function installModules(uri: string, names: string[]): Promise<void
|
|||
await runCommand(cmd, root)
|
||||
} catch (e) {
|
||||
statusItem.dispose()
|
||||
workspace.showMessage(`Install error ${e.message}`, 'error')
|
||||
window.showMessage(`Install error ${e.message}`, 'error')
|
||||
return
|
||||
}
|
||||
statusItem.dispose()
|
||||
workspace.showMessage(`Installed: ${exists.join(' ')}`, 'more')
|
||||
window.showMessage(`Installed: ${exists.join(' ')}`, 'more')
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { StatusBarItem, window } from 'coc.nvim'
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { Disposable } from 'vscode-languageserver-protocol'
|
||||
import { ITypeScriptServiceClient } from '../typescriptService'
|
||||
import { workspace, StatusBarItem } from 'coc.nvim'
|
||||
|
||||
const typingsInstallTimeout = 30 * 1000
|
||||
|
||||
|
@ -67,7 +67,7 @@ export class AtaProgressReporter {
|
|||
private statusItem: StatusBarItem
|
||||
|
||||
constructor(client: ITypeScriptServiceClient) {
|
||||
this.statusItem = workspace.createStatusBarItem(10, { progress: true })
|
||||
this.statusItem = window.createStatusBarItem(10, { progress: true })
|
||||
const disposables: Disposable[] = []
|
||||
disposables.push(client.onDidBeginInstallTypings(e => this._onBegin(e.eventId)))
|
||||
disposables.push(client.onDidEndInstallTypings(e => this._onEndOrTimeout(e.eventId)))
|
||||
|
@ -113,7 +113,7 @@ export class AtaProgressReporter {
|
|||
private onTypesInstallerInitializationFailed() { // tslint:disable-line
|
||||
this.statusItem.hide()
|
||||
if (!this._invalid) {
|
||||
workspace.showMessage('Could not install typings files for JavaScript language features. Please ensure that NPM is installed', 'error')
|
||||
window.showMessage('Could not install typings files for JavaScript language features. Please ensure that NPM is installed', 'error')
|
||||
}
|
||||
this._invalid = true
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { Uri, window, workspace } from 'coc.nvim'
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { workspace, Uri } from 'coc.nvim'
|
||||
import API from './api'
|
||||
import { TypeScriptServiceConfiguration } from './configuration'
|
||||
declare var __webpack_require__: any
|
||||
|
@ -88,7 +88,7 @@ const MODULE_FOLDERS = ['node_modules/typescript/lib', '.vscode/pnpify/typescrip
|
|||
|
||||
export class TypeScriptVersionProvider {
|
||||
|
||||
public constructor(private configuration: TypeScriptServiceConfiguration) { }
|
||||
public constructor(private configuration: TypeScriptServiceConfiguration) {}
|
||||
|
||||
public updateConfiguration(
|
||||
configuration: TypeScriptServiceConfiguration
|
||||
|
@ -131,7 +131,7 @@ export class TypeScriptVersionProvider {
|
|||
'')
|
||||
return bundledVersion
|
||||
} catch (e) {
|
||||
workspace.showMessage('Bundled typescript module not found', 'error')
|
||||
window.showMessage('Bundled typescript module not found', 'error')
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Uri, StatusBarItem, workspace, events } from 'coc.nvim'
|
||||
import { events, StatusBarItem, Uri, window, workspace } from 'coc.nvim'
|
||||
import { Disposable } from 'vscode-languageserver-protocol'
|
||||
import { TypeScriptVersion } from './versionProvider'
|
||||
|
||||
|
@ -10,7 +10,7 @@ export default class VersionStatus {
|
|||
private readonly _normalizePath: (resource: Uri) => string | null,
|
||||
private readonly enableJavascript: boolean
|
||||
) {
|
||||
this._versionBarEntry = workspace.createStatusBarItem(99)
|
||||
this._versionBarEntry = window.createStatusBarItem(99)
|
||||
this._onChangeEditorSub = events.on('BufEnter', this.onBufEnter, this)
|
||||
this._versionBarEntry.show()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue