[PATCH] D70041: register cuda language activation event and activate for .cuh files

2019-12-02 Thread Paul Taylor via Phabricator via cfe-commits
ptaylor updated this revision to Diff 231742.
ptaylor added a comment.

drop comment about vscode cuda syntax highlighting


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70041/new/

https://reviews.llvm.org/D70041

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


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -83,21 +83,14 @@
   }
   const serverOptions: vscodelc.ServerOptions = clangd;
 
-  // Note that CUDA ('.cu') files are special. When opening files of all other
-  // extensions, VSCode would load clangd automatically. This is achieved by
-  // having a corresponding 'onLanguage:...' activation event in package.json.
-  // However, VSCode does not have CUDA as a supported language yet, so we
-  // cannot add a corresponding activationEvent for CUDA files and clangd will
-  // *not* load itself automatically on '.cu' files.
-  const cudaFilePattern: string = '**/*.{' + [ 'cu' ].join() + '}';
   const clientOptions: vscodelc.LanguageClientOptions = {
 // Register the server for c-family and cuda files.
 documentSelector: [
 { scheme: 'file', language: 'c' },
 { scheme: 'file', language: 'cpp' },
+{ scheme: 'file', language: 'cuda' },
 { scheme: 'file', language: 'objective-c'},
-{ scheme: 'file', language: 'objective-cpp'},
-{ scheme: 'file', pattern: cudaFilePattern },
+{ scheme: 'file', language: 'objective-cpp'}
 ],
 synchronize: !syncFileEvents ? undefined : {
 // FIXME: send sync file events when clangd provides implemenatations.
@@ -111,10 +104,10 @@
 serverOptions, clientOptions);
   if (getConfig('semanticHighlighting')) {
 const semanticHighlightingFeature =
-  new semanticHighlighting.SemanticHighlightingFeature(clangdClient,
-context);
+new semanticHighlighting.SemanticHighlightingFeature(clangdClient,
+ context);
 context.subscriptions.push(
-  vscode.Disposable.from(semanticHighlightingFeature));
+vscode.Disposable.from(semanticHighlightingFeature));
 clangdClient.registerFeature(semanticHighlightingFeature);
   }
   console.log('Clang Language Server is now active!');
Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -23,6 +23,7 @@
 "activationEvents": [
 "onLanguage:c",
 "onLanguage:cpp",
+"onLanguage:cuda",
 "onLanguage:objective-c",
 "onLanguage:objective-cpp",
 "onCommand:clangd-vscode.activate"
@@ -64,6 +65,13 @@
 "**/MSVC/*/include/**"
 ],
 "firstLine": "^/[/*].*-\\*-\\s*C\\+\\+\\s*-\\*-.*"
+},
+{
+"id": "cuda",
+"extensions": [
+".cu",
+".cuh"
+]
 }
 ],
 "configuration": {


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -83,21 +83,14 @@
   }
   const serverOptions: vscodelc.ServerOptions = clangd;
 
-  // Note that CUDA ('.cu') files are special. When opening files of all other
-  // extensions, VSCode would load clangd automatically. This is achieved by
-  // having a corresponding 'onLanguage:...' activation event in package.json.
-  // However, VSCode does not have CUDA as a supported language yet, so we
-  // cannot add a corresponding activationEvent for CUDA files and clangd will
-  // *not* load itself automatically on '.cu' files.
-  const cudaFilePattern: string = '**/*.{' + [ 'cu' ].join() + '}';
   const clientOptions: vscodelc.LanguageClientOptions = {
 // Register the server for c-family and cuda files.
 documentSelector: [
 { scheme: 'file', language: 'c' },
 { scheme: 'file', language: 'cpp' },
+{ scheme: 'file', language: 'cuda' },
 { scheme: 'file', language: 'objective-c'},
-{ scheme: 'file', language: 'objective-cpp'},
-{ scheme: 'file', pattern: cudaFilePattern },
+{ scheme: 'file', language: 'objective-cpp'}
 ],
 synchronize: 

[PATCH] D70041: register cuda language activation event and activate for .cuh files

2019-11-20 Thread Paul Taylor via Phabricator via cfe-commits
ptaylor updated this revision to Diff 230301.
ptaylor added a comment.

- add package.json entry to contribute cuda language id
- remove extra cuda file patterns, update comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70041/new/

https://reviews.llvm.org/D70041

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


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -83,21 +83,18 @@
   }
   const serverOptions: vscodelc.ServerOptions = clangd;
 
