From ecda674f374ccd5c2df17522dd891001a56750a2 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 13 Dec 2021 19:07:58 +0100 Subject: [PATCH 1/2] Suppress 'anon_bitfield_qualifiers' errors Those errors are present in the CMSIS-Atmel package, and makes the language server produce other bogus errors as a consquence of parse failure of header files. See https://github.com/arduino/arduino-ide/issues/307 See https://github.com/arduino/arduino-ide/issues/112 --- ls/lsp_client_clangd.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ls/lsp_client_clangd.go b/ls/lsp_client_clangd.go index e98f94c..6381902 100644 --- a/ls/lsp_client_clangd.go +++ b/ls/lsp_client_clangd.go @@ -22,6 +22,15 @@ type ClangdLSPClient struct { } func NewClangdLSPClient(logger jsonrpc.FunctionLogger, dataFolder *paths.Path, ls *INOLanguageServer) *ClangdLSPClient { + clangdConfFile := ls.buildPath.Join(".clangd") + clangdConf := fmt.Sprintln("Diagnostics:") + clangdConf += fmt.Sprintln(" Suppress: [anon_bitfield_qualifiers]") + clangdConf += fmt.Sprintln("CompileFlags:") + clangdConf += fmt.Sprintln(" Add: -ferror-limit=0") + if err := clangdConfFile.WriteFile([]byte(clangdConf)); err != nil { + logger.Logf("Error writing clangd configuration: %s", err) + } + // Start clangd args := []string{ ls.config.ClangdPath.String(), From af923db612c53fad7476e43c352d3de80ad19683 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 16 Dec 2021 16:46:09 +0100 Subject: [PATCH 2/2] Canonicalize path to clangd for query-driver parameter --- ls/lsp_client_clangd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ls/lsp_client_clangd.go b/ls/lsp_client_clangd.go index 6381902..dc259f0 100644 --- a/ls/lsp_client_clangd.go +++ b/ls/lsp_client_clangd.go @@ -38,7 +38,7 @@ func NewClangdLSPClient(logger jsonrpc.FunctionLogger, dataFolder *paths.Path, l fmt.Sprintf(`--compile-commands-dir=%s`, ls.buildPath), } if dataFolder != nil { - args = append(args, fmt.Sprintf("-query-driver=%s", dataFolder.Join("packages", "**"))) + args = append(args, fmt.Sprintf("-query-driver=%s", dataFolder.Join("packages", "**").Canonical())) } logger.Logf(" Starting clangd: %s", strings.Join(args, " "))