@@ -7,6 +7,8 @@ import (
@@ -54,6 +56,16 @@ type App struct {
54 cleanupFuncs []func() error
56 cleanupFuncs []func() error
59+// isGitRepo checks if the current directory is a git repository
60+func isGitRepo() bool {
61+ bts, err := exec.CommandContext(
62+ context.Background(),
64+ "--is-inside-work-tree",
66+ return err == nil && strings.TrimSpace(string(bts)) == "true"
57// New initializes a new applcation instance.
69// New initializes a new applcation instance.
58func New(ctx context.Context, conn *sql.DB, cfg *config.Config) (*App, error) {
70func New(ctx context.Context, conn *sql.DB, cfg *config.Config) (*App, error) {
59 q := db.New(conn)
71 q := db.New(conn)
@@ -86,9 +98,13 @@ func New(ctx context.Context, conn *sql.DB, cfg *config.Config) (*App, error) {
87 app.setupEvents()
99 app.setupEvents()
89− // Start the global watcher
101+ // Start the global watcher only if this is a git repository
90− if err := watcher.Start(); err != nil {
103+ if err := watcher.Start(); err != nil {
91− return nil, fmt.Errorf("app: %w", err)
104+ return nil, fmt.Errorf("app: %w", err)
107+ slog.Warn("Not starting global watcher: not a git repository")
94 // Initialize LSP clients in the background.
110 // Initialize LSP clients in the background.