Go to Symbol in workspace includes all opened projects
This commit is contained in:
parent
fde4e6cdd5
commit
031fa8f441
2 changed files with 32 additions and 10 deletions
|
@ -409,6 +409,15 @@
|
||||||
"description": "Enable/disable showing completions on potentially undefined values that insert an optional chain call. Requires TS 3.7+ and strict null checks to be enabled.",
|
"description": "Enable/disable showing completions on potentially undefined values that insert an optional chain call. Requires TS 3.7+ and strict null checks to be enabled.",
|
||||||
"scope": "resource"
|
"scope": "resource"
|
||||||
},
|
},
|
||||||
|
"typescript.workspaceSymbols.scope": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"allOpenProjects",
|
||||||
|
"currentProject"
|
||||||
|
],
|
||||||
|
"default": "allOpenProjects",
|
||||||
|
"scope": "window"
|
||||||
|
},
|
||||||
"javascript.showUnused": {
|
"javascript.showUnused": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": true,
|
"default": true,
|
||||||
|
|
|
@ -2,12 +2,13 @@
|
||||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
* 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 { CancellationToken, Range, SymbolInformation, SymbolKind } from 'vscode-languageserver-protocol'
|
import {CancellationToken, Range, SymbolInformation, SymbolKind} from 'vscode-languageserver-protocol'
|
||||||
import { WorkspaceSymbolProvider } from 'coc.nvim/lib/provider'
|
import {WorkspaceSymbolProvider} from 'coc.nvim/lib/provider'
|
||||||
import { workspace } from 'coc.nvim'
|
import {workspace} from 'coc.nvim'
|
||||||
import * as Proto from '../protocol'
|
import * as Proto from '../protocol'
|
||||||
import { ITypeScriptServiceClient } from '../typescriptService'
|
import {ITypeScriptServiceClient} from '../typescriptService'
|
||||||
import * as typeConverters from '../utils/typeConverters'
|
import * as typeConverters from '../utils/typeConverters'
|
||||||
|
import API from '../utils/api'
|
||||||
|
|
||||||
function getSymbolKind(item: Proto.NavtoItem): SymbolKind {
|
function getSymbolKind(item: Proto.NavtoItem): SymbolKind {
|
||||||
switch (item.kind) {
|
switch (item.kind) {
|
||||||
|
@ -32,21 +33,28 @@ export default class TypeScriptWorkspaceSymbolProvider implements WorkspaceSymbo
|
||||||
public constructor(
|
public constructor(
|
||||||
private readonly client: ITypeScriptServiceClient,
|
private readonly client: ITypeScriptServiceClient,
|
||||||
private readonly languageIds: string[]
|
private readonly languageIds: string[]
|
||||||
) { }
|
) {}
|
||||||
|
|
||||||
public async provideWorkspaceSymbols(
|
public async provideWorkspaceSymbols(
|
||||||
search: string,
|
search: string,
|
||||||
token: CancellationToken
|
token: CancellationToken
|
||||||
): Promise<SymbolInformation[]> {
|
): Promise<SymbolInformation[]> {
|
||||||
const uri = this.getUri()
|
|
||||||
if (!uri) return []
|
|
||||||
|
|
||||||
const filepath = this.client.toPath(uri)
|
let filepath: string | undefined
|
||||||
if (!filepath) return []
|
if (this.searchAllOpenProjects) {
|
||||||
|
filepath = undefined
|
||||||
|
} else {
|
||||||
|
let uri = this.getUri()
|
||||||
|
filepath = uri ? this.client.toPath(uri) : undefined
|
||||||
|
if (!filepath && this.client.apiVersion.lt(API.v390)) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const args: Proto.NavtoRequestArgs = {
|
const args: Proto.NavtoRequestArgs = {
|
||||||
file: filepath,
|
file: filepath,
|
||||||
searchValue: search
|
searchValue: search,
|
||||||
|
maxResultCount: 256,
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await this.client.execute('navto', args, token)
|
const response = await this.client.execute('navto', args, token)
|
||||||
|
@ -93,4 +101,9 @@ export default class TypeScriptWorkspaceSymbolProvider implements WorkspaceSymbo
|
||||||
}
|
}
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private get searchAllOpenProjects(): boolean {
|
||||||
|
return this.client.apiVersion.gte(API.v390)
|
||||||
|
&& workspace.getConfiguration('typescript').get('workspaceSymbols.scope', 'allOpenProjects') === 'allOpenProjects'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue