summaryrefslogtreecommitdiffhomepage
path: root/cmd
diff options
context:
space:
mode:
authoradamdottv <[email protected]>2025-05-29 14:39:37 -0500
committeradamdottv <[email protected]>2025-05-29 14:39:37 -0500
commit50ba0b380bbbd5b78c1399f15c6b785c223fc620 (patch)
tree7857e485fe46fb97625d464a1f59dd08d5107e60 /cmd
parent6cccbdccd3139c9d548d3794e88d1f7065def7d4 (diff)
downloadopencode-50ba0b380bbbd5b78c1399f15c6b785c223fc620.tar.gz
opencode-50ba0b380bbbd5b78c1399f15c6b785c223fc620.zip
wip: refactoring tui
Diffstat (limited to 'cmd')
-rw-r--r--cmd/root.go51
1 files changed, 12 insertions, 39 deletions
diff --git a/cmd/root.go b/cmd/root.go
index ccee60d39..f9a55babe 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -3,7 +3,6 @@ package cmd
import (
"context"
"fmt"
- "io"
"os"
"sync"
"time"
@@ -15,7 +14,6 @@ import (
"github.com/spf13/cobra"
"github.com/sst/opencode/internal/config"
"github.com/sst/opencode/internal/logging"
- "github.com/sst/opencode/internal/lsp/discovery"
"github.com/sst/opencode/internal/pubsub"
"github.com/sst/opencode/internal/tui"
"github.com/sst/opencode/internal/tui/app"
@@ -69,12 +67,6 @@ to assist developers in writing, debugging, and understanding code directly from
return err
}
- // Run LSP auto-discovery
- if err := discovery.IntegrateLSPServers(cwd); err != nil {
- slog.Warn("Failed to auto-discover LSP servers", "error", err)
- // Continue anyway, this is not a fatal error
- }
-
// Create main context for the application
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
@@ -92,6 +84,18 @@ to assist developers in writing, debugging, and understanding code directly from
tea.WithAltScreen(),
)
+ evts, err := app.Events.Event(ctx)
+ if err != nil {
+ slog.Error("Failed to subscribe to events", "error", err)
+ return err
+ }
+
+ go func() {
+ for item := range evts {
+ program.Send(item)
+ }
+ }()
+
// Setup the subscriptions, this will send services events to the TUI
ch, cancelSubs := setupSubscriptions(app, ctx)
@@ -122,18 +126,6 @@ to assist developers in writing, debugging, and understanding code directly from
}
}()
- evts, err := app.Events.Event(ctx)
- if err != nil {
- slog.Error("Failed to subscribe to events", "error", err)
- return err
- }
-
- go func() {
- for item := range evts {
- program.Send(item)
- }
- }()
-
// Cleanup function for when the program exits
cleanup := func() {
// Cancel subscriptions first
@@ -256,25 +248,6 @@ func Execute() {
}
}
-// checkStdinPipe checks if there's data being piped into stdin
-func checkStdinPipe() (string, bool) {
- // Check if stdin is not a terminal (i.e., it's being piped)
- stat, _ := os.Stdin.Stat()
- if (stat.Mode() & os.ModeCharDevice) == 0 {
- // Read all data from stdin
- data, err := io.ReadAll(os.Stdin)
- if err != nil {
- return "", false
- }
-
- // If we got data, return it
- if len(data) > 0 {
- return string(data), true
- }
- }
- return "", false
-}
-
func init() {
rootCmd.Flags().BoolP("help", "h", false, "Help")
rootCmd.Flags().BoolP("version", "v", false, "Version")