config-lsp/server/root-handler/lsp/text-document-range-formatting.go
2024-10-27 12:10:20 +01:00

40 lines
1.0 KiB
Go

package lsp
import (
sshconfig "config-lsp/handlers/ssh_config/lsp"
sshdconfig "config-lsp/handlers/sshd_config/lsp"
"config-lsp/root-handler/shared"
"config-lsp/root-handler/utils"
"github.com/tliron/glsp"
protocol "github.com/tliron/glsp/protocol_3_16"
)
func TextDocumentRangeFormattingFunc(
context *glsp.Context,
params *protocol.DocumentRangeFormattingParams,
) ([]protocol.TextEdit, error) {
language := shared.Handler.GetLanguageForDocument(params.TextDocument.URI)
if language == nil {
return nil, utils.LanguageUndetectableError{}
}
switch *language {
case shared.LanguageHosts:
return nil, nil
case shared.LanguageSSHDConfig:
return sshdconfig.TextDocumentRangeFormatting(context, params)
case shared.LanguageSSHConfig:
return sshconfig.TextDocumentRangeFormatting(context, params)
case shared.LanguageFstab:
return nil, nil
case shared.LanguageWireguard:
return nil, nil
case shared.LanguageAliases:
return nil, nil
}
panic("root-handler/TextDocumentRangeFormattingFunc: unexpected language" + *language)
}