Skip to content

Commit 59f0539

Browse files
committed
Use custom .clang-format file in sketch if present
1 parent 2b471cf commit 59f0539

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Diff for: handler/handler.go

+12
Original file line numberDiff line numberDiff line change
@@ -1768,6 +1768,18 @@ func (handler *InoHandler) createClangdFormatterConfig(cppuri lsp.DocumentURI) (
17681768
config := `
17691769
AllowShortFunctionsOnASingleLine: None
17701770
`
1771+
1772+
// If a custom config is present in the sketch folder, use that one
1773+
customConfigFile := handler.sketchRoot.Join(".clang-format")
1774+
if customConfigFile.Exist() {
1775+
if c, err := customConfigFile.ReadFile(); err != nil {
1776+
log.Printf(" error reading custom formatter config file %s: %s", customConfigFile, err)
1777+
} else {
1778+
log.Printf(" using custom formatter config file %s", customConfigFile)
1779+
config = string(c)
1780+
}
1781+
}
1782+
17711783
targetFile := cppuri.AsPath()
17721784
if targetFile.IsNotDir() {
17731785
targetFile = targetFile.Parent()

0 commit comments

Comments
 (0)