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

Paul Taylor via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 20 11:37:46 PST 2019


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<boolean>('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",


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70041.230301.patch
Type: text/x-patch
Size: 3402 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191120/750e77d1/attachment-0001.bin>


More information about the cfe-commits mailing list