feat: Add root handler for text document range formatting

This commit is contained in:
Myzel394 2024-09-21 09:36:44 +02:00
parent 3ffd1f4c4b
commit ad8311d0c6
No known key found for this signature in database
GPG Key ID: DEC4AAB876F73185

View File

@ -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)
}