Skip to content

Commit 802e256

Browse files
authored
Add an item to the FAQ re: C/C++ and #include (#4308)
I found this after a bit of Googling and I thought it would be helpful for the FAQ. Thanks!
1 parent 40c876c commit 802e256

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docs/page/faq.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,17 @@ The issue is caused by `clojure-lsp` server being more aggressive with formattin
7171
``` elisp
7272
(setq lsp-enable-suggest-server-download nil)
7373
```
74+
75+
---
76+
### :grey_question: How can I stop #include statements being automatically inserted when editing C/C++ code?
77+
78+
You can use `lsp-clients-clangd-args` to configure your clangd. Add the following:
79+
80+
``` elisp
81+
(setq lsp-clients-clangd-args
82+
'("--header-insertion=never"))
83+
```
84+
85+
For more flags, see clangd --help.
86+
87+
(Thanks to [Martingale on Emacs StackExchange](https://emacs.stackexchange.com/questions/58015/how-to-stop-lsp-mode-including-headers-automatically-for-c-c-code) for this answer!)

0 commit comments

Comments
 (0)