From 760f5e57ff5cd079450b1e07845ceec1440fcf39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felici=C3=A1n=20N=C3=A9meth?= Date: Mon, 11 Nov 2019 10:19:24 +0100 Subject: [PATCH] initialize: implement serverInfo (LSP 3.15.0) Return serverInfo for an initialize request. This helps clients to identify ccls even when they just connect to a TCP port and allows them to easily implement server specific functionalities like $ccls/navigate. --- CMakeLists.txt | 2 ++ src/messages/initialize.cc | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 092f178f..471f4a63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -240,3 +240,5 @@ endif() set_property(SOURCE src/main.cc APPEND PROPERTY COMPILE_DEFINITIONS CCLS_VERSION=\"${CCLS_VERSION}\") +set_property(SOURCE src/messages/initialize.cc APPEND PROPERTY + COMPILE_DEFINITIONS CCLS_VERSION=\"${CCLS_VERSION}\") diff --git a/src/messages/initialize.cc b/src/messages/initialize.cc index 5861d28c..b015d98d 100644 --- a/src/messages/initialize.cc +++ b/src/messages/initialize.cc @@ -221,8 +221,13 @@ REFLECT_STRUCT(InitializeParam, rootUri, capabilities, trace, workspaceFolders); struct InitializeResult { ServerCap capabilities; + struct ServerInfo { + const char *name = "ccls"; + const char *version = CCLS_VERSION; + } serverInfo; }; -REFLECT_STRUCT(InitializeResult, capabilities); +REFLECT_STRUCT(InitializeResult::ServerInfo, name, version); +REFLECT_STRUCT(InitializeResult, capabilities, serverInfo); struct FileSystemWatcher { std::string globPattern = "**/*";