summaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
authoradamdottv <[email protected]>2025-05-01 07:28:37 -0500
committeradamdottv <[email protected]>2025-05-01 07:28:37 -0500
commitf2b36b92347622f4c7f150c8dcef7218960d0702 (patch)
treef03a83e5a9a7647e9766437b69217f032f9ac5fe /internal
parentf224978bbcc0b2995e6492cf73d0fab930217e91 (diff)
downloadopencode-f2b36b92347622f4c7f150c8dcef7218960d0702.tar.gz
opencode-f2b36b92347622f4c7f150c8dcef7218960d0702.zip
fix: remove lsp tool
Diffstat (limited to 'internal')
-rw-r--r--internal/llm/agent/tools.go1
-rw-r--r--internal/llm/tools/lsp.go49
-rw-r--r--internal/lsp/discovery/tool/lsp_tool.go92
-rw-r--r--internal/tui/components/chat/chat.go2
4 files changed, 1 insertions, 143 deletions
diff --git a/internal/llm/agent/tools.go b/internal/llm/agent/tools.go
index df1dd1b66..e6b0119ae 100644
--- a/internal/llm/agent/tools.go
+++ b/internal/llm/agent/tools.go
@@ -35,7 +35,6 @@ func CoderAgentTools(
tools.NewViewTool(lspClients),
tools.NewPatchTool(lspClients, permissions, history),
tools.NewWriteTool(lspClients, permissions, history),
- tools.NewConfigureLspServerTool(),
NewAgentTool(sessions, messages, lspClients),
}, otherTools...,
)
diff --git a/internal/llm/tools/lsp.go b/internal/llm/tools/lsp.go
deleted file mode 100644
index c2b4b04f3..000000000
--- a/internal/llm/tools/lsp.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package tools
-
-import (
- "context"
- "encoding/json"
- "fmt"
-
- "github.com/opencode-ai/opencode/internal/lsp/discovery/tool"
-)
-
-// ConfigureLspServerTool is a tool for configuring LSP servers
-type ConfigureLspServerTool struct{}
-
-// NewConfigureLspServerTool creates a new ConfigureLspServerTool
-func NewConfigureLspServerTool() *ConfigureLspServerTool {
- return &ConfigureLspServerTool{}
-}
-
-// Info returns information about the tool
-func (t *ConfigureLspServerTool) Info() ToolInfo {
- return ToolInfo{
- Name: "configureLspServer",
- Description: "Searches for an LSP server for the given language",
- Parameters: map[string]any{
- "language": map[string]any{
- "type": "string",
- "description": "The language identifier (e.g., \"go\", \"typescript\", \"python\")",
- },
- },
- Required: []string{"language"},
- }
-}
-
-// Run executes the tool
-func (t *ConfigureLspServerTool) Run(ctx context.Context, params ToolCall) (ToolResponse, error) {
- result, err := tool.ConfigureLspServer(ctx, json.RawMessage(params.Input))
- if err != nil {
- return NewTextErrorResponse(err.Error()), nil
- }
-
- // Convert the result to JSON
- resultJSON, err := json.MarshalIndent(result, "", " ")
- if err != nil {
- return NewTextErrorResponse(fmt.Sprintf("Failed to marshal result: %v", err)), nil
- }
-
- return NewTextResponse(string(resultJSON)), nil
-}
-
diff --git a/internal/lsp/discovery/tool/lsp_tool.go b/internal/lsp/discovery/tool/lsp_tool.go
deleted file mode 100644
index c1f2f73a3..000000000
--- a/internal/lsp/discovery/tool/lsp_tool.go
+++ /dev/null
@@ -1,92 +0,0 @@
-package tool
-
-import (
- "context"
- "encoding/json"
- "fmt"
-
- "github.com/opencode-ai/opencode/internal/config"
- "github.com/opencode-ai/opencode/internal/logging"
- "github.com/opencode-ai/opencode/internal/lsp/discovery"
-)
-
-// ConfigureLspServerRequest represents the request for the configureLspServer tool
-type ConfigureLspServerRequest struct {
- // Language identifier (e.g., "go", "typescript", "python")
- Language string `json:"language"`
-}
-
-// ConfigureLspServerResponse represents the response from the configureLspServer tool
-type ConfigureLspServerResponse struct {
- // Whether the server was found
- Found bool `json:"found"`
-
- // Path to the server executable
- Path string `json:"path,omitempty"`
-
- // Command to run the server
- Command string `json:"command,omitempty"`
-
- // Arguments to pass to the command
- Args []string `json:"args,omitempty"`
-
- // Installation instructions if the server was not found
- InstallInstructions string `json:"installInstructions,omitempty"`
-
- // Whether the server was added to the configuration
- Added bool `json:"added,omitempty"`
-}
-
-// ConfigureLspServer searches for an LSP server for the given language
-func ConfigureLspServer(ctx context.Context, rawArgs json.RawMessage) (any, error) {
- var args ConfigureLspServerRequest
- if err := json.Unmarshal(rawArgs, &args); err != nil {
- return nil, fmt.Errorf("failed to parse arguments: %w", err)
- }
-
- if args.Language == "" {
- return nil, fmt.Errorf("language parameter is required")
- }
-
- // Find the LSP server for the language
- serverInfo, err := discovery.FindLSPServer(args.Language)
- if err != nil {
- // Server not found, return instructions
- return ConfigureLspServerResponse{
- Found: false,
- Command: serverInfo.Command,
- Args: serverInfo.Args,
- InstallInstructions: serverInfo.InstallCmd,
- Added: false,
- }, nil
- }
-
- // Server found, update the configuration if available
- added := false
- if serverInfo.Available {
- // Get the current configuration
- cfg := config.Get()
- if cfg != nil {
- // Add the server to the configuration
- cfg.LSP[args.Language] = config.LSPConfig{
- Disabled: false,
- Command: serverInfo.Path,
- Args: serverInfo.Args,
- }
- added = true
- logging.Info("Added LSP server to configuration",
- "language", args.Language,
- "command", serverInfo.Command,
- "path", serverInfo.Path)
- }
- }
-
- // Return the server information
- return ConfigureLspServerResponse{
- Found: true,
- Path: serverInfo.Path,
- Command: serverInfo.Command,
- Args: serverInfo.Args,
- Added: added,
- }, nil
-} \ No newline at end of file
diff --git a/internal/tui/components/chat/chat.go b/internal/tui/components/chat/chat.go
index 8623b3d7b..a372868e1 100644
--- a/internal/tui/components/chat/chat.go
+++ b/internal/tui/components/chat/chat.go
@@ -35,7 +35,7 @@ func header(width int) string {
func lspsConfigured(width int) string {
cfg := config.Get()
- title := "LSP Configuration"
+ title := "LSP Servers"
title = ansi.Truncate(title, width, "…")
t := theme.CurrentTheme()