| | 2 | |
| | 3 | [https://clangd.llvm.org clangd] is language server designed to provide features like autocomplete, go to definition, and refactoring to a wide range of editors. |
| | 4 | |
| | 5 | == Setting up clangd |
| | 6 | |
| | 7 | === Generate compile_command.json |
| | 8 | |
| | 9 | ==== macOS |
| | 10 | clangd relies on compile_commands.json file to work, which can be generated on macOS by running |
| | 11 | |
| | 12 | {{{ |
| | 13 | make r EXPORT_COMPILE_COMMANDS=YES |
| | 14 | generate-compile-commands WebKitBuild/Release |
| | 15 | }}} |
| | 16 | |
| | 17 | I would recommend running this command each time you pull the latest code. |
| | 18 | |
| | 19 | If you add or remove files during development, just compile with make and run the {{{generate-compile-commands}}}. |
| | 20 | |
| | 21 | |
| | 22 | ==== Linux and Windows |
| | 23 | |
| | 24 | For other platforms using cmake, generating compile_commands.json can be accomplished by running |
| | 25 | |
| | 26 | |
| | 27 | {{{ |
| | 28 | cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 |
| | 29 | }}} |
| | 30 | |
| | 31 | |
| | 32 | === Configure your editor |
| | 33 | |
| | 34 | Every editor will have slightly different method to setup clangd. |
| | 35 | |
| | 36 | The clangd website provides an excellent setup guide for most popular editors. |
| | 37 | |
| | 38 | |
| | 39 | ||= Editors =||= Links =|| |
| | 40 | || BBEdit || https://www.barebones.com/support/bbedit/lsp-notes.html|| |
| | 41 | || Clion || https://www.jetbrains.com/help/clion/settings-languages-cpp-clangd.html|| |
| | 42 | || Emacs || https://clangd.llvm.org/installation#editor-plugins|| |
| | 43 | || Vim || https://clangd.llvm.org/installation#editor-plugins|| |
| | 44 | || VSCode || https://clangd.llvm.org/installation#editor-plugins|| |
| | 45 | || Sublime Text || https://clangd.llvm.org/installation#editor-plugins|| |