config-lsp/server/handlers/wireguard/lsp/text-document-code-action.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

25 lines
625 B
Go

package lsp
import (
"config-lsp/handlers/wireguard"
"config-lsp/handlers/wireguard/handlers"
"github.com/tliron/glsp"
protocol "github.com/tliron/glsp/protocol_3_16"
)
func TextDocumentCodeAction(context *glsp.Context, params *protocol.CodeActionParams) ([]protocol.CodeAction, error) {
d := wireguard.DocumentParserMap[params.TextDocument.URI]
actions := make([]protocol.CodeAction, 0, 2)
actions = append(actions, handlers.GetKeyGenerationCodeActions(d, params)...)
actions = append(actions, handlers.GetKeepaliveCodeActions(d, params)...)
if len(actions) > 0 {
return actions, nil
}
return nil, nil
}