# How to make LSP to be aware of project context (c++)

**URL:** <https://discuss.kakoune.com/t/how-to-make-lsp-to-be-aware-of-project-context-c/2015>\
**Category:** Help\
**Created:** [March 18, 2022, 1:18pm UTC](https://discuss.kakoune.com/t/how-to-make-lsp-to-be-aware-of-project-context-c/2015 "2022-03-18T13:18:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ADe](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/ade/32/1062_2.png) [@ADe](https://discuss.kakoune.com/u/ADe)\
**Post date:** [March 18, 2022, 1:18pm UTC](https://discuss.kakoune.com/t/how-to-make-lsp-to-be-aware-of-project-context-c/2015/1 "2022-03-18T13:18:29Z")

</div>

Apologies if description is unclear, I’ll try to describe my problem best way i can.  
I use a tool to build my c++ project for me called cmake.

From my root project directory i have all my libraries stored in ./libraries/“lib\_folder\_name”

My source code stored in ./source/

and my build and binary files in ./build/

The problem is while editing source code files kak-lsp is is not aware of project structure  
and using “#include \<lib\_name/header\>” and all functions used by that library are interpreted as an error by kak-lsp.

> - ‘lib/name’ file not found

The only “solution” is to use "#include “…/libraries/path/to/header/file” which works with kak-lsp.

---

<div class="post-metadata">

**Author:** ![krobelus](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/krobelus/32/616_2.png) [@krobelus](https://discuss.kakoune.com/u/krobelus)\
**Post date:** [March 18, 2022, 2:49pm UTC](https://discuss.kakoune.com/t/how-to-make-lsp-to-be-aware-of-project-context-c/2015/2 "2022-03-18T14:49:42Z")

</div>

The C++ language servers read a file called `compile_commands.json` in the project root.  
See clangd’s [Getting started](https://clangd.llvm.org/installation#project-setup) for how to set that up. For CMake you can use this:

```
cd build && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..
cd .. && ln -s build/compile_commands.json .

```

(this will work for any editor that uses clangd)

---

<div class="post-metadata">

**Author:** ![ADe](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/ade/32/1062_2.png) [@ADe](https://discuss.kakoune.com/u/ADe)\
**Post date:** [March 18, 2022, 3:34pm UTC](https://discuss.kakoune.com/t/how-to-make-lsp-to-be-aware-of-project-context-c/2015/3 "2022-03-18T15:34:26Z")

</div>

Excellent, thank you.  
I thought i need to symlink compile\_commands.json to project root or source code project root also, but as it turns out, this is unnecessary. This works without symlink.
