[PATCH] D49967: [clangd] Add command-line option to suppress the space and the circular dot prepended in a completion label.

Raoul Wols via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 29 11:23:08 PDT 2018


rwols created this revision.
rwols added reviewers: sammccall, ilya-biryukov, ioeric.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay.

Some LSP clients (e.g. Sublime Text) assume that the label and the completion trigger have a common
prefix. This assumption is broken by prepending a space or dot in front of the label, depending
on wether we're inserting an `#include <...>` text edit or not. This change allows to clear the
prepended characters in the label.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49967

Files:
  clangd/tool/ClangdMain.cpp


Index: clangd/tool/ClangdMain.cpp
===================================================================
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -12,13 +12,13 @@
 #include "Path.h"
 #include "Trace.h"
 #include "index/SymbolYAML.h"
+#include "clang/Basic/Version.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/raw_ostream.h"
-#include "clang/Basic/Version.h"
 #include <cstdlib>
 #include <iostream>
 #include <memory>
@@ -157,6 +157,14 @@
                 llvm::cl::init(clangd::CodeCompleteOptions().ShowOrigins),
                 llvm::cl::Hidden);
 
+static llvm::cl::opt<bool> NoHeaderInsertDecorators(
+    "no-header-insert-decorators",
+    llvm::cl::desc(
+        "Do not prepend a circular dot or space before the completion "
+        "label, depending on wether "
+        "an include line will be inserted or not."),
+    llvm::cl::init(false));
+
 static llvm::cl::opt<Path> YamlSymbolFile(
     "yaml-symbol-file",
     llvm::cl::desc(
@@ -276,6 +284,10 @@
   CCOpts.Limit = LimitResults;
   CCOpts.BundleOverloads = CompletionStyle != Detailed;
   CCOpts.ShowOrigins = ShowOrigins;
+  if (NoHeaderInsertDecorators) {
+    CCOpts.IncludeIndicator.Insert.clear();
+    CCOpts.IncludeIndicator.NoInsert.clear();
+  }
 
   // Initialize and run ClangdLSPServer.
   ClangdLSPServer LSPServer(Out, CCOpts, CompileCommandsDirPath, Opts);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49967.157893.patch
Type: text/x-patch
Size: 1529 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180729/8ab48289/attachment.bin>


More information about the cfe-commits mailing list