summaryrefslogtreecommitdiff
path: root/lsp-write.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-12-22 22:56:18 -0500
committerpommicket <pommicket@gmail.com>2022-12-22 22:56:18 -0500
commitb9ac4215ef8d02ad6da257315891c408bc395165 (patch)
tree3b7297102da65890944989f730dd1217c6931f7c /lsp-write.c
parent266af5ed551765ca22cb90819f570ff9371e279b (diff)
start capabilities
Diffstat (limited to 'lsp-write.c')
-rw-r--r--lsp-write.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/lsp-write.c b/lsp-write.c
index 28b19d3..51f638f 100644
--- a/lsp-write.c
+++ b/lsp-write.c
@@ -1,4 +1,5 @@
+
static const char *lsp_language_id(Language lang) {
switch (lang) {
case LANG_CONFIG:
@@ -109,6 +110,16 @@ static void write_key_arr_start(JSONWriter *o, const char *key) {
write_arr_start(o);
}
+static void write_arr_elem_obj_start(JSONWriter *o) {
+ write_arr_elem(o);
+ write_obj_start(o);
+}
+
+static void write_arr_elem_arr_start(JSONWriter *o) {
+ write_arr_elem(o);
+ write_arr_start(o);
+}
+
static void write_number(JSONWriter *o, double number) {
str_builder_appendf(&o->builder, "%g", number);
}
@@ -118,6 +129,11 @@ static void write_key_number(JSONWriter *o, const char *key, double number) {
write_number(o, number);
}
+static void write_arr_elem_number(JSONWriter *o, double number) {
+ write_arr_elem(o);
+ write_number(o, number);
+}
+
static void write_null(JSONWriter *o) {
str_builder_append(&o->builder, "null");
}
@@ -127,11 +143,30 @@ static void write_key_null(JSONWriter *o, const char *key) {
write_null(o);
}
+static void write_bool(JSONWriter *o, bool b) {
+ str_builder_append(&o->builder, b ? "true" : "false");
+}
+
+static void write_key_bool(JSONWriter *o, const char *key, bool b) {
+ write_key(o, key);
+ write_bool(o, b);
+}
+
+static void write_arr_elem_null(JSONWriter *o) {
+ write_arr_elem(o);
+ write_null(o);
+}
+
static void write_key_string(JSONWriter *o, const char *key, const char *s) {
write_key(o, key);
write_string(o, s);
}
+static void write_arr_elem_string(JSONWriter *o, const char *s) {
+ write_arr_elem(o);
+ write_string(o, s);
+}
+
static void write_file_uri(JSONWriter *o, DocumentID document) {
const char *path = o->lsp->document_paths[document];
str_builder_append(&o->builder, "\"file:///");
@@ -251,9 +286,30 @@ static void write_request(LSP *lsp, LSPRequest *request) {
write_key_obj_start(o, "params");
write_key_number(o, "processId", process_get_id());
write_key_obj_start(o, "capabilities");
+ write_key_obj_start(o, "textDocument");
+ write_key_obj_start(o, "completion");
+ // completion capabilities
+ write_key_obj_start(o, "completionItem");
+ write_key_bool(o, "snippetSupport", false);
+ write_obj_end(o);
+ // "completion item kinds" supported by ted
+ // (these are the little icons displayed for function/variable/etc.)
+ write_key_obj_start(o, "completionItemKind");
+ write_key_arr_start(o, "valueSet");
+ for (int i = LSP_COMPLETION_KIND_MIN;
+ i <= LSP_COMPLETION_KIND_MAX; ++i) {
+ write_arr_elem_number(o, i);
+ }
+ write_arr_end(o);
+ write_obj_end(o);
+ write_obj_end(o);
+ write_obj_end(o);
write_obj_end(o);
write_key_null(o, "rootUri");
write_key_null(o, "workspaceFolders");
+ write_key_obj_start(o, "clientInfo");
+ write_key_string(o, "name", "ted");
+ write_obj_end(o);
write_obj_end(o);
} break;
case LSP_REQUEST_DID_OPEN: {