diff options
author | pommicket <pommicket@gmail.com> | 2023-09-08 22:59:47 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-09-08 22:59:47 -0400 |
commit | 0dcfd5a4f1fd865c24c01b17b214e1f72e4c06fe (patch) | |
tree | d693d70a57713cf4dbe48d30159100bab279c77d /lsp-write.c | |
parent | f86b0aa1e843646056c08a91fcc759aa0d8a57ba (diff) |
LSP code formatting (not entirely working yet)
Diffstat (limited to 'lsp-write.c')
-rw-r--r-- | lsp-write.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lsp-write.c b/lsp-write.c index 17aef7f..050d784 100644 --- a/lsp-write.c +++ b/lsp-write.c @@ -302,6 +302,10 @@ static const char *lsp_request_method(LSPRequest *request) { return "workspace/didChangeConfiguration"; case LSP_REQUEST_WORKSPACE_SYMBOLS: return "workspace/symbol"; + case LSP_REQUEST_RANGE_FORMATTING: + return "textDocument/rangeFormatting"; + case LSP_REQUEST_FORMATTING: + return "textDocument/formatting"; } assert(0); return "$/ignore"; @@ -652,6 +656,22 @@ void write_request(LSP *lsp, LSPRequest *request) { str_builder_append(&o->builder, lsp_request_string(request, config->settings)); write_obj_end(o); } break; + case LSP_REQUEST_FORMATTING: + case LSP_REQUEST_RANGE_FORMATTING: { + const LSPRequestFormatting *formatting = &request->data.formatting; + write_key_obj_start(o, "params"); + write_key_obj_start(o, "textDocument"); + write_key_file_uri(o, "uri", formatting->document); + write_obj_end(o); + write_key_obj_start(o, "options"); + write_key_number(o, "tabSize", formatting->tab_width); + write_key_bool(o, "insertSpaces", formatting->indent_with_spaces); + write_obj_end(o); + if (formatting->use_range) { + write_key_range(o, "range", formatting->range); + } + write_obj_end(o); + } break; } write_obj_end(o); |