| 1 |
#include "LSPRlsDetector.hpp" |
| 2 |
#include "file_logger.h" |
| 3 |
#include "globals.h" |
| 4 |
#include <wx/filename.h> |
| 5 |
#include <wx/utils.h> |
| 6 |
|
| 7 |
LSPRlsDetector::LSPRlsDetector() |
| 8 |
: LSPDetector("rust") |
| 9 |
{ |
| 10 |
} |
| 11 |
|
| 12 |
LSPRlsDetector::~LSPRlsDetector() {} |
| 13 |
|
| 14 |
bool LSPRlsDetector::DoLocate() |
| 15 |
{ |
| 16 |
// rls exists under ~/.cargo/bin/rls |
| 17 |
wxString homedir; |
| 18 |
#ifdef __WXMSW__ |
| 19 |
::wxGetEnv("USERPROFILE", &homedir); |
| 20 |
wxFileName rls(homedir, "rls.exe"); |
| 21 |
#else |
| 22 |
::wxGetEnv("HOME", &homedir); |
| 23 |
wxFileName rls(homedir, "rls"); |
| 24 |
#endif |
| 25 |
rls.AppendDir(".cargo"); |
| 26 |
rls.AppendDir("bin"); |
| 27 |
if(!rls.FileExists()) { |
| 28 |
return false; |
| 29 |
} |
| 30 |
|
| 31 |
clDEBUG() << "==> Found" << rls << endl; |
| 32 |
wxString command; |
| 33 |
command << rls.GetFullPath(); |
| 34 |
::WrapWithQuotes(command); |
| 35 |
SetCommand(command); |
| 36 |
|
| 37 |
// Add support for the languages |
| 38 |
GetLangugaes().Add("rust"); |
| 39 |
SetConnectionString("stdio"); |
| 40 |
SetPriority(75); // rls is the second best choice after rust-analyzer |
| 41 |
SetEnabled(false); // by default disable this LSP |
| 42 |
return true; |
| 43 |
} |