From e5af87eece9993bcce6134af65e48776c1cddc3f Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 8 Nov 2016 18:46:00 +0800 Subject: [PATCH] fix #13 --- client/package.json | 6 +++--- server/.vscode/settings.json | 3 +++ server/src/server.ts | 2 +- server/src/ycm.ts | 14 +++++++------- 4 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 server/.vscode/settings.json diff --git a/client/package.json b/client/package.json index cee9f6d..50296e7 100644 --- a/client/package.json +++ b/client/package.json @@ -56,10 +56,10 @@ "default": false, "description": "show debug messages" }, - "ycmd.enable_hover_type": { + "ycmd.use_imprecise_get_type": { "type": "boolean", - "default": true, - "description": "GetType from ycmd by hover on variable" + "default": false, + "description": "use GetTypeImprecise subcommand instand of GetType, please see https://github.com/Valloric/ycmd/pull/609" } } }, diff --git a/server/.vscode/settings.json b/server/.vscode/settings.json new file mode 100644 index 0000000..c7c1623 --- /dev/null +++ b/server/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "typescript.tsdk": "./node_modules/typescript/lib" +} \ No newline at end of file diff --git a/server/src/server.ts b/server/src/server.ts index 8fbc698..7b92126 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -73,7 +73,7 @@ connection.onNotification({ method: 'FixIt'}, async (args) => { connection.onHover(async (event): Promise => { const ycm = await getYcm() try { - return await ycm.getType(event.textDocument.uri, event.position, documents) + return await ycm.getType(event.textDocument.uri, event.position, documents, workspaceConfiguration.ycmd.use_imprecise_get_type) } catch (err) { logger(`onHover error`, err) } diff --git a/server/src/ycm.ts b/server/src/ycm.ts index 3e32feb..47f59ae 100644 --- a/server/src/ycm.ts +++ b/server/src/ycm.ts @@ -233,9 +233,8 @@ export default class Ycm { return res } - public async getType(documentUri: string, position: Position, documents: TextDocuments) { - if (!this.settings.ycmd.enable_hover_type) return null - const type = await this.runCompleterCommand(documentUri, position, documents, 'GetType') as YcmGetTypeResponse + public async getType(documentUri: string, position: Position, documents: TextDocuments, imprecise: boolean = false) { + const type = await this.runCompleterCommand(documentUri, position, documents, imprecise ? 'GetTypeImprecise' : 'GetType') as YcmGetTypeResponse logger('getType', JSON.stringify(type)) return mapYcmTypeToHover(type, documents.get(documentUri).languageId) } @@ -298,10 +297,11 @@ export default class Ycm { export interface Settings { ycmd: { path: string - global_extra_config: string, - python: string, - confirm_extra_conf: boolean, - debug: boolean, + global_extra_config: string + python: string + confirm_extra_conf: boolean + debug: boolean enable_hover_type: boolean + use_imprecise_get_type: boolean } } \ No newline at end of file