diff options
| author | Albert Cervin <albert@acervin.com> | 2024-05-22 00:00:29 +0200 |
|---|---|---|
| committer | Albert Cervin <albert@acervin.com> | 2024-09-12 20:17:56 +0200 |
| commit | 405da5f84b072ea97b69359454899f45d92d24b6 (patch) | |
| tree | 20525b4bc44a5d8cbab4d62abe8413e174731db6 /src/dged/lsp.h | |
| parent | 4ab7e453e26afc6e9f4938c65f89463fbba9e267 (diff) | |
| download | dged-405da5f84b072ea97b69359454899f45d92d24b6.tar.gz dged-405da5f84b072ea97b69359454899f45d92d24b6.tar.xz dged-405da5f84b072ea97b69359454899f45d92d24b6.zip | |
WIP LSP client
This contains the start of an LSP client.
Nothing (except starting the LSP server) works
at the moment and the feature is disabled by default.
Diffstat (limited to 'src/dged/lsp.h')
| -rw-r--r-- | src/dged/lsp.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/dged/lsp.h b/src/dged/lsp.h new file mode 100644 index 0000000..3fd6285 --- /dev/null +++ b/src/dged/lsp.h @@ -0,0 +1,75 @@ +#ifndef _LSP_H +#define _LSP_H + +#include "location.h" +#include "s8.h" + +struct buffer; +struct lsp; +struct reactor; + +typedef uint32_t request_id; + +struct lsp_response { + request_id id; + bool ok; + union payload_data { + void *result; + struct s8 error; + } payload; +}; + +struct lsp_notification { + int something; +}; + +struct lsp_client { + void (*log_message)(int type, struct s8 msg); +}; + +struct hover { + struct s8 contents; + + bool has_range; + struct region *range; +}; + +struct text_doc_item { + struct s8 uri; + struct s8 language_id; + uint32_t version; + struct s8 text; +}; + +struct text_doc_position { + struct s8 uri; + struct location pos; +}; + +struct initialize_params { + struct s8 client_name; + struct s8 client_version; +}; + +// lifecycle functions +struct lsp *lsp_create(char *const command[], struct reactor *reactor, + struct buffer *stderr_buffer, + struct lsp_client client_impl, const char *name); +uint32_t lsp_update(struct lsp *lsp, struct lsp_response **responses, + uint32_t responses_capacity); +void lsp_destroy(struct lsp *lsp); + +// process control functions +int lsp_start_server(struct lsp *lsp); +int lsp_restart_server(struct lsp *lsp); +void lsp_stop_server(struct lsp *lsp); +bool lsp_server_running(const struct lsp *lsp); +uint64_t lsp_server_pid(const struct lsp *lsp); +const char *lsp_server_name(const struct lsp *lsp); + +// protocol functions +void lsp_initialize(struct lsp *lsp, struct initialize_params); +void lsp_did_open_document(struct lsp *lsp, struct text_doc_item document); +request_id lsp_hover(struct lsp *lsp, struct text_doc_position); + +#endif |
