From 4c562f926e13de8d040029e954b7cf407134a8bb Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 2 Mar 2026 14:24:36 +0200 Subject: lsp: use appconfig.CustomAction directly for custom actions (task 411) --- internal/lsp/handlers_codeaction.go | 3 ++- internal/lsp/server.go | 27 ++------------------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/internal/lsp/handlers_codeaction.go b/internal/lsp/handlers_codeaction.go index 7798f24..58d7134 100644 --- a/internal/lsp/handlers_codeaction.go +++ b/internal/lsp/handlers_codeaction.go @@ -9,6 +9,7 @@ import ( "strings" "time" + "codeberg.org/snonux/hexai/internal/appconfig" "codeberg.org/snonux/hexai/internal/llm" "codeberg.org/snonux/hexai/internal/logging" ) @@ -380,7 +381,7 @@ func formatCustomDiagnostics(diagnostics []Diagnostic) string { return b.String() } -func (s *Server) customActionByID(id string) *CustomAction { +func (s *Server) customActionByID(id string) *appconfig.CustomAction { for _, item := range s.customActions() { if item.ID == id { action := item diff --git a/internal/lsp/server.go b/internal/lsp/server.go index bf1f724..573428b 100644 --- a/internal/lsp/server.go +++ b/internal/lsp/server.go @@ -85,17 +85,6 @@ type ServerOptions struct { IgnoreChecker *ignore.Checker } -// CustomAction mirrors user-defined code actions passed from config. -type CustomAction struct { - ID string - Title string - Kind string - Scope string // "selection" | "diagnostics" - Instruction string // if set, use rewrite templates - System string // optional when User is set - User string // if set, use this user template -} - func NewServer(r io.Reader, w io.Writer, logger *log.Logger, opts ServerOptions) *Server { ctx, cancel := context.WithCancel(context.Background()) s := &Server{ @@ -401,24 +390,12 @@ func (s *Server) promptSet() appconfig.App { return s.currentConfig() } -func (s *Server) customActions() []CustomAction { +func (s *Server) customActions() []appconfig.CustomAction { cfg := s.currentConfig() if len(cfg.CustomActions) == 0 { return nil } - customs := make([]CustomAction, 0, len(cfg.CustomActions)) - for _, ca := range cfg.CustomActions { - customs = append(customs, CustomAction{ - ID: ca.ID, - Title: ca.Title, - Kind: ca.Kind, - Scope: ca.Scope, - Instruction: ca.Instruction, - System: ca.System, - User: ca.User, - }) - } - return customs + return append([]appconfig.CustomAction{}, cfg.CustomActions...) } func (s *Server) requestTimeoutContext(timeout time.Duration) (context.Context, context.CancelFunc) { -- cgit v1.2.3