diff --git a/root-handler/text-document-range-formatting.go b/root-handler/text-document-range-formatting.go new file mode 100644 index 0000000..6b4cff6 --- /dev/null +++ b/root-handler/text-document-range-formatting.go @@ -0,0 +1,39 @@ +package roothandler + +import ( + sshdconfig "config-lsp/handlers/sshd_config/lsp" + "github.com/tliron/glsp" + protocol "github.com/tliron/glsp/protocol_3_16" +) + +func TextDocumentRangeFormattingFunc( + context *glsp.Context, + params *protocol.DocumentRangeFormattingParams, +) ([]protocol.TextEdit, error) { + language := rootHandler.GetLanguageForDocument(params.TextDocument.URI) + + if language == nil { + showParseError( + context, + params.TextDocument.URI, + undetectableError, + ) + + return nil, undetectableError.Err + } + + switch *language { + case LanguageHosts: + return nil, nil + case LanguageSSHDConfig: + return sshdconfig.TextDocumentRangeFormatting(context, params) + case LanguageFstab: + return nil, nil + case LanguageWireguard: + return nil, nil + case LanguageAliases: + return nil, nil + } + + panic("root-handler/TextDocumentRangeFormattingFunc: unexpected language" + *language) +}