Debian Codegraph @

LanguageServer/LSPClangdDetector.cpp

raw
1 #include "LSPClangdDetector.hpp"
2
3 #include "CompilerLocatorCLANG.h"
4 #include "MSYS2.hpp"
5 #include "Platform.hpp"
6 #include "asyncprocess.h"
7 #include "clFilesCollector.h"
8 #include "file_logger.h"
9 #include "globals.h"
10 #include "procutils.h"
11
12 #include <wx/filename.h>
13 #include <wx/regex.h>
14
15 LSPClangdDetector::LSPClangdDetector()
16 : LSPDetector("clangd")
17 {
18 }
19
20 LSPClangdDetector::~LSPClangdDetector() {}
21
22 bool LSPClangdDetector::DoLocate()
23 {
24 wxString path;
25 if(!ThePlatform->WhichWithVersion("clangd", { 12, 13, 14, 15, 16, 17, 18, 19, 20 }, &path)) {
26 return false;
27 }
28
29 clDEBUG() << "Found clangd ==>" << path << endl;
30 ConfigureFile(path);
31 return true;
32 }
33
34 void LSPClangdDetector::ConfigureFile(const wxFileName& clangdExe)
35 {
36 clDEBUG() << "==> Found" << clangdExe;
37 wxString command;
38 command << clangdExe.GetFullPath();
39 ::WrapWithQuotes(command);
40
41 command << " -limit-results=250 -header-insertion-decorators=0 --compile-commands-dir=$(WorkspacePath)";
42 SetCommand(command);
43 // Add support for the languages
44 GetLangugaes().Add("c");
45 GetLangugaes().Add("cpp");
46 SetConnectionString("stdio");
47 SetPriority(90); // clangd should override the default cc engine
48 }