summaryrefslogtreecommitdiff
path: root/autocomplete.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-12-29 12:12:36 -0500
committerpommicket <pommicket@gmail.com>2022-12-29 12:12:36 -0500
commit18fbb21e6b95139a8890ba4a65f4402df128ac84 (patch)
treee72f8f462465d14bf48a88372f90d2d347f025c9 /autocomplete.c
parent948decc409bac1e3671afc5d0212b4b35c669b4a (diff)
working hover
Diffstat (limited to 'autocomplete.c')
-rw-r--r--autocomplete.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/autocomplete.c b/autocomplete.c
index 1271fba..1d03c75 100644
--- a/autocomplete.c
+++ b/autocomplete.c
@@ -54,6 +54,8 @@ void autocomplete_scroll(Ted *ted, i32 by) {
static void autocomplete_move_cursor(Ted *ted, i32 by) {
Autocomplete *ac = &ted->autocomplete;
u32 ncompletions = arr_len(ac->suggested);
+ if (ncompletions == 0)
+ return;
i32 cursor = ac->cursor;
cursor += by;
cursor = (i32)mod_i32(cursor, (i32)ncompletions);
@@ -186,6 +188,52 @@ static void autocomplete_find_completions(Ted *ted, uint32_t trigger) {
autocomplete_update_suggested(ted);
}
+static SymbolKind lsp_completion_kind_to_ted(LSPCompletionKind kind) {
+ switch (kind) {
+ case LSP_COMPLETION_TEXT:
+ case LSP_COMPLETION_MODULE:
+ case LSP_COMPLETION_UNIT:
+ case LSP_COMPLETION_COLOR:
+ case LSP_COMPLETION_FILE:
+ case LSP_COMPLETION_REFERENCE:
+ case LSP_COMPLETION_FOLDER:
+ case LSP_COMPLETION_OPERATOR:
+ return SYMBOL_OTHER;
+
+ case LSP_COMPLETION_METHOD:
+ case LSP_COMPLETION_FUNCTION:
+ case LSP_COMPLETION_CONSTRUCTOR:
+ return SYMBOL_FUNCTION;
+
+ case LSP_COMPLETION_FIELD:
+ case LSP_COMPLETION_PROPERTY:
+ return SYMBOL_FIELD;
+
+ case LSP_COMPLETION_VARIABLE:
+ return SYMBOL_VARIABLE;
+
+ case LSP_COMPLETION_CLASS:
+ case LSP_COMPLETION_INTERFACE:
+ case LSP_COMPLETION_ENUM:
+ case LSP_COMPLETION_STRUCT:
+ case LSP_COMPLETION_EVENT:
+ case LSP_COMPLETION_TYPEPARAMETER:
+ return SYMBOL_TYPE;
+
+ case LSP_COMPLETION_VALUE:
+ case LSP_COMPLETION_ENUMMEMBER:
+ case LSP_COMPLETION_CONSTANT:
+ return SYMBOL_CONSTANT;
+
+ case LSP_COMPLETION_KEYWORD:
+ case LSP_COMPLETION_SNIPPET:
+ return SYMBOL_KEYWORD;
+ }
+ assert(0);
+ return SYMBOL_OTHER;
+}
+
+
static void autocomplete_process_lsp_response(Ted *ted, const LSPResponse *response) {
const LSPRequest *request = &response->request;
if (request->type != LSP_REQUEST_COMPLETION)