mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-26 09:31:59 +00:00
Add structures to support document formatting
This commit is contained in:
parent
5680ff2592
commit
abc2edf05f
@ -34,6 +34,8 @@ const char* IpcIdToString(IpcId id) {
|
||||
return "textDocument/documentHighlight";
|
||||
case IpcId::TextDocumentHover:
|
||||
return "textDocument/hover";
|
||||
case IpcId::TextDocumentFormatting:
|
||||
return "textDocument/formatting";
|
||||
case IpcId::TextDocumentReferences:
|
||||
return "textDocument/references";
|
||||
case IpcId::TextDocumentDocumentSymbol:
|
||||
|
@ -22,6 +22,7 @@ enum class IpcId : int {
|
||||
TextDocumentDefinition,
|
||||
TextDocumentDocumentHighlight,
|
||||
TextDocumentHover,
|
||||
TextDocumentFormatting,
|
||||
TextDocumentReferences,
|
||||
TextDocumentDocumentSymbol,
|
||||
TextDocumentDocumentLink,
|
||||
|
@ -273,6 +273,25 @@ struct lsTextDocumentPositionParams {
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(lsTextDocumentPositionParams, textDocument, position);
|
||||
|
||||
struct lsFormattingOptions {
|
||||
// Size of a tab in spaces.
|
||||
int tabSize;
|
||||
// Prefer spaces over tabs.
|
||||
bool insertSpaces;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(lsFormattingOptions, tabSize, insertSpaces);
|
||||
|
||||
struct lsTextDocumentFormattingParams {
|
||||
// The text document.
|
||||
lsTextDocumentIdentifier textDocument;
|
||||
|
||||
// The format options, like tabs or spaces.
|
||||
lsFormattingOptions formattingOptions;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(lsTextDocumentFormattingParams,
|
||||
textDocument,
|
||||
formattingOptions);
|
||||
|
||||
struct lsTextEdit {
|
||||
// The range of the text document to be manipulated. To insert
|
||||
// text into a document create a range where start === end.
|
||||
|
20
src/messages/text_document_formatting.cc
Normal file
20
src/messages/text_document_formatting.cc
Normal file
@ -0,0 +1,20 @@
|
||||
#include "message_handler.h"
|
||||
|
||||
namespace {
|
||||
struct Ipc_TextDocumentFormatting
|
||||
: public IpcMessage<Ipc_TextDocumentFormatting> {
|
||||
const static IpcId kIpcId = IpcId::TextDocumentFormatting;
|
||||
|
||||
lsRequestId id;
|
||||
lsTextDocumentFormattingParams params;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentFormatting, id, params);
|
||||
REGISTER_IPC_MESSAGE(Ipc_TextDocumentFormatting);
|
||||
|
||||
struct Out_TextDocumentFormatting
|
||||
: public lsOutMessage<Out_TextDocumentFormatting> {
|
||||
lsRequestId id;
|
||||
std::vector<lsTextEdit> edits;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(Out_TextDocumentFormatting, jsonrpc, id, edits);
|
||||
} // namespace
|
Loading…
Reference in New Issue
Block a user