Search code examples
c++cudasublimetext3clangd

How to use cuda with LSP-clangd


I want to use sublime text as my c++ editor.

I added LSP-clangd in the editor. I generate some compile_commands.json and clangd works on almost every files in my project but not with cuda files.

I saw in clangd FAQ that we must ensure :

  1. that our editor plugin is enabling clangd when CUDA files are open (e.g. enabling for extension *.cu). I didn't found any parameters in LSP-clangd settings to add some file extensions.
  2. make sure that clangd understands these are CUDA files (e.g. by extension *.cu or adding the clang flag -xcuda). Where should I add these flags? In compile_commands.json?
  3. set the path to your cuda installation if it isn’t detected, by adding the clang flag --cuda-path=... Where should I specify this path? I tried using command clang --cuda-path=my/cuda/path but it returns me clang: error; no input files

Have you any idea to solve one of these 3 problems ? or did someone suceed to use cuda with clangd in sublime text ?


Solution

  • Thanks to @HighCommander4, I solve this issue by adding a clang config file to my project. Moreover, I found an issue on clangd github that shares a similar problem.

    Here is the .clangd configuration file that I use for my project :

    CompileFlags:
      Add:
        - --cuda-path=C://Program Files//NVIDIA GPU Computing Toolkit//CUDA//v12.1
        - -LC://Program Files//NVIDIA GPU Computing Toolkit//CUDA//v12.1//lib
        - -IC://Program Files//NVIDIA GPU Computing Toolkit//CUDA//v12.1//include