|
@@ -3,7 +3,6 @@ package cmd
|
|
|
import (
|
|
import (
|
|
|
"context"
|
|
"context"
|
|
|
"fmt"
|
|
"fmt"
|
|
|
- "io"
|
|
|
|
|
"os"
|
|
"os"
|
|
|
"sync"
|
|
"sync"
|
|
|
"time"
|
|
"time"
|
|
@@ -15,7 +14,6 @@ import (
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/cobra"
|
|
|
"github.com/sst/opencode/internal/config"
|
|
"github.com/sst/opencode/internal/config"
|
|
|
"github.com/sst/opencode/internal/logging"
|
|
"github.com/sst/opencode/internal/logging"
|
|
|
- "github.com/sst/opencode/internal/lsp/discovery"
|
|
|
|
|
"github.com/sst/opencode/internal/pubsub"
|
|
"github.com/sst/opencode/internal/pubsub"
|
|
|
"github.com/sst/opencode/internal/tui"
|
|
"github.com/sst/opencode/internal/tui"
|
|
|
"github.com/sst/opencode/internal/tui/app"
|
|
"github.com/sst/opencode/internal/tui/app"
|
|
@@ -69,12 +67,6 @@ to assist developers in writing, debugging, and understanding code directly from
|
|
|
return err
|
|
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
|
|
// Create main context for the application
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
defer cancel()
|
|
defer cancel()
|
|
@@ -92,6 +84,18 @@ to assist developers in writing, debugging, and understanding code directly from
|
|
|
tea.WithAltScreen(),
|
|
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
|
|
// Setup the subscriptions, this will send services events to the TUI
|
|
|
ch, cancelSubs := setupSubscriptions(app, ctx)
|
|
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 function for when the program exits
|
|
|
cleanup := func() {
|
|
cleanup := func() {
|
|
|
// Cancel subscriptions first
|
|
// 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() {
|
|
func init() {
|
|
|
rootCmd.Flags().BoolP("help", "h", false, "Help")
|
|
rootCmd.Flags().BoolP("help", "h", false, "Help")
|
|
|
rootCmd.Flags().BoolP("version", "v", false, "Version")
|
|
rootCmd.Flags().BoolP("version", "v", false, "Version")
|