mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-19 07:25:27 +02:00
feat: Add root handler for text document range formatting
This commit is contained in:
parent
3ffd1f4c4b
commit
ad8311d0c6
39
root-handler/text-document-range-formatting.go
Normal file
39
root-handler/text-document-range-formatting.go
Normal 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)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user