-  // Note that CUDA ('.cu') files are special. When opening files of all other
-  // extensions, VSCode would load clangd automatically. This is achieved by
-  // having a corresponding 'onLanguage:...' activation event in package.json.
-  // However, VSCode does not have CUDA as a supported language yet, so we
-  // cannot add a corresponding activationEvent for CUDA files and clangd will
-  // *not* load itself automatically on '.cu' files.
-  const cudaFilePattern: string = '**/*.{' + [ 'cu' ].join() + '}';
   const clientOptions: vscodelc.LanguageClientOptions = {
 // Register the server for c-family and cuda files.
 documentSelector: [
 { scheme: 'file', language: 'c' },
 { scheme: 'file', language: 'cpp' },
+// Syntax highlighting for the 'cuda' language is
+// provided by the kriegalex.vscode-cudacpp plugin.
+// @see https://github.com/kriegalex/vscode-cuda
+// @see 
https://marketplace.visualstudio.com/items?itemName=kriegalex.vscode-cudacpp
+{ scheme: 'file', language: 'cuda' },
 { scheme: 'file', language: 'objective-c'},
-{ scheme: 'file', language: 'objective-cpp'},
-{ scheme: 'file', pattern: cudaFilePattern },
+{ scheme: 'file', language: 'objective-cpp'}
 ],
 synchronize: !syncFileEvents ? undefined : {
 // FIXME: send sync file events when clangd provides implemenatations.
@@ -111,10 +108,10 @@
 serverOptions, clientOptions);
   if (getConfig('semanticHighlighting')) {
 const semanticHighlightingFeature =
-  new semanticHighlighting.SemanticHighlightingFeature(clangdClient,
-context);
+new semanticHighlighting.SemanticHighlightingFeature(clangdClient,
+ context);
 context.subscriptions.push(
-  vscode.Disposable.from(semanticHighlightingFeature));
+vscode.Disposable.from(semanticHighlightingFeature));
 clangdClient.registerFeature(semanticHighlightingFeature);
   }
   console.log('Clang Language Server is now active!');
Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -23,6 +23,7 @@
 "activationEvents": [
 "onLanguage:c",
 "onLanguage:cpp",
+"onLanguage:cuda",
 "onLanguage:objective-c",
 "onLanguage:objective-cpp",
 "onCommand:clangd-vscode.activate"
@@ -64,7 +65,14 @@
 "**/MSVC/*/include/**"
 ],
 "firstLine": "^/[/*].*-\\*-\\s*C\\+\\+\\s*-\\*-.*"
-}
+},
+   {
+   "id": "cuda",
+   "extensions": [
+   ".cu",
+   ".cuh"
+   ]
+   }
 ],
 "configuration": {
 "type": "object",


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -83,21 +83,18 @@
   }
   const serverOptions: vscodelc.ServerOptions = clangd;
 
-  // Note that CUDA ('.cu') files are special. When opening files of all other
-  // extensions, VSCode would load clangd automatically. This is achieved by
-  // having a corresponding 'onLanguage:...' activation event in package.json.
-  // However, VSCode does not have CUDA as a supported language yet, so we
-  // cannot add a corresponding activationEvent for CUDA files and clangd will
-  // *not* load itself automatically on '.cu' files.
-  const cudaFilePattern: string = '**/*.{' + [ 'cu' ].join() + '}';
   const clientOptions: vscodelc.LanguageClientOptions = {
 // Register 

[PATCH] D70041: register cuda language activation event and activate for .cuh files

2019-11-20 Thread Paul Taylor via Phabricator via cfe-commits
ptaylor updated this revision to Diff 230302.
ptaylor added a comment.

- fix package.json whitespace


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70041/new/

https://reviews.llvm.org/D70041

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


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -83,21 +83,18 @@
   }
   const serverOptions: vscodelc.ServerOptions = clangd;
 
