diff --git a/internal/lsp/client.go b/internal/lsp/client.go index 18bc1ed954acbf4a0397dfa497bd2133513bb090..bc8d31dba0360aed813d4b9cf6e5b769bb2559d4 100644 --- a/internal/lsp/client.go +++ b/internal/lsp/client.go @@ -277,10 +277,6 @@ func (c *Client) WaitForServerReady(ctx context.Context) error { // Set initial state c.SetServerState(StateStarting) - // Create a context with timeout - ctx, cancel := context.WithTimeout(ctx, 30*time.Second) - defer cancel() - // Try to ping the server with a simple request ticker := time.NewTicker(500 * time.Millisecond) defer ticker.Stop() @@ -495,14 +491,9 @@ func (c *Client) RegisterServerRequestHandler(method string, handler transport.H // openKeyConfigFiles opens important configuration files that help initialize the server. func (c *Client) openKeyConfigFiles(ctx context.Context) { - wd, err := os.Getwd() - if err != nil { - return - } - // Try to open each file, ignoring errors if they don't exist for _, file := range c.config.RootMarkers { - file = filepath.Join(wd, file) + file = filepath.Join(c.cwd, file) if _, err := os.Stat(file); err == nil { // File exists, try to open it if err := c.OpenFile(ctx, file); err != nil { diff --git a/internal/lsp/handlers.go b/internal/lsp/handlers.go index 9674ab22c226a4662beb08daa813325b52c079af..63ad93b2dd1cbc856eda4a9e41884dfc27e93870 100644 --- a/internal/lsp/handlers.go +++ b/internal/lsp/handlers.go @@ -81,7 +81,7 @@ func notifyFileWatchRegistration(id string, watchers []protocol.FileSystemWatche func HandleServerMessage(_ context.Context, method string, params json.RawMessage) { var msg protocol.ShowMessageParams if err := json.Unmarshal(params, &msg); err != nil { - slog.Debug("Server message", "type", msg.Type, "message", msg.Message) + slog.Debug("Error unmarshal server message", "error", err) return } diff --git a/internal/lsp/manager.go b/internal/lsp/manager.go index d77b0cc673428045198f38757962c1326573dece..f436b3cb3433d9c7e6c5ef28a3cff8bfa17f447f 100644 --- a/internal/lsp/manager.go +++ b/internal/lsp/manager.go @@ -229,6 +229,7 @@ func (s *Manager) startServer(ctx context.Context, name, filepath string, server if _, err := client.Initialize(initCtx, s.cfg.WorkingDir()); err != nil { slog.Error("LSP client initialization failed", "name", name, "error", err) client.Close(ctx) + s.clients.Del(name) return }