summaryrefslogtreecommitdiff
path: root/lsp.h
diff options
context:
space:
mode:
Diffstat (limited to 'lsp.h')
-rw-r--r--lsp.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/lsp.h b/lsp.h
index c267283..a7fa9b0 100644
--- a/lsp.h
+++ b/lsp.h
@@ -97,6 +97,7 @@ typedef enum {
LSP_REQUEST_LOG_MESSAGE, //< window/logMessage
LSP_REQUEST_WORKSPACE_FOLDERS, //< workspace/workspaceFolders - NOTE: this is handled directly in lsp-parse.c (because it only needs information from the LSP struct)
LSP_REQUEST_PUBLISH_DIAGNOSTICS, //< textDocument/publishDiagnostics
+ LSP_REQUEST_CODE_ACTION, //< textDocument/codeAction
} LSPRequestType;
typedef enum {
@@ -170,6 +171,8 @@ typedef struct {
/// URI to description of code
/// e.g. for Rust's E0621, this would be https://doc.rust-lang.org/error_codes/E0621.html
LSPString code_description_uri;
+ // raw diagnostic object, to be used with textDocument/codeAction
+ LSPString raw;
} LSPDiagnostic;
typedef struct {
@@ -259,6 +262,12 @@ typedef struct {
} LSPRequestFormatting;
typedef struct {
+ LSPDocumentID document;
+ LSPRange range;
+ LSPString *raw_diagnostics;
+} LSPRequestCodeAction;
+
+typedef struct {
LSPMessageType type;
/// LSP requests/responses tend to have a lot of strings.
/// to avoid doing a ton of allocations+frees,
@@ -296,6 +305,7 @@ typedef struct {
LSPRequestPublishDiagnostics publish_diagnostics;
// LSP_REQUEST_FORMATTING and LSP_REQUEST_RANGE_FORMATTING
LSPRequestFormatting formatting;
+ LSPRequestCodeAction code_action;
} data;
} LSPRequest;
@@ -565,6 +575,35 @@ typedef struct {
LSPTextEdit *edits;
} LSPResponseFormatting;
+typedef enum {
+ LSP_COMMAND_NONE,
+ LSP_COMMAND_WORKSPACE_EDIT,
+} LSPCommandKind;
+
+typedef struct {
+ LSPCommandKind kind;
+ union {
+ LSPWorkspaceEdit edit;
+ } data;
+} LSPCommand;
+
+typedef enum {
+ LSP_CODE_ACTION_OTHER,
+ LSP_CODE_ACTION_QUICKFIX,
+} LSPCodeActionKind;
+
+typedef struct {
+ LSPString name;
+ LSPWorkspaceEdit edit;
+ LSPCodeActionKind kind;
+ bool is_preferred;
+ LSPCommand command;
+} LSPCodeAction;
+
+typedef struct {
+ LSPCodeAction *actions;
+} LSPResponseCodeAction;
+
typedef struct {
LSPMessageBase base;
/// the request which this is a response to
@@ -586,6 +625,7 @@ typedef struct {
LSPResponseDocumentLink document_link;
/// `LSP_REQUEST_FORMATTING` or `LSP_REQUEST_RANGE_FORMATTING`
LSPResponseFormatting formatting;
+ LSPResponseCodeAction code_action;
} data;
} LSPResponse;
@@ -629,6 +669,7 @@ typedef struct {
bool document_link_support;
bool formatting_support;
bool range_formatting_support;
+ bool code_action_support;
} LSPCapabilities;
typedef struct LSP LSP;
@@ -669,6 +710,7 @@ void lsp_register_language(u64 id, const char *lsp_identifier);
// if clear = true, the error will be cleared.
// 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_response_free(LSPResponse *response);
void lsp_message_free(LSPMessage *message);
u32 lsp_document_id(LSP *lsp, const char *path);
// returned pointer lives as long as lsp.
@@ -935,8 +977,11 @@ size_t json_escape_to(char *out, size_t out_sz, const char *in);
char *json_escape(const char *str);
LSPString lsp_response_add_json_string(LSPResponse *response, const JSON *json, JSONString string);
LSPString lsp_request_add_json_string(LSPRequest *request, const JSON *json, JSONString string);
+void lsp_workspace_edit_free(LSPWorkspaceEdit *edit);
/// free resources used by lsp-write.c
void lsp_write_quit(void);
+// convert JSON value back into string
+char *json_reserialize(const JSON *json, JSONValue value);
/// print server-to-client communication
#define LSP_SHOW_S2C 0