Improve clangd support
clangd is a very useful tool, serving as a Language Server for C/C++, helping non-IDE editors tremendously. With these tweaks, it works flawlessly on my setup. Add a .clangd config file to exclude the `-mno-direct-extern-access` flag which works fine on gcc but not on clang. Also tell CMake to export a thing called "compile commands", which is essentially a JSON file detailing all the commands used in compilation, so that clangd can correctly process headers and allow you to jump between definitions, uses and whatnot. Finally, adds `.cache/clangd` to the gitignore file. Signed-off-by: tmpod <tom@tmpod.dev>
This commit is contained in:
parent
56f5ed6a88
commit
c6d8adc2fd
3 changed files with 9 additions and 0 deletions
4
.clangd
Normal file
4
.clangd
Normal file
|
@ -0,0 +1,4 @@
|
|||
CompileFlags:
|
||||
Remove:
|
||||
# clang has an issue with this flag, while gcc does not
|
||||
- "-mno-direct-extern-access"
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -188,3 +188,6 @@ screenshots/
|
|||
android/src/google/play/listings/
|
||||
keywords/
|
||||
iphone/metadata/**/keywords.txt
|
||||
|
||||
# clangd cache
|
||||
.cache/clangd/
|
||||
|
|
|
@ -11,6 +11,8 @@ set(CMAKE_C_VISIBILITY_PRESET hidden)
|
|||
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# Fixes warning ld: warning: ignoring duplicate libraries on Mac and Windows.
|
||||
if (POLICY CMP0156)
|
||||
cmake_policy(SET CMP0156 NEW)
|
||||
|
|
Reference in a new issue