Skip to content

Instantly share code, notes, and snippets.

@itewqq
Created February 19, 2023 14:37
Show Gist options
  • Save itewqq/4b4ee89ba420d585efb472116879b1ee to your computer and use it in GitHub Desktop.
Save itewqq/4b4ee89ba420d585efb472116879b1ee to your computer and use it in GitHub Desktop.
Configure vscode for linux kernel source code
  1. Disable or uninstall the official C/C++ plugin.
  2. Install the clangd plugin.
  3. Build the kernel with clang:
/path/to/kernel_source$ make CC=clang defconfig
/path/to/kernel_source$ make CC=clang -j16
  1. Generate the compile_commands.json:
/path/to/kernel_source$ python ./scripts/clang-tools/gen_compile_commands.py

If no error occures, you will find compile_commands.json in /path/to/kernel_source/.

  1. Configure the clangd plugin with the following parameters:

image.png

  1. Open any C file in kernel source and enjoy it :)

image.png

@gerdoe-jr
Copy link

gerdoe-jr commented Sep 4, 2024

C&P:

--compile-commands-dir=${workspaceFolder}
--background-index
--completion-style=detailed
--header-insertion=never
--log=info
--pretty

@enkerewpo
Copy link

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment