[clangd] Detect C++ for extension-less source files in vscode extension
authorHaojian Wu <hokein@google.com>
Mon, 17 Jun 2019 12:59:14 +0000 (12:59 +0000)
committerHaojian Wu <hokein@google.com>
Mon, 17 Jun 2019 12:59:14 +0000 (12:59 +0000)
Summary:
Extend our extension to support detecting these files as C++ files based on the first
line (`-*- C++ -*-`), it will make clangd work on C++ standard headers
(e.g. iostream).

We use the contributes.languages[1] to enrich the builtin VScode C++
support.

[1]: https://code.visualstudio.com/api/references/contribution-points#contributes.languages

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D63397

llvm-svn: 363554

clang-tools-extra/clangd/clients/clangd-vscode/package.json

index 072bfa79ffe1939d3ec49e9115bce0e01da2e1fc..9d9699db013d1a60e32c0d3abc94f68d8c1fe580 100644 (file)
         "url": "http://llvm.org/svn/llvm-project/clang-tools-extra/trunk/clangd/clients/clangd-vscode/"
     },
     "contributes": {
+        "languages": [{
+            "id": "cpp",
+            "firstLine": "^\/[/*].*-\\*-\\s*C\\+\\+\\s*-\\*-.*"
+        }],
         "configuration": {
             "type": "object",
             "title": "clangd configuration",