-  // Note that CUDA ('.cu') files are special. When opening files of all other
-  // extensions, VSCode would load clangd automatically. This is achieved by
-  // having a corresponding 'onLanguage:...' activation event in package.json.
-  // However, VSCode does not have CUDA as a supported language yet, so we
-  // cannot add a corresponding activationEvent for CUDA files and clangd will
-  // *not* load itself automatically on '.cu' files.
-  const cudaFilePattern: string = '**/*.{' + [ 'cu' ].join() + '}';
   const clientOptions: vscodelc.LanguageClientOptions = {
 // Register the server for c-family and cuda files.
 documentSelector: [
 { scheme: 'file', language: 'c' },
 { scheme: 'file', language: 'cpp' },
+// Syntax highlighting for the 'cuda' language is
+// provided by the kriegalex.vscode-cudacpp plugin.
+// @see https://github.com/kriegalex/vscode-cuda
+// @see 
https://marketplace.visualstudio.com/items?itemName=kriegalex.vscode-cudacpp
+{ scheme: 'file', language: 'cuda' },
 { scheme: 'file', language: 'objective-c'},
-{ scheme: 'file', language: 'objective-cpp'},
-{ scheme: 'file', pattern: cudaFilePattern },
+{ scheme: 'file', language: 'objective-cpp'}
 ],
 synchronize: !syncFileEvents ? undefined : {
 // FIXME: send sync file events when clangd provides implemenatations.
@@ -111,10 +108,10 @@
 serverOptions, clientOptions);
   if (getConfig('semanticHighlighting')) {
 const semanticHighlightingFeature =
-  new semanticHighlighting.SemanticHighlightingFeature(clangdClient,
-context);
+new semanticHighlighting.SemanticHighlightingFeature(clangdClient,
+ context);
 context.subscriptions.push(
-  vscode.Disposable.from(semanticHighlightingFeature));
+vscode.Disposable.from(semanticHighlightingFeature));
 clangdClient.registerFeature(semanticHighlightingFeature);
   }
   console.log('Clang Language Server is now active!');
Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -23,6 +23,7 @@
 "activationEvents": [
 "onLanguage:c",
 "onLanguage:cpp",
+"onLanguage:cuda",
 "onLanguage:objective-c",
 "onLanguage:objective-cpp",
 "onCommand:clangd-vscode.activate"
@@ -64,6 +65,13 @@
 "**/MSVC/*/include/**"
 ],
 "firstLine": "^/[/*].*-\\*-\\s*C\\+\\+\\s*-\\*-.*"
+},
+{
+"id": "cuda",
+"extensions": [
+".cu",
+".cuh"
+]
 }
 ],
 "configuration": {


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -83,21 +83,18 @@
   }
   const serverOptions: vscodelc.ServerOptions = clangd;
 
