summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-12-28 17:23:28 -0500
committerpommicket <pommicket@gmail.com>2022-12-28 17:23:28 -0500
commitdc8d64a02d99368d2a66cff6caf5a18de3f06bd2 (patch)
treea8a35ac6551d03d1ba97960d2ea61d02722f9548
parent29c5c9b7544243a161d403b66ddfa11b6cdbbcf6 (diff)
better signature help
-rw-r--r--lsp-parse.c9
-rw-r--r--lsp-write.c8
-rw-r--r--lsp.h3
3 files changed, 13 insertions, 7 deletions
diff --git a/lsp-parse.c b/lsp-parse.c
index 633fd2e..b5f687f 100644
--- a/lsp-parse.c
+++ b/lsp-parse.c
@@ -325,10 +325,13 @@ static bool parse_signature_help(LSP *lsp, const JSON *json, LSPResponse *respon
return false;
}
+ #if 0
+ // currently we don't show signature documentation
JSONString documentation = get_markup_content(json,
json_object_get(json, signature_in, "documentation"));
if (documentation.len)
signature_out->documentation = lsp_response_add_json_string(response, json, documentation);
+ #endif
JSONArray parameters = json_object_get_array(json, signature_in, "parameters");
u32 active_parameter = U32_MAX;
@@ -344,19 +347,21 @@ static bool parse_signature_help(LSP *lsp, const JSON *json, LSPResponse *respon
JSONObject parameter_info = json_array_get_object(json, parameters, active_parameter);
JSONValue parameter_label_value = json_object_get(json, parameter_info, "label");
u16 start = 0, end = 0;
+ // parse the parameter label
if (parameter_label_value.type == JSON_ARRAY) {
+ // parameter label is specified as UTF-16 character range
JSONArray parameter_label = parameter_label_value.val.array;
double start_dbl = json_array_get_number(json, parameter_label, 0);
double end_dbl = json_array_get_number(json, parameter_label, 1);
- if (isfinite(start_dbl) && isfinite(end_dbl)) {
+ if (!(isfinite(start_dbl) && isfinite(end_dbl))) {
lsp_set_error(lsp, "Bad contents of ParameterInfo.label array.");
return false;
}
start = (u16)start_dbl;
end = (u16)end_dbl;
} else if (parameter_label_value.type == JSON_STRING) {
+ // parameter label is specified as substring
JSONString parameter_label = parameter_label_value.val.string;
- // this is a substring within the label.
char *sig_lbl = json_string_get_alloc(json, label);
char *param_lbl = json_string_get_alloc(json, parameter_label);
const char *pos = strstr(sig_lbl, param_lbl);
diff --git a/lsp-write.c b/lsp-write.c
index 5898109..edd4934 100644
--- a/lsp-write.c
+++ b/lsp-write.c
@@ -365,6 +365,7 @@ 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");
+ // here are the client capabilities for ted
write_key_obj_start(o, "textDocument");
write_key_obj_start(o, "completion");
// completion capabilities
@@ -398,11 +399,14 @@ static void write_request(LSP *lsp, LSPRequest *request) {
write_key_bool(o, "contextSupport", true);
write_obj_end(o);
write_key_obj_start(o, "signatureHelp");
- // we don't have context support because sending the activeSignatureHelp member is annoying
- //write_key_bool(o, "contextSupport", true);
write_key_obj_start(o, "signatureInformation");
+ write_key_obj_start(o, "parameterInformation");
+ write_key_bool(o, "labelOffsetSupport", true);
+ write_obj_end(o);
write_key_bool(o, "activeParameterSupport", true);
write_obj_end(o);
+ // we don't have context support because sending the activeSignatureHelp member is annoying
+ //write_key_bool(o, "contextSupport", true);
write_obj_end(o);
write_obj_end(o);
write_key_obj_start(o, "workspace");
diff --git a/lsp.h b/lsp.h
index c078820..02cbbc7 100644
--- a/lsp.h
+++ b/lsp.h
@@ -251,7 +251,6 @@ typedef struct {
typedef struct {
LSPString label;
- LSPString documentation;
// NOTE: LSP gives us parameter information for *all*
// parameters, but we only really need it for the active parameter.
@@ -259,8 +258,6 @@ typedef struct {
// part of it should be highlighted for the active parameter
u16 active_start;
u16 active_end;
- // documentation for the active parameter
- LSPString active_documentation;
} LSPSignatureInformation;
typedef struct {