Skip to content

Commit 9d859f4

Browse files
committed
Auto-detect arduino-cli.yaml in ~/.arduino15
1 parent e7b8550 commit 9d859f4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Diff for: main.go

+11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"os"
1010
"os/exec"
1111
"os/signal"
12+
"os/user"
13+
"path"
1214

1315
"github.com/arduino/arduino-language-server/ls"
1416
"github.com/arduino/arduino-language-server/streams"
@@ -75,6 +77,15 @@ func main() {
7577
log.Fatal("ArduinoCLI daemon address and instance number must be set.")
7678
}
7779
} else {
80+
if *cliConfigPath == "" {
81+
if user, _ := user.Current(); user != nil {
82+
candidate := path.Join(user.HomeDir, ".arduino15/arduino-cli.yaml")
83+
if _, err := os.Stat(candidate); err == nil {
84+
*cliConfigPath = candidate
85+
log.Printf("ArduinoCLI config file found at %s\n", candidate)
86+
}
87+
}
88+
}
7889
if *cliConfigPath == "" {
7990
log.Fatal("Path to ArduinoCLI config file must be set.")
8091
}

0 commit comments

Comments
 (0)