[PATCH] D31121: [clangd] Add support for vscode extension configuration

2017-03-24 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL298696: [clangd] Add support for vscode extension 
configuration (authored by krasimir).

Changed prior to commit:
  https://reviews.llvm.org/D31121?vs=92367=92907#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31121

Files:
  clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
  clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts


Index: clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
@@ -2,14 +2,24 @@
 import * as vscodelc from 'vscode-languageclient';
 
 /**
+ * Method to get workspace configuration option
+ * @param option name of the option (e.g. for clangd.path should be path)
+ * @param defaultValue default value to return if option is not set
+ */
+function getConfig(option: string, defaultValue?: any) : T {
+const config = vscode.workspace.getConfiguration('clangd');
+return config.get(option, defaultValue);
+}
+
+/**
  *  this method is called when your extension is activate
  *  your extension is activated the very first time the command is executed
  */
 export function activate(context: vscode.ExtensionContext) {
-// TODO: make this configurable
-const clangdPath = '/usr/bin/clangd';
+const clangdPath = getConfig('path');
+const clangdArgs = getConfig('arguments');
 
-const serverOptions: vscodelc.ServerOptions = { command: clangdPath };
+const serverOptions: vscodelc.ServerOptions = { command: clangdPath, args: 
clangdArgs };
 
 const clientOptions: vscodelc.LanguageClientOptions = {
 // Register the server for C/C++ files
@@ -39,4 +49,4 @@
 const disposable = clangdClient.start();
 
 context.subscriptions.push(disposable, 
vscode.commands.registerCommand('clangd.applyFix', applyTextEdits));
-}
\ No newline at end of file
+}
Index: clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
@@ -33,5 +33,26 @@
 "mocha": "^2.3.3",
 "@types/node": "^6.0.40",
 "@types/mocha": "^2.2.32"
+},
+"contributes": {
+"configuration": {
+"type": "object",
+"title": "clangd configuration",
+"properties": {
+"clangd.path": {
+"type": "string",
+"default": "clangd",
+"description": "The path to clangd executable, e.g.: 
/usr/bin/clangd"
+},
+"clangd.arguments": {
+"type": "array",
+"default": [],
+"items": {
+"type": "string"
+},
+"description": "Arguments for clangd server"
+}
+}
+}
 }
-}
\ No newline at end of file
+}


Index: clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
@@ -2,14 +2,24 @@
 import * as vscodelc from 'vscode-languageclient';
 
 /**
+ * Method to get workspace configuration option
+ * @param option name of the option (e.g. for clangd.path should be path)
+ * @param defaultValue default value to return if option is not set
+ */
+function getConfig(option: string, defaultValue?: any) : T {
+const config = vscode.workspace.getConfiguration('clangd');
+return config.get(option, defaultValue);
+}
+
+/**
  *  this method is called when your extension is activate
  *  your extension is activated the very first time the command is executed
  */
 export function activate(context: vscode.ExtensionContext) {
-// TODO: make this configurable
-const clangdPath = '/usr/bin/clangd';
+const clangdPath = getConfig('path');
+const clangdArgs = getConfig('arguments');
 
-const serverOptions: vscodelc.ServerOptions = { command: clangdPath };
+const serverOptions: vscodelc.ServerOptions = { command: clangdPath, args: clangdArgs };
 
 const clientOptions: vscodelc.LanguageClientOptions = {
 // Register the server for C/C++ files
@@ -39,4 +49,4 @@
 const disposable = clangdClient.start();
 
 context.subscriptions.push(disposable, vscode.commands.registerCommand('clangd.applyFix', applyTextEdits));
-}
\ No newline at end of file
+}
Index: clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json

[PATCH] D31121: [clangd] Add support for vscode extension configuration

2017-03-23 Thread Stanislav Ionascu via Phabricator via cfe-commits
stanionascu added a comment.

Thanks for review!
Would be great if somebody would commit it, as I cannot do it myself.


https://reviews.llvm.org/D31121



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31121: [clangd] Add support for vscode extension configuration

2017-03-23 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

Looks good! Sorry for the delay.


https://reviews.llvm.org/D31121



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31121: [clangd] Add support for vscode extension configuration

2017-03-20 Thread Stanislav Ionascu via Phabricator via cfe-commits
stanionascu added inline comments.



Comment at: clangd/clients/clangd-vscode/package.json:45
+"default": "clangd",
+"description": "The path to clangd executable"
+},

krasimir wrote:
> krasimir wrote:
> > Maybe prepend a `, for example: /usr/bin/clangd` to the "description".
> meh, it's OK like that.
I still extended the description with the example :)


https://reviews.llvm.org/D31121



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31121: [clangd] Add support for vscode extension configuration

2017-03-20 Thread Stanislav Ionascu via Phabricator via cfe-commits
stanionascu updated this revision to Diff 92367.
stanionascu edited the summary of this revision.
stanionascu added a comment.

- removed unrelated new line change
- extended the "clang.path" description a bit
- removed defaultValue for getConfig<>, as it's anyway "contributed" by 
extension package.json


https://reviews.llvm.org/D31121

Files:
  clangd/clients/clangd-vscode/package.json
  clangd/clients/clangd-vscode/src/extension.ts


