Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e7b8550

Browse filesBrowse files
committed
Auto-detect any clangd and arduino-cli in $PATH
1 parent 2554452 commit e7b8550
Copy full SHA for e7b8550

File tree

Expand file treeCollapse file tree

1 file changed

+22
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+22
-4
lines changed

‎main.go

Copy file name to clipboardExpand all lines: main.go
+22-4Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"net/http"
88
_ "net/http/pprof"
99
"os"
10+
"os/exec"
1011
"os/signal"
1112

1213
"github.com/arduino/arduino-language-server/ls"
@@ -68,15 +69,32 @@ func main() {
6869
log.SetOutput(os.Stderr)
6970
}
7071

71-
if *cliPath != "" {
72+
if *cliDaemonAddress != "" || *cliDaemonInstanceNumber != -1 {
73+
// if one is set, both must be set
74+
if *cliDaemonAddress == "" || *cliDaemonInstanceNumber == -1 {
75+
log.Fatal("ArduinoCLI daemon address and instance number must be set.")
76+
}
77+
} else {
7278
if *cliConfigPath == "" {
7379
log.Fatal("Path to ArduinoCLI config file must be set.")
7480
}
75-
} else if *cliDaemonAddress == "" || *cliDaemonInstanceNumber == -1 {
76-
log.Fatal("ArduinoCLI daemon address and instance number must be set.")
81+
if *cliPath == "" {
82+
bin, _ := exec.LookPath("arduino-cli")
83+
if bin == "" {
84+
log.Fatal("Path to ArduinoCLI must be set.")
85+
}
86+
log.Printf("arduino-cli found at %s\n", bin)
87+
*cliPath = bin
88+
}
7789
}
90+
7891
if *clangdPath == "" {
79-
log.Fatal("Path to Clangd must be set.")
92+
bin, _ := exec.LookPath("clangd")
93+
if bin == "" {
94+
log.Fatal("Path to Clangd must be set.")
95+
}
96+
log.Printf("clangd found at %s\n", bin)
97+
*clangdPath = bin
8098
}
8199

82100
config := &ls.Config{

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.