Skip to content

Automatically detect the path of clangd, arduino-cli, and its configuration #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 20, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Auto-detect any clangd and arduino-cli in $PATH
  • Loading branch information
joewreschnig committed Jun 18, 2022
commit e7b85502d679efce465c090f9c91c646bafefcc0
26 changes: 22 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
_ "net/http/pprof"
"os"
"os/exec"
"os/signal"

"github.com/arduino/arduino-language-server/ls"
Expand Down Expand Up @@ -68,15 +69,32 @@ func main() {
log.SetOutput(os.Stderr)
}

if *cliPath != "" {
if *cliDaemonAddress != "" || *cliDaemonInstanceNumber != -1 {
// if one is set, both must be set
if *cliDaemonAddress == "" || *cliDaemonInstanceNumber == -1 {
log.Fatal("ArduinoCLI daemon address and instance number must be set.")
}
} else {
if *cliConfigPath == "" {
log.Fatal("Path to ArduinoCLI config file must be set.")
}
} else if *cliDaemonAddress == "" || *cliDaemonInstanceNumber == -1 {
log.Fatal("ArduinoCLI daemon address and instance number must be set.")
if *cliPath == "" {
bin, _ := exec.LookPath("arduino-cli")
if bin == "" {
log.Fatal("Path to ArduinoCLI must be set.")
}
log.Printf("arduino-cli found at %s\n", bin)
*cliPath = bin
}
}

if *clangdPath == "" {
log.Fatal("Path to Clangd must be set.")
bin, _ := exec.LookPath("clangd")
if bin == "" {
log.Fatal("Path to Clangd must be set.")
}
log.Printf("clangd found at %s\n", bin)
*clangdPath = bin
}

config := &ls.Config{
Expand Down