Index: clangd/clients/clangd-vscode/src/extension.ts
===
--- clangd/clients/clangd-vscode/src/extension.ts
+++ clangd/clients/clangd-vscode/src/extension.ts
@@ -2,14 +2,24 @@
 import * as vscodelc from 'vscode-languageclient';
 
 /**
+ * Method to get workspace configuration option
+ * @param option name of the option (e.g. for clangd.path should be path)
+ * @param defaultValue default value to return if option is not set
+ */
+function getConfig(option: string, defaultValue?: any) : T {
+const config = vscode.workspace.getConfiguration('clangd');
+return config.get(option, defaultValue);
+}
+
+/**
  *  this method is called when your extension is activate
  *  your extension is activated the very first time the command is executed
  */
 export function activate(context: vscode.ExtensionContext) {
-// TODO: make this configurable
-const clangdPath = '/usr/bin/clangd';
+const clangdPath = getConfig('path');
+const clangdArgs = getConfig('arguments');
 
-const serverOptions: vscodelc.ServerOptions = { command: clangdPath };
+const serverOptions: vscodelc.ServerOptions = { command: clangdPath, args: 
clangdArgs };
 
 const clientOptions: vscodelc.LanguageClientOptions = {
 // Register the server for C/C++ files
@@ -39,4 +49,4 @@
 const disposable = clangdClient.start();
 
 context.subscriptions.push(disposable, 
vscode.commands.registerCommand('clangd.applyFix', applyTextEdits));
-}
\ No newline at end of file
+}
Index: clangd/clients/clangd-vscode/package.json
===
--- clangd/clients/clangd-vscode/package.json
+++ clangd/clients/clangd-vscode/package.json
@@ -33,5 +33,26 @@
 "mocha": "^2.3.3",
 "@types/node": "^6.0.40",
 "@types/mocha": "^2.2.32"
+},
+"contributes": {
+"configuration": {
+"type": "object",
+"title": "clangd configuration",
+"properties": {
+"clangd.path": {
+"type": "string",
+"default": "clangd",
+"description": "The path to clangd executable, e.g.: 
/usr/bin/clangd"
+},
+"clangd.arguments": {
+"type": "array",
+"default": [],
+"items": {
+"type": "string"
+},
+"description": "Arguments for clangd server"
+}
+}
+}
 }
-}
\ No newline at end of file
+}


Index: clangd/clients/clangd-vscode/src/extension.ts
===
--- clangd/clients/clangd-vscode/src/extension.ts
+++ clangd/clients/clangd-vscode/src/extension.ts
@@ -2,14 +2,24 @@
 import * as vscodelc from 'vscode-languageclient';
 
 /**
+ * Method to get workspace configuration option
+ * @param option name of the option (e.g. for clangd.path should be path)
+ * @param defaultValue default value to return if option is not set
+ */
+function getConfig(option: string, defaultValue?: any) : T {
+const config = vscode.workspace.getConfiguration('clangd');
+return config.get(option, defaultValue);
+}
+
+/**
  *  this method is called when your extension is activate
  *  your extension is activated the very first time the command is executed
  */
 export function activate(context: vscode.ExtensionContext) {
-// TODO: make this configurable
-const clangdPath = '/usr/bin/clangd';
+const clangdPath = getConfig('path');
+const clangdArgs = getConfig('arguments');
 
-const serverOptions: vscodelc.ServerOptions = { command: clangdPath };
+const serverOptions: vscodelc.ServerOptions = { command: clangdPath, args: clangdArgs };
 
 const clientOptions: vscodelc.LanguageClientOptions = {
 // Register the server for C/C++ files
@@ -39,4 +49,4 @@
 const disposable = clangdClient.start();
 
 context.subscriptions.push(disposable, vscode.commands.registerCommand('clangd.applyFix', applyTextEdits));
-}
\ No newline at end of file
+}
Index: clangd/clients/clangd-vscode/package.json
===
--- clangd/clients/clangd-vscode/package.json
+++ clangd/clients/clangd-vscode/package.json
@@ -33,5 +33,26 @@
 "mocha": "^2.3.3",
 "@types/node": "^6.0.40",
 "@types/mocha": "^2.2.32"
+},
+"contributes": 

[PATCH] D31121: [clangd] Add support for vscode extension configuration

2017-03-20 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

It looks pretty good! I just have a minor suggestion.




Comment at: clangd/clients/clangd-vscode/package.json:45
+"default": "clangd",
+"description": "The path to clangd executable"
+},

krasimir wrote:
> Maybe prepend a `, for example: /usr/bin/clangd` to the "description".
meh, it's OK like that.


https://reviews.llvm.org/D31121



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31121: [clangd] Add support for vscode extension configuration

2017-03-20 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: clangd/clients/clangd-vscode/package.json:45
+"default": "clangd",
+"description": "The path to clangd executable"
+},

Maybe prepend a `, for example: /usr/bin/clangd` to the "description".



Comment at: clangd/clients/clangd-vscode/src/extension.ts:19
 export function activate(context: vscode.ExtensionContext) {
-// TODO: make this configurable
-const clangdPath = '/usr/bin/clangd';
+const clangdPath = getConfig('path', '/usr/bin/clangd');
+const clangdArgs = getConfig('arguments', []);

I feel that this is too platform-specific and redundant because "clangd.path" 
already has a default value.


https://reviews.llvm.org/D31121



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits