Skip to content

Commit

Permalink
FixeD: LSP: some implementations (e.g. gopls) require that the clie…
Browse files Browse the repository at this point in the history
…nt will send the semantic tokens types + modifiers
  • Loading branch information
eranif committed Jul 14, 2024
1 parent 498276b commit 4e09d93
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions CodeLite/LSP/InitializeRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@ JSONItem LSP::InitializeRequest::ToJSON(const wxString& name) const
JSONItem params = JSONItem::createObject("params");
json.append(params);
params.addProperty("processId", GetProcessId());
if(GetRootUri().IsEmpty()) {
if (GetRootUri().IsEmpty()) {
JSON nullItem(cJSON_NULL);
JSONItem nullObj = nullItem.toElement();
params.append(nullObj);
(void)nullItem.release(); // dont delete it on destruction, it is now owned by 'params'
} else {
params.addProperty("rootUri", LSP::FileNameToURI(GetRootUri()));
}
if(!m_initOptions.empty()) {

if (!m_initOptions.empty()) {
// Parse the JSON string and set it as the 'initializationOptions
JSON initializationOptions(m_initOptions);
if(initializationOptions.isOk()) {
if (initializationOptions.isOk()) {
cJSON* pjson = initializationOptions.release();
params.addProperty(wxString("initializationOptions"), (cJSON*)pjson);
}
Expand All @@ -43,6 +44,42 @@ JSONItem LSP::InitializeRequest::ToJSON(const wxString& name) const
auto hoverFormat = textDocumentCapabilities.AddObject("hover").AddArray("contentFormat");
hoverFormat.arrayAppend("markdown");
hoverFormat.arrayAppend("plaintext");

auto sematicTokens = textDocumentCapabilities.AddObject("semanticTokens");
auto tokenTypes = sematicTokens.AddArray("tokenTypes");
tokenTypes.arrayAppend("type");
tokenTypes.arrayAppend("class");
tokenTypes.arrayAppend("enum");
tokenTypes.arrayAppend("interface");
tokenTypes.arrayAppend("struct");
tokenTypes.arrayAppend("typeParameter");
tokenTypes.arrayAppend("parameter");
tokenTypes.arrayAppend("variable");
tokenTypes.arrayAppend("property");
tokenTypes.arrayAppend("enumMember");
tokenTypes.arrayAppend("event");
tokenTypes.arrayAppend("function");
tokenTypes.arrayAppend("method");
tokenTypes.arrayAppend("macro");
tokenTypes.arrayAppend("keyword");
tokenTypes.arrayAppend("modifier");
tokenTypes.arrayAppend("comment");
tokenTypes.arrayAppend("string");
tokenTypes.arrayAppend("number");
tokenTypes.arrayAppend("regexp");
tokenTypes.arrayAppend("operator");

auto tokenModifiers = sematicTokens.AddArray("tokenModifiers");
tokenModifiers.arrayAppend("declaration");
tokenModifiers.arrayAppend("definition");
tokenModifiers.arrayAppend("readonly");
tokenModifiers.arrayAppend("static");
tokenModifiers.arrayAppend("deprecated");
tokenModifiers.arrayAppend("abstract");
tokenModifiers.arrayAppend("async");
tokenModifiers.arrayAppend("modification");
tokenModifiers.arrayAppend("documentation");
tokenModifiers.arrayAppend("defaultLibrary");
return json;
}

Expand Down

0 comments on commit 4e09d93

Please sign in to comment.