diff options
author | pommicket <pommicket@gmail.com> | 2022-12-22 16:27:06 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-22 16:27:06 -0500 |
commit | 6bb4da5fab94d2ed3d093b996674fd1cc28eda2f (patch) | |
tree | d986574a0100cd4d35782585a8309815f8bf1b49 /lsp.h | |
parent | f2296487cf9b2e86261eaf1d448b723f3ef70202 (diff) |
document IDs instead of documents
Diffstat (limited to 'lsp.h')
-rw-r--r-- | lsp.h | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -7,6 +7,8 @@ // (if the server never sends a response) // - TESTING: make rust-analyzer-slow (waits 10s before sending response) +typedef u32 DocumentID; + typedef enum { LSP_REQUEST, LSP_RESPONSE @@ -45,10 +47,8 @@ typedef enum { } LSPRequestType; typedef struct { - // buffer language Language language; - // freed by lsp_request_free - char *document; + DocumentID document; // freed by lsp_request_free char *file_contents; } LSPRequestDidOpen; @@ -61,7 +61,7 @@ typedef struct { } LSPDocumentChangeEvent; typedef struct { - char *document; + DocumentID document; LSPDocumentChangeEvent *changes; // dynamic array } LSPRequestDidChange; @@ -79,8 +79,7 @@ typedef struct { } LSPRequestMessage; typedef struct { - // freed by lsp_request_free - char *document; + DocumentID document; LSPPosition pos; } LSPDocumentPosition; @@ -166,6 +165,10 @@ typedef struct { typedef struct LSP { Process process; u32 request_id; + StrHashTable document_ids; // values are u32. they are indices into document_filenames. + // this is a dynamic array which just keeps growing. + // but the user isn't gonna open millions of files so it's fine. + char **document_paths; LSPMessage *messages; SDL_mutex *messages_mutex; LSPRequest *requests_client2server; @@ -194,6 +197,7 @@ typedef struct LSP { // you can set error = NULL, error_size = 0, clear = true to just clear the error bool lsp_get_error(LSP *lsp, char *error, size_t error_size, bool clear); void lsp_message_free(LSPMessage *message); +u32 lsp_document_id(LSP *lsp, const char *path); void lsp_send_request(LSP *lsp, const LSPRequest *request); const char *lsp_response_string(const LSPResponse *response, LSPString string); bool lsp_create(LSP *lsp, const char *analyzer_command); |