-  // Note that CUDA ('.cu') files are special. When opening files of all other
-  // extensions, VSCode would load clangd automatically. This is achieved by
-  // having a corresponding 'onLanguage:...' activation event in package.json.
-  // However, VSCode does not have CUDA as a supported language yet, so we
-  // cannot add a corresponding activationEvent for CUDA files and clangd will
-  // *not* load itself automatically on '.cu' files.
-  const cudaFilePattern: string = '**/*.{' + [ 'cu' ].join() + '}';
   const clientOptions: vscodelc.LanguageClientOptions = {
 // Register the server for c-family and cuda files.
 documentSelector: [
 { scheme: 'file', language: 'c' },
 { scheme: 'file', language: 'cpp' },
+// Syntax highlighting for the 'cuda' language is

[PATCH] D70041: register cuda language activation event and activate for .cuh files

2019-11-14 Thread Paul Taylor via Phabricator via cfe-commits
ptaylor added inline comments.



Comment at: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts:92
+  // *not* load itself automatically on '.cu' and '.cuh' files.
+  const cudaFilePatterns: {scheme: string, pattern: string}[] = [
+{scheme : 'file', pattern : '**/*.{cu}'},

hokein wrote:
> I think we could simplify the code, we could move this part to the 
> package.json under the `contributes` umbrella, something like
> 
> ```
>   "contributes": {
> "languages": [
> {
> "id": "cuda",
> "filenamePatterns": [
> "**/*.{cu}",
> "**/*.{cuh}",
> ],
> }
> ]
> ```
> 
> then in the extension.ts, we only need an entry `{ scheme: 'file', language: 
> 'cuda' }` when initailizing the clientOptions.
Yes that's an option. I chose this approach to stay consistent with the current 
behavior, because `vscode-clangd` can do CUDA intellisense and refactoring, it 
doesn't contribute the CUDA grammar definitions for syntax highlighting.

The VSCode docs aren't clear on whether multiple extensions can contribute 
separate features for the same language, or what happens when two plugins both 
contribute languages with the same `languageId`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70041/new/

https://reviews.llvm.org/D70041



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


[PATCH] D70041: register cuda language activation event and activate for .cuh files

2019-11-12 Thread Paul Taylor via Phabricator via cfe-commits
ptaylor added a comment.

A similar PR has been submitted to the `vscode-cpptools` repo to enable 
debugging CUDA files via `cuda-gdb` with the official Microsoft VSCode C++ 
plugin: https://github.com/microsoft/vscode-cpptools/pull/4585


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70041/new/

https://reviews.llvm.org/D70041



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


[PATCH] D70041: register cuda language activation event and activate for .cuh files

2019-11-08 Thread Paul Taylor via Phabricator via cfe-commits
ptaylor created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70041

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


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -88,16 +88,29 @@
   // having a corresponding 'onLanguage:...' activation event in package.json.
   // However, VSCode does not have CUDA as a supported language yet, so we
   // cannot add a corresponding activationEvent for CUDA files and clangd will
-  // *not* load itself automatically on '.cu' files.
-  const cudaFilePattern: string = '**/*.{' + [ 'cu' ].join() + '}';
+  // *not* load itself automatically on '.cu' and '.cuh' files.
+  const cudaFilePatterns: {scheme: string, pattern: string}[] = [
+{scheme : 'file', pattern : '**/*.{cu}'},
+{scheme : 'file', pattern : '**/*.{cuh}'}
+  ];
   const clientOptions: vscodelc.LanguageClientOptions = {
 // Register the server for c-family and cuda files.
 documentSelector: [
 { scheme: 'file', language: 'c' },
 { scheme: 'file', language: 'cpp' },
+// Optimistically register an activation event for the 'cuda'
+// language id. This should be forwards-compatible if VSCode
+// starts shipping CUDA language support. A working 'cuda'
+// language definition is provided by kriegalex.vscode-cudacpp.
+// This handler ensures clangd activates if the vscode-cudacpp
+// plugin is installed and activated.
+// @see https://github.com/kriegalex/vscode-cuda
+// @see 
https://marketplace.visualstudio.com/items?itemName=kriegalex.vscode-cudacpp
+{ scheme: 'file', language: 'cuda' },
 { scheme: 'file', language: 'objective-c'},
 { scheme: 'file', language: 'objective-cpp'},
-{ scheme: 'file', pattern: cudaFilePattern },
+// Also add the '.cu' and '.cuh' patterns
+...cudaFilePatterns
 ],
 synchronize: !syncFileEvents ? undefined : {
 // FIXME: send sync file events when clangd provides implemenatations.
@@ -111,10 +124,10 @@
 serverOptions, clientOptions);
   if (getConfig('semanticHighlighting')) {
 const semanticHighlightingFeature =
-  new semanticHighlighting.SemanticHighlightingFeature(clangdClient,
-context);
+new semanticHighlighting.SemanticHighlightingFeature(clangdClient,
+ context);
 context.subscriptions.push(
-  vscode.Disposable.from(semanticHighlightingFeature));
+vscode.Disposable.from(semanticHighlightingFeature));
 clangdClient.registerFeature(semanticHighlightingFeature);
   }
   console.log('Clang Language Server is now active!');
Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -23,6 +23,7 @@
 "activationEvents": [
 "onLanguage:c",
 "onLanguage:cpp",
+"onLanguage:cuda",
 "onLanguage:objective-c",
 "onLanguage:objective-cpp",
 "onCommand:clangd-vscode.activate"


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -88,16 +88,29 @@
   // having a corresponding 'onLanguage:...' activation event in package.json.
   // However, VSCode does not have CUDA as a supported language yet, so we
   // cannot add a corresponding activationEvent for CUDA files and clangd will
-  // *not* load itself automatically on '.cu' files.
-  const cudaFilePattern: string = '**/*.{' + [ 'cu' ].join() + '}';
+  // *not* load itself automatically on '.cu' and '.cuh' files.
+  const cudaFilePatterns: {scheme: string, pattern: string}[] = [
+{scheme : 'file', pattern : '**/*.{cu}'},
+{scheme : 'file', pattern : '**/*.{cuh}'}
+  ];
   const clientOptions: vscodelc.LanguageClientOptions = {
 // Register the server for c-family and cuda files.
 documentSelector: [
 { scheme: 'file', language: 'c' },
 { scheme: 'file', language: 'cpp' },
+// Optimistically register an activation event for the 'cuda'
+// language id. This should be