This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Add .cu files to VSCode extension
ClosedPublic

Authored by ilya-biryukov on Mar 25 2019, 3:50 AM.

Details

Summary

clangd should be able to handle those with a proper compilation
database. However, users using 'nvcc' might start seeing spurious errors
in '.cu' files after this change.

My plan is to land and release this, but be ready to revert in
case of negative user feedback.

Diff Detail

Event Timeline

ilya-biryukov created this revision.Mar 25 2019, 3:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 25 2019, 3:50 AM

Do we need to add an entry "onLanguage:cuda" for cuda in the extension package.json?

ilya-biryukov added a comment.EditedMar 25 2019, 6:12 AM

Do we need to add an entry "onLanguage:cuda" for cuda in the extension package.json?

Yeah, sounds reasonable, but I don't see cuda in the list of languages in VSCode, nor does it auto-detect a language for .cu files for me.
Can those added by extensions (that I might be missing)? What would be the correct way to lookup all available languages?

Do we need to add an entry "onLanguage:cuda" for cuda in the extension package.json?

Yeah, sounds reasonable, but I don't see cuda in the list of languages in VSCode, nor does it auto-detect a language for .cu files for me.
Can those added by extensions (that I might be missing)? What would be the correct way to lookup all available languages?

Taking a closer look, it seems cuda is not supported by default in vscode :(

vscode provides a way to add a new language in the extension, see https://code.visualstudio.com/api/references/contribution-points#contributes.languages, we may define the cuda language in our extension, but vscode also uses this configuration to do other stuff, like syntax highlight, it seems out of scope of our extension, and I'm not sure how would it work with other cuda extension (like vscode-cudacpp which implements the cuda language).

I guess we might leave the patch as it is. clangd won't be started if vscode users only open .cu files; once the users open a c++ file, clangd starts, and clangd should also work for cuda files.

ilya-biryukov added a comment.EditedMar 25 2019, 7:06 AM

Taking a closer look, it seems cuda is not supported by default in vscode :(

vscode provides a way to add a new language in the extension, see https://code.visualstudio.com/api/references/contribution-points#contributes.languages, we may define the cuda language in our extension, but vscode also uses this configuration to do other stuff, like syntax highlight, it seems out of scope of our extension, and I'm not sure how would it work with other cuda extension (like vscode-cudacpp which implements the cuda language).

Agree, we shouldn't define it in our extensions. Actually, IMO the best place for it would be the VSCode code itself. Maybe someone interested in CUDA would pioneer it at some point this and send a PR to VSCode :-)

I guess we might leave the patch as it is. clangd won't be started if vscode users only open .cu files; once the users open a c++ file, clangd starts, and clangd should also work for cuda files.

+1, as annoying as it is, this looks like the best option so far.

hokein accepted this revision.Mar 25 2019, 7:47 AM
hokein added inline comments.
clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
72 ↗(On Diff #192067)

nit: worth a comment documenting the behavior of .cu.

This revision is now accepted and ready to land.Mar 25 2019, 7:47 AM
  • Added a comments about CUDA files
ilya-biryukov marked an inline comment as done.Mar 25 2019, 8:01 AM
This revision was automatically updated to reflect the committed changes.