config-lsp/server/handlers/wireguard/lsp/workspace-execute-command.go
Myzel394 ff9b5db18a
refactor(server): Refactor Wireguard config; Improve completions; Improve code actions
Signed-off-by: Myzel394 <github.7a2op@simplelogin.co>
2025-03-16 00:23:54 +01:00

32 lines
883 B
Go

package lsp
import (
"config-lsp/handlers/wireguard"
"config-lsp/handlers/wireguard/handlers"
"strings"
"github.com/tliron/glsp"
protocol "github.com/tliron/glsp/protocol_3_16"
)
func WorkspaceExecuteCommand(context *glsp.Context, params *protocol.ExecuteCommandParams) (*protocol.ApplyWorkspaceEditParams, error) {
_, command, _ := strings.Cut(params.Command, ".")
switch command {
case string(handlers.CodeActionGeneratePrivateKey):
args := handlers.CodeActionGeneratePrivateKeyArgsFromArguments(params.Arguments[0].(map[string]any))
d := wireguard.DocumentParserMap[args.URI]
return args.RunCommand(d)
case string(handlers.CodeActionGeneratePresharedKey):
args := handlers.CodeActionGeneratePresharedKeyArgsFromArguments(params.Arguments[0].(map[string]any))
d := wireguard.DocumentParserMap[args.URI]
return args.RunCommand(d)
}
return nil, nil
}