sublimelsp / LSP-clangd

C/C++ support for Sublime's LSP plugin provided through clangd.
MIT License
42 stars 1 forks source link

How to make clangd works with cuda files #5

Closed davidAlgis closed 1 year ago

davidAlgis commented 1 year ago

How to make clangd works with cuda files ? Do I need some specific compilation flags ? I saw on clangd FAQ that we must ensure that the plugin enable clangd when opening cuda files. Is it possible with this plugin ?

rchl commented 1 year ago

Which syntax are you using for cuda files? It's shown in the bottom-right corner, inside the status bar.

must ensure that the plugin enable clangd when opening cuda files. Is it possible with this plugin ?

If you are seeing clangd in the bottom-left corner of the status bar then it means it's running.

rwols commented 1 year ago

You need to add the base scope to the selector https://github.com/sublimelsp/LSP-clangd/blob/92e0fe4f2977a27b5f1e47d5254bf69a0798dfc5/LSP-clangd.sublime-settings#L14

davidAlgis commented 1 year ago

@rchl I'm seing clangd, but it seems to don't know the existence of cuda header. The errors are In included file "cuda_runtime.h" file not found clangpp(file not found). Moreover, the project is built correctly with msbuild.

@rwols I already did it, I even add cuda source file : "selector": "source.c | source.c++ | source.objc | source.objc++ | source.cuda-c++"

LDAP commented 1 year ago

Can you capture logs from the LSP? You can enable logging in the LSP (not LSP-clangd) settings.

It might be possible that we need to add the language ID to https://github.com/sublimelsp/LSP/blob/main/language-ids.sublime-settings. I believe Sublime sends cuda-c++ but it should be cuda-cpp.

rchl commented 1 year ago

As far as logs, those are enabled by default and can be seen after opening the log panel with LSP: Toggle Log Panel command.

davidAlgis commented 1 year ago

Here are my log, I just open a simple test file test.cpp with only one line #include "cuda_runtime.h

:: [15:00:47.553] --> clangd initialize (1): {'processId': 17596, 'capabilities': {'textDocument': {'implementation': {'linkSupport': True, 'dynamicRegistration': True}, 'callHierarchy': {'dynamicRegistration': True}, 'formatting': {'dynamicRegistration': True}, 'typeDefinition': {'linkSupport': True, 'dynamicRegistration': True}, 'synchronization': {'didSave': True, 'willSaveWaitUntil': True, 'dynamicRegistration': True, 'willSave': True}, 'declaration': {'linkSupport': True, 'dynamicRegistration': True}, 'completion': {'completionItemKind': {'valueSet': [8, 7, 25, 5, 14, 4, 10, 24, 12, 2, 9, 18, 19, 1, 11, 20, 23, 17, 15, 16, 21, 22, 13, 6, 3]}, 'completionItem': {'labelDetailsSupport': True, 'documentationFormat': ['markdown', 'plaintext'], 'insertReplaceSupport': True, 'resolveSupport': {'properties': ['detail', 'documentation', 'additionalTextEdits']}, 'insertTextModeSupport': {'valueSet': [2]}, 'snippetSupport': True, 'tagSupport': {'valueSet': [1]}, 'deprecatedSupport': True}, 'dynamicRegistration': True, 'insertTextMode': 2}, 'definition': {'linkSupport': True, 'dynamicRegistration': True}, 'references': {'dynamicRegistration': True}, 'inlayHint': {'dynamicRegistration': True, 'resolveSupport': {'properties': ['textEdits', 'label.command']}}, 'codeAction': {'isPreferredSupport': True, 'resolveSupport': {'properties': ['edit']}, 'dataSupport': True, 'dynamicRegistration': True, 'codeActionLiteralSupport': {'codeActionKind': {'valueSet': ['quickfix', 'refactor', 'refactor.extract', 'refactor.inline', 'refactor.rewrite', 'source.fixAll', 'source.organizeImports']}}}, 'semanticTokens': {'requests': {'range': True, 'full': {'delta': True}}, 'overlappingTokenSupport': False, 'dynamicRegistration': True, 'tokenModifiers': ['abstract', 'modification', 'deprecated', 'readonly', 'defaultLibrary', 'static', 'async', 'documentation', 'definition', 'declaration'], 'augmentsSyntaxTokens': True, 'formats': ['relative'], 'tokenTypes': ['interface', 'type', 'typeParameter', 'number', 'keyword', 'string', 'property', 'variable', 'regexp', 'namespace', 'method', 'enumMember', 'comment', 'macro', 'decorator', 'event', 'class', 'operator', 'struct', 'modifier', 'enum', 'parameter', 'function'], 'multilineTokenSupport': True}, 'signatureHelp': {'signatureInformation': {'documentationFormat': ['markdown', 'plaintext'], 'activeParameterSupport': True, 'parameterInformation': {'labelOffsetSupport': True}}, 'dynamicRegistration': True, 'contextSupport': True}, 'rename': {'prepareSupportDefaultBehavior': 1, 'dynamicRegistration': True, 'prepareSupport': True}, 'selectionRange': {'dynamicRegistration': True}, 'rangeFormatting': {'dynamicRegistration': True}, 'typeHierarchy': {'dynamicRegistration': True}, 'publishDiagnostics': {'codeDescriptionSupport': True, 'versionSupport': True, 'dataSupport': True, 'relatedInformation': True, 'tagSupport': {'valueSet': [2, 1]}}, 'colorProvider': {'dynamicRegistration': True}, 'documentLink': {'dynamicRegistration': True, 'tooltipSupport': True}, 'hover': {'contentFormat': ['markdown', 'plaintext'], 'dynamicRegistration': True}, 'documentHighlight': {'dynamicRegistration': True}, 'documentSymbol': {'symbolKind': {'valueSet': [18, 11, 17, 26, 8, 4, 9, 7, 13, 3, 6, 22, 15, 1, 2, 24, 5, 20, 25, 14, 23, 21, 10, 16, 12, 19]}, 'dynamicRegistration': True, 'hierarchicalDocumentSymbolSupport': True, 'tagSupport': {'valueSet': [1]}}, 'codeLens': {'dynamicRegistration': True}}, 'window': {'showMessage': {'messageActionItem': {'additionalPropertiesSupport': True}}, 'workDoneProgress': True, 'showDocument': {'support': True}}, 'workspace': {'didChangeConfiguration': {'dynamicRegistration': True}, 'executeCommand': {}, 'applyEdit': True, 'workspaceEdit': {'failureHandling': 'abort', 'documentChanges': True}, 'inlayHint': {'refreshSupport': True}, 'semanticTokens': {'refreshSupport': True}, 'configuration': True, 'workspaceFolders': True, 'codeLens': {'refreshSupport': True}, 'symbol': {'symbolKind': {'valueSet': [18, 11, 17, 26, 8, 4, 9, 7, 13, 3, 6, 22, 15, 1, 2, 24, 5, 20, 25, 14, 23, 21, 10, 16, 12, 19]}, 'dynamicRegistration': True, 'tagSupport': {'valueSet': [1]}}}, 'general': {'markdown': {'parser': 'Python-Markdown', 'version': '3.2.2'}, 'regularExpressions': {'engine': 'ECMAScript'}}}, 'initializationOptions': {'clangd': {'fallback-style': None, 'all-scopes-completion': False, 'pch-storage': None, 'query-driver': None, 'project-root': None, 'enable-config': False, 'malloc-trim': False, 'path-mappings': None, 'remote-index-address': None, 'compile-commands-dir': None, 'header-insertion-decorators': False, 'clang-tidy': True, 'function-arg-placeholders': False, 'limit-references': None, 'limit-results': None, 'pretty': False, 'header-insertion': None, 'background-index': False, 'completion-style': None, 'background-index-priority': None, 'number-workers': None, 'log': None}, 'clangdFileStatus': False, 'fallbackFlags': []}, 'rootPath': 'D:\\arc_blanc_these\\Programmes\\HybridizationPlugin', 'clientInfo': {'version': '1.22.0', 'name': 'Sublime Text LSP'}, 'rootUri': 'file:///D:/arc_blanc_these/Programmes/HybridizationPlugin', 'workspaceFolders': [{'uri': 'file:///D:/arc_blanc_these/Programmes/HybridizationPlugin', 'name': 'HybridizationPlugin'}]}
clangd: I[15:00:47.600] clangd version 15.0.6 (https://github.com/llvm/llvm-project 088f33605d8a61ff519c580a71b1dd57d16a03f8)
clangd: I[15:00:47.601] Features: windows+grpc
clangd: I[15:00:47.601] PID: 7792
clangd: I[15:00:47.601] Working directory: D:\arc_blanc_these\Programmes\HybridizationPlugin
clangd: I[15:00:47.601] argv[0]: C:\Users\david\AppData\Local\Sublime Text\Package Storage\LSP-clangd\clangd_15.0.6/bin/clangd.exe
clangd: I[15:00:47.601] argv[1]: --clang-tidy
clangd: I[15:00:47.607] Starting LSP over stdin/stdout
clangd: I[15:00:47.607] <-- initialize(1)
clangd: I[15:00:47.659] --> reply:initialize(1) 51 ms
:: [15:00:47.659] <<< clangd (1) (duration: 105ms): {'capabilities': {'documentSymbolProvider': True, 'completionProvider': {'triggerCharacters': ['.', '<', '>', ':', '"', '/', '*'], 'resolveProvider': False}, 'referencesProvider': True, 'typeHierarchyProvider': True, 'standardTypeHierarchyProvider': True, 'compilationDatabase': {'automaticReload': True}, 'codeActionProvider': {'codeActionKinds': ['quickfix', 'refactor', 'info']}, 'workspaceSymbolProvider': True, 'definitionProvider': True, 'selectionRangeProvider': True, 'signatureHelpProvider': {'triggerCharacters': ['(', ')', '{', '}', '<', '>', ',']}, 'callHierarchyProvider': True, 'implementationProvider': True, 'documentFormattingProvider': True, 'renameProvider': {'prepareProvider': True}, 'astProvider': True, 'memoryUsageProvider': True, 'documentLinkProvider': {'resolveProvider': False}, 'clangdInlayHintsProvider': True, 'documentOnTypeFormattingProvider': {'moreTriggerCharacter': [], 'firstTriggerCharacter': '\n'}, 'documentRangeFormattingProvider': True, 'declarationProvider': True, 'documentHighlightProvider': True, 'textDocumentSync': {'save': {}, 'didOpen': {}, 'change': {'syncKind': 2}, 'didClose': {}}, 'hoverProvider': True, 'typeDefinitionProvider': True, 'semanticTokensProvider': {'range': False, 'full': {'delta': True}, 'legend': {'tokenTypes': ['variable', 'variable', 'parameter', 'function', 'method', 'function', 'property', 'variable', 'class', 'interface', 'enum', 'enumMember', 'type', 'type', 'unknown', 'namespace', 'typeParameter', 'concept', 'type', 'macro', 'comment'], 'tokenModifiers': ['declaration', 'deprecated', 'deduced', 'readonly', 'static', 'abstract', 'virtual', 'dependentName', 'defaultLibrary', 'usedAsMutableReference', 'functionScope', 'classScope', 'fileScope', 'globalScope']}}, 'inlayHintProvider': True, 'executeCommandProvider': {'commands': ['clangd.applyFix', 'clangd.applyTweak']}}, 'serverInfo': {'version': 'clangd version 15.0.6 (https://github.com/llvm/llvm-project 088f33605d8a61ff519c580a71b1dd57d16a03f8) windows+grpc x86_64-pc-windows-msvc', 'name': 'clangd'}}
:: [15:00:47.659]  -> clangd initialized: {}
clangd: I[15:00:47.660] <-- initialized
clangd: I[15:00:47.668] <-- textDocument/didOpen
clangd: I[15:00:47.669] <-- textDocument/documentLink(2)
clangd: E[15:00:47.671] config error at C:\Users\david\AppData\Local\clangd\config.yaml:2:33: Found unexpected ':' while scanning a plain scalar
clangd: I[15:00:47.671] --> textDocument/publishDiagnostics
clangd: I[15:00:47.672] Loaded compilation database from D:\arc_blanc_these\Programmes\HybridizationPlugin\compile_commands.json
clangd: I[15:00:47.672] ASTWorker building file D:\arc_blanc_these\Programmes\HybridizationPlugin\TessendorfPlugin\src\Spectrum\test.cpp version 0 with command inferred from D:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/src/Spectrum/empirical_dir_spectrum.cpp
clangd: [D:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin]
clangd: "C:\\Users\\david\\AppData\\Local\\Sublime Text\\Package Storage\\LSP-clangd\\clangd_15.0.6\\bin\\g++" --driver-mode=g++ -MD -MP -DNDEBUG -DPLUGINHYBRIDIZATION_SHARED_EXPORTS -ID:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/include -ID:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/include/Kernels -ID:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/include/Spectrum -ID:/arc_blanc_these/Programmes/HybridizationPlugin/HybridizationInterop/include -ID:/arc_blanc_these/Programmes/HybridizationPlugin/HybridizationCommon/include -ID:/arc_blanc_these/Programmes/HybridizationPlugin/HybridizationInterop/include/Kernels -ID:/InteropUnityCUDA/Plugin/Utilities/include -m64 -O2 -g -MF D:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/temp/x64/Release/empirical_dir_spectrum.d -c "-resource-dir=C:\\Users\\david\\AppData\\Local\\Sublime Text\\Package Storage\\LSP-clangd\\clangd_15.0.6\\lib\\clang\\15.0.6" -- "D:\\arc_blanc_these\\Programmes\\HybridizationPlugin\\TessendorfPlugin\\src\\Spectrum\\test.cpp"
clangd: I[15:00:47.674] --> window/workDoneProgress/create(0)
clangd: I[15:00:47.674] Enqueueing 10 commands for indexing
:: [15:00:47.667]  -> clangd textDocument/didOpen: {'textDocument': {'version': 0, 'text': '#include "cura_runtime.h"', 'languageId': 'cpp', 'uri': 'file:///D:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/src/Spectrum/test.cpp'}}
:: [15:00:47.668] --> clangd textDocument/documentLink (2): {'textDocument': {'uri': 'file:///D:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/src/Spectrum/test.cpp'}}
:: [15:00:47.687] <-  clangd textDocument/publishDiagnostics: {'diagnostics': [{'message': "Found unexpected ':' while scanning a plain scalar", 'range': {'start': {'line': 1, 'character': 33}, 'end': {'line': 1, 'character': 33}}, 'source': 'clangd-config', 'relatedInformation': [], 'severity': 1}], 'uri': 'file:///C:/Users/david/AppData/Local/clangd/config.yaml'}
:: [15:00:47.688] <-- clangd window/workDoneProgress/create (0): {'token': 'backgroundIndexProgress'}
:: [15:00:47.688] >>> clangd (0) (duration: 0ms): None
clangd: I[15:00:47.689] <-- reply(0)
clangd: I[15:00:47.689] --> $/progress
clangd: I[15:00:47.689] --> $/progress
:: [15:00:47.688] <-  clangd $/progress: {'token': 'backgroundIndexProgress', 'value': {'kind': 'begin', 'percentage': 0, 'title': 'indexing'}}
:: [15:00:47.689] <-  clangd $/progress: {'token': 'backgroundIndexProgress', 'value': {'kind': 'report', 'message': '0/1', 'percentage': 0}}
clangd: I[15:00:47.699] --> workspace/semanticTokens/refresh(1)
clangd: I[15:00:47.700] <-- reply(1)
:: [15:00:47.699] <-- clangd workspace/semanticTokens/refresh (1): None
:: [15:00:47.699] >>> clangd (1) (duration: 0ms): None
clangd: I[15:00:47.722] --> textDocument/publishDiagnostics
clangd: I[15:00:47.722] --> reply:textDocument/documentLink(2) 52 ms
:: [15:00:47.723] <-  clangd textDocument/publishDiagnostics: {'version': 0, 'diagnostics': [{'message': "'cura_runtime.h' file not found", 'range': {'start': {'line': 0, 'character': 9}, 'end': {'line': 0, 'character': 25}}, 'code': 'pp_file_not_found', 'source': 'clang', 'relatedInformation': [], 'severity': 1}], 'uri': 'file:///D:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/src/Spectrum/test.cpp'}
:: [15:00:47.742] <<< clangd (2) (duration: 73ms): []
clangd: I[15:00:48.123] --> $/progress
clangd: I[15:00:48.123] --> $/progress
:: [15:00:48.123] <-  clangd $/progress: {'token': 'backgroundIndexProgress', 'value': {'kind': 'report', 'message': '0/1', 'percentage': 0}}
:: [15:00:48.123] <-  clangd $/progress: {'token': 'backgroundIndexProgress', 'value': {'kind': 'end'}}
clangd: I[15:01:03.868] <-- textDocument/hover(3)
clangd: I[15:01:03.912] --> reply:textDocument/hover(3) 44 ms
:: [15:01:03.866] --> clangd textDocument/hover (3): {'textDocument': {'uri': 'file:///D:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/src/Spectrum/test.cpp'}, 'position': {'line': 0, 'character': 21}}
clangd: I[15:01:03.929] <-- textDocument/codeAction(4)
clangd: I[15:01:03.932] --> reply:textDocument/codeAction(4) 2 ms
:: [15:01:03.928] --> clangd textDocument/codeAction (4): {'textDocument': {'uri': 'file:///D:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/src/Spectrum/test.cpp'}, 'range': {'start': {'line': 0, 'character': 9}, 'end': {'line': 0, 'character': 25}}, 'context': {'triggerKind': 2, 'diagnostics': [{'message': "'cura_runtime.h' file not found", 'range': {'start': {'line': 0, 'character': 9}, 'end': {'line': 0, 'character': 25}}, 'code': 'pp_file_not_found', 'source': 'clang', 'relatedInformation': [], 'severity': 1}]}}
:: [15:01:03.928] <<< clangd (3) (duration: 62ms): None
:: [15:01:03.962] <<< clangd (4) (duration: 34ms): []
LDAP commented 1 year ago

I never used Cuda myself, but isn't the file type .cu? Also, do you have the Cuda package installed and Cuda selected in the bottom-right corner?

davidAlgis commented 1 year ago

Indeed, the file type in Cuda are cu file that will be compiled with a cuda compiler : nvcc. But even for .cpp or .h files when I want to include cuda headers I have an error of file not found. @LDAP what do you mean by "Cuda package" ? if you're talking about this one it's already installed. For .cu files I selected CUDA in the bottom-right corner.

rchl commented 1 year ago

As far finding the cuda headers, the FAQ seems to say that if you have problems with that then you should pass --cuda-path=.... Maybe LDAP can answer on how exactly this can be done with this package. Is it through package settings or compile commands rather?

As for handling *.cu files, you haven't provided logs for that but I'm guessing the language ID has to be cuda (googled a bit). So open Preferences: LSP Language ID Mapping Overrides and add:

"source.cuda-c++": "cuda"
LDAP commented 1 year ago

Yes I meant that package.

If you can't find Cuda headers even in regular cpp files then this is likely an issue with clangd or with your toolkit installation.

If the server does not work correctly only in Cuda files then it could be because the language id must be added (I think we should add that regardless).

LDAP commented 1 year ago

@rchl according to https://code.visualstudio.com/docs/languages/identifiers it's cuda-cpp

davidAlgis commented 1 year ago

@rchl ok I add it in Language mapping. Sorry for the log, I wanted to make it very simple, but I forget to open a .cu file... Here is a version where I open test.cu with only the same include as the one above.

:: [15:44:59.823] --> clangd initialize (1): {'rootPath': 'D:\\arc_blanc_these\\Programmes\\HybridizationPlugin', 'capabilities': {'window': {'showDocument': {'support': True}, 'workDoneProgress': True, 'showMessage': {'messageActionItem': {'additionalPropertiesSupport': True}}}, 'general': {'regularExpressions': {'engine': 'ECMAScript'}, 'markdown': {'version': '3.2.2', 'parser': 'Python-Markdown'}}, 'workspace': {'semanticTokens': {'refreshSupport': True}, 'inlayHint': {'refreshSupport': True}, 'workspaceEdit': {'documentChanges': True, 'failureHandling': 'abort'}, 'applyEdit': True, 'configuration': True, 'executeCommand': {}, 'symbol': {'dynamicRegistration': True, 'symbolKind': {'valueSet': [16, 2, 10, 3, 15, 14, 12, 22, 26, 11, 21, 18, 1, 17, 24, 20, 19, 23, 4, 13, 6, 5, 7, 9, 8, 25]}, 'tagSupport': {'valueSet': [1]}}, 'didChangeConfiguration': {'dynamicRegistration': True}, 'codeLens': {'refreshSupport': True}, 'workspaceFolders': True}, 'textDocument': {'semanticTokens': {'tokenModifiers': ['deprecated', 'documentation', 'abstract', 'definition', 'async', 'modification', 'static', 'declaration', 'defaultLibrary', 'readonly'], 'dynamicRegistration': True, 'overlappingTokenSupport': False, 'requests': {'full': {'delta': True}, 'range': True}, 'tokenTypes': ['number', 'modifier', 'enum', 'namespace', 'string', 'typeParameter', 'enumMember', 'function', 'decorator', 'regexp', 'interface', 'event', 'macro', 'type', 'struct', 'keyword', 'method', 'parameter', 'class', 'property', 'variable', 'comment', 'operator'], 'formats': ['relative'], 'augmentsSyntaxTokens': True, 'multilineTokenSupport': True}, 'codeAction': {'dynamicRegistration': True, 'dataSupport': True, 'resolveSupport': {'properties': ['edit']}, 'codeActionLiteralSupport': {'codeActionKind': {'valueSet': ['quickfix', 'refactor', 'refactor.extract', 'refactor.inline', 'refactor.rewrite', 'source.fixAll', 'source.organizeImports']}}, 'isPreferredSupport': True}, 'implementation': {'dynamicRegistration': True, 'linkSupport': True}, 'selectionRange': {'dynamicRegistration': True}, 'definition': {'dynamicRegistration': True, 'linkSupport': True}, 'inlayHint': {'dynamicRegistration': True, 'resolveSupport': {'properties': ['textEdits', 'label.command']}}, 'documentLink': {'tooltipSupport': True, 'dynamicRegistration': True}, 'completion': {'insertTextMode': 2, 'dynamicRegistration': True, 'completionItem': {'insertTextModeSupport': {'valueSet': [2]}, 'resolveSupport': {'properties': ['detail', 'documentation', 'additionalTextEdits']}, 'insertReplaceSupport': True, 'documentationFormat': ['markdown', 'plaintext'], 'labelDetailsSupport': True, 'deprecatedSupport': True, 'tagSupport': {'valueSet': [1]}, 'snippetSupport': True}, 'completionItemKind': {'valueSet': [8, 9, 1, 16, 13, 21, 18, 3, 20, 25, 11, 6, 17, 23, 12, 22, 14, 2, 7, 10, 19, 4, 5, 15, 24]}}, 'colorProvider': {'dynamicRegistration': True}, 'rangeFormatting': {'dynamicRegistration': True}, 'signatureHelp': {'contextSupport': True, 'dynamicRegistration': True, 'signatureInformation': {'parameterInformation': {'labelOffsetSupport': True}, 'activeParameterSupport': True, 'documentationFormat': ['markdown', 'plaintext']}}, 'declaration': {'dynamicRegistration': True, 'linkSupport': True}, 'formatting': {'dynamicRegistration': True}, 'typeDefinition': {'dynamicRegistration': True, 'linkSupport': True}, 'typeHierarchy': {'dynamicRegistration': True}, 'rename': {'prepareSupport': True, 'dynamicRegistration': True, 'prepareSupportDefaultBehavior': 1}, 'hover': {'dynamicRegistration': True, 'contentFormat': ['markdown', 'plaintext']}, 'documentHighlight': {'dynamicRegistration': True}, 'callHierarchy': {'dynamicRegistration': True}, 'publishDiagnostics': {'versionSupport': True, 'relatedInformation': True, 'dataSupport': True, 'tagSupport': {'valueSet': [1, 2]}, 'codeDescriptionSupport': True}, 'references': {'dynamicRegistration': True}, 'codeLens': {'dynamicRegistration': True}, 'documentSymbol': {'hierarchicalDocumentSymbolSupport': True, 'dynamicRegistration': True, 'symbolKind': {'valueSet': [16, 2, 10, 3, 15, 14, 12, 22, 26, 11, 21, 18, 1, 17, 24, 20, 19, 23, 4, 13, 6, 5, 7, 9, 8, 25]}, 'tagSupport': {'valueSet': [1]}}, 'synchronization': {'willSaveWaitUntil': True, 'dynamicRegistration': True, 'willSave': True, 'didSave': True}}}, 'initializationOptions': {'fallbackFlags': [], 'clangdFileStatus': False, 'clangd': {'background-index-priority': None, 'project-root': None, 'query-driver': None, 'path-mappings': None, 'log': None, 'compile-commands-dir': None, 'remote-index-address': None, 'all-scopes-completion': False, 'limit-references': None, 'function-arg-placeholders': False, 'pch-storage': None, 'background-index': False, 'pretty': False, 'number-workers': None, 'enable-config': False, 'fallback-style': None, 'malloc-trim': False, 'limit-results': None, 'completion-style': None, 'header-insertion-decorators': False, 'header-insertion': None, 'clang-tidy': True}}, 'processId': 12936, 'workspaceFolders': [{'name': 'HybridizationPlugin', 'uri': 'file:///D:/arc_blanc_these/Programmes/HybridizationPlugin'}], 'rootUri': 'file:///D:/arc_blanc_these/Programmes/HybridizationPlugin', 'clientInfo': {'name': 'Sublime Text LSP', 'version': '1.22.0'}}
clangd: I[15:44:59.857] clangd version 15.0.6 (https://github.com/llvm/llvm-project 088f33605d8a61ff519c580a71b1dd57d16a03f8)
clangd: I[15:44:59.858] Features: windows+grpc
clangd: I[15:44:59.858] PID: 2412
clangd: I[15:44:59.858] Working directory: D:\arc_blanc_these\Programmes\HybridizationPlugin
clangd: I[15:44:59.858] argv[0]: C:\Users\david\AppData\Local\Sublime Text\Package Storage\LSP-clangd\clangd_15.0.6/bin/clangd.exe
clangd: I[15:44:59.858] argv[1]: --clang-tidy
clangd: I[15:44:59.862] Starting LSP over stdin/stdout
clangd: I[15:44:59.863] <-- initialize(1)
clangd: I[15:44:59.894] --> reply:initialize(1) 31 ms
:: [15:44:59.894] <<< clangd (1) (duration: 71ms): {'serverInfo': {'name': 'clangd', 'version': 'clangd version 15.0.6 (https://github.com/llvm/llvm-project 088f33605d8a61ff519c580a71b1dd57d16a03f8) windows+grpc x86_64-pc-windows-msvc'}, 'capabilities': {'typeDefinitionProvider': True, 'documentRangeFormattingProvider': True, 'documentSymbolProvider': True, 'callHierarchyProvider': True, 'standardTypeHierarchyProvider': True, 'codeActionProvider': {'codeActionKinds': ['quickfix', 'refactor', 'info']}, 'completionProvider': {'resolveProvider': False, 'triggerCharacters': ['.', '<', '>', ':', '"', '/', '*']}, 'workspaceSymbolProvider': True, 'inlayHintProvider': True, 'semanticTokensProvider': {'legend': {'tokenModifiers': ['declaration', 'deprecated', 'deduced', 'readonly', 'static', 'abstract', 'virtual', 'dependentName', 'defaultLibrary', 'usedAsMutableReference', 'functionScope', 'classScope', 'fileScope', 'globalScope'], 'tokenTypes': ['variable', 'variable', 'parameter', 'function', 'method', 'function', 'property', 'variable', 'class', 'interface', 'enum', 'enumMember', 'type', 'type', 'unknown', 'namespace', 'typeParameter', 'concept', 'type', 'macro', 'comment']}, 'full': {'delta': True}, 'range': False}, 'documentFormattingProvider': True, 'implementationProvider': True, 'astProvider': True, 'referencesProvider': True, 'hoverProvider': True, 'renameProvider': {'prepareProvider': True}, 'documentOnTypeFormattingProvider': {'firstTriggerCharacter': '\n', 'moreTriggerCharacter': []}, 'executeCommandProvider': {'commands': ['clangd.applyFix', 'clangd.applyTweak']}, 'selectionRangeProvider': True, 'definitionProvider': True, 'compilationDatabase': {'automaticReload': True}, 'documentHighlightProvider': True, 'signatureHelpProvider': {'triggerCharacters': ['(', ')', '{', '}', '<', '>', ',']}, 'documentLinkProvider': {'resolveProvider': False}, 'typeHierarchyProvider': True, 'clangdInlayHintsProvider': True, 'memoryUsageProvider': True, 'textDocumentSync': {'didClose': {}, 'change': {'syncKind': 2}, 'didOpen': {}, 'save': {}}, 'declarationProvider': True}}
:: [15:44:59.895]  -> clangd initialized: {}
clangd: I[15:44:59.896] <-- initialized
clangd: I[15:44:59.902] <-- textDocument/didOpen
clangd: E[15:44:59.903] config error at C:\Users\david\AppData\Local\clangd\config.yaml:2:33: Found unexpected ':' while scanning a plain scalar
clangd: I[15:44:59.903] --> textDocument/publishDiagnostics
clangd: I[15:44:59.904] Loaded compilation database from D:\arc_blanc_these\Programmes\HybridizationPlugin\compile_commands.json
clangd: I[15:44:59.905] ASTWorker building file D:\arc_blanc_these\Programmes\HybridizationPlugin\TessendorfPlugin\src\Spectrum\test.cu version 0 with command inferred from D:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/src/Spectrum/test.cpp
clangd: [D:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin]
clangd: "C:\\Users\\david\\AppData\\Local\\Sublime Text\\Package Storage\\LSP-clangd\\clangd_15.0.6\\bin\\g++" --driver-mode=g++ -MD -MP -DDEBUG -DPLUGINHYBRIDIZATION_SHARED_EXPORTS -ID:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/include -ID:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/include/Kernels -ID:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/include/Spectrum -ID:/arc_blanc_these/Programmes/HybridizationPlugin/HybridizationInterop/include -ID:/arc_blanc_these/Programmes/HybridizationPlugin/HybridizationCommon/include -ID:/arc_blanc_these/Programmes/HybridizationPlugin/HybridizationInterop/include/Kernels -ID:/InteropUnityCUDA/Plugin/Utilities/include -m64 -g -MF D:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/temp/x64/Debug/test.d -c "-resource-dir=C:\\Users\\david\\AppData\\Local\\Sublime Text\\Package Storage\\LSP-clangd\\clangd_15.0.6\\lib\\clang\\15.0.6" -- "D:\\arc_blanc_these\\Programmes\\HybridizationPlugin\\TessendorfPlugin\\src\\Spectrum\\test.cu"
clangd: I[15:44:59.906] --> window/workDoneProgress/create(0)
clangd: I[15:44:59.906] Enqueueing 11 commands for indexing
clangd: I[15:44:59.907] <-- textDocument/documentLink(2)
:: [15:44:59.901]  -> clangd textDocument/didOpen: {'textDocument': {'uri': 'file:///D:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/src/Spectrum/test.cu', 'languageId': 'cuda', 'text': '#include "cuda_runtime.h"', 'version': 0}}
:: [15:44:59.906] --> clangd textDocument/documentLink (2): {'textDocument': {'uri': 'file:///D:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/src/Spectrum/test.cu'}}
:: [15:44:59.917] <-  clangd textDocument/publishDiagnostics: {'uri': 'file:///C:/Users/david/AppData/Local/clangd/config.yaml', 'diagnostics': [{'severity': 1, 'relatedInformation': [], 'range': {'end': {'character': 33, 'line': 1}, 'start': {'character': 33, 'line': 1}}, 'source': 'clangd-config', 'message': "Found unexpected ':' while scanning a plain scalar"}]}
:: [15:44:59.918] <-- clangd window/workDoneProgress/create (0): {'token': 'backgroundIndexProgress'}
:: [15:44:59.918] >>> clangd (0) (duration: 0ms): None
clangd: I[15:44:59.918] <-- reply(0)
clangd: I[15:44:59.918] --> $/progress
clangd: I[15:44:59.918] --> $/progress
:: [15:44:59.918] <-  clangd $/progress: {'value': {'title': 'indexing', 'percentage': 0, 'kind': 'begin'}, 'token': 'backgroundIndexProgress'}
:: [15:44:59.919] <-  clangd $/progress: {'value': {'percentage': 0, 'message': '0/1', 'kind': 'report'}, 'token': 'backgroundIndexProgress'}
clangd: I[15:44:59.930] --> workspace/semanticTokens/refresh(1)
clangd: I[15:44:59.930] <-- reply(1)
:: [15:44:59.930] <-- clangd workspace/semanticTokens/refresh (1): None
:: [15:44:59.930] >>> clangd (1) (duration: 0ms): None
clangd: I[15:44:59.952] --> textDocument/publishDiagnostics
clangd: I[15:44:59.952] --> reply:textDocument/documentLink(2) 45 ms
:: [15:44:59.952] <-  clangd textDocument/publishDiagnostics: {'uri': 'file:///D:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/src/Spectrum/test.cu', 'diagnostics': [{'message': "Cannot find CUDA installation; provide its path via '--cuda-path', or pass '-nocudainc' to build without CUDA includes", 'severity': 1, 'relatedInformation': [], 'source': 'clang', 'code': 'drv_no_cuda_installation', 'range': {'end': {'character': 0, 'line': 0}, 'start': {'character': 0, 'line': 0}}}, {'message': "Cannot find libdevice for sm_35; provide path to different CUDA installation via '--cuda-path', or pass '-nocudalib' to build without linking with libdevice", 'severity': 1, 'relatedInformation': [], 'source': 'clang', 'code': 'drv_no_cuda_libdevice', 'range': {'end': {'character': 0, 'line': 0}, 'start': {'character': 0, 'line': 0}}}, {'message': "'cuda_runtime.h' file not found", 'severity': 1, 'relatedInformation': [], 'source': 'clang', 'code': 'pp_file_not_found', 'range': {'end': {'character': 25, 'line': 0}, 'start': {'character': 9, 'line': 0}}}], 'version': 0}
:: [15:44:59.963] <<< clangd (2) (duration: 57ms): []
clangd: I[15:45:00.189] --> $/progress
clangd: I[15:45:00.189] --> $/progress
:: [15:45:00.189] <-  clangd $/progress: {'value': {'percentage': 0, 'message': '0/1', 'kind': 'report'}, 'token': 'backgroundIndexProgress'}
:: [15:45:00.189] <-  clangd $/progress: {'value': {'kind': 'end'}, 'token': 'backgroundIndexProgress'}
clangd: I[15:45:05.998] <-- textDocument/didOpen
clangd: I[15:45:06.000] <-- textDocument/documentLink(3)
clangd: I[15:45:06.000] ASTWorker building file D:\arc_blanc_these\Programmes\HybridizationPlugin\TessendorfPlugin\src\Spectrum\test.cpp version 0 with command
clangd: [D:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin]
clangd: "C:\\Users\\david\\AppData\\Local\\Sublime Text\\Package Storage\\LSP-clangd\\clangd_15.0.6\\bin\\g++" --driver-mode=g++ -MD -MP -DDEBUG -DPLUGINHYBRIDIZATION_SHARED_EXPORTS -ID:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/include -ID:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/include/Kernels -ID:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/include/Spectrum -ID:/arc_blanc_these/Programmes/HybridizationPlugin/HybridizationInterop/include -ID:/arc_blanc_these/Programmes/HybridizationPlugin/HybridizationCommon/include -ID:/arc_blanc_these/Programmes/HybridizationPlugin/HybridizationInterop/include/Kernels -ID:/InteropUnityCUDA/Plugin/Utilities/include -m64 -g -o D:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/temp/x64/Debug/test.o -MF D:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/temp/x64/Debug/test.d -c "-resource-dir=C:\\Users\\david\\AppData\\Local\\Sublime Text\\Package Storage\\LSP-clangd\\clangd_15.0.6\\lib\\clang\\15.0.6" -- "D:\\arc_blanc_these\\Programmes\\HybridizationPlugin\\TessendorfPlugin\\src\\Spectrum\\test.cpp"
clangd: I[15:45:06.016] --> workspace/semanticTokens/refresh(2)
:: [15:45:05.997]  -> clangd textDocument/didOpen: {'textDocument': {'uri': 'file:///D:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/src/Spectrum/test.cpp', 'languageId': 'cpp', 'text': '#include "cuda_runtime.h"', 'version': 0}}
clangd: I[15:45:06.026] <-- textDocument/codeAction(4)
:: [15:45:05.999] --> clangd textDocument/documentLink (3): {'textDocument': {'uri': 'file:///D:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/src/Spectrum/test.cpp'}}
clangd: I[15:45:06.032] <-- reply(2)
:: [15:45:06.025] --> clangd textDocument/codeAction (4): {'context': {'diagnostics': [], 'triggerKind': 2}, 'range': {'end': {'character': 0, 'line': 0}, 'start': {'character': 0, 'line': 0}}, 'textDocument': {'uri': 'file:///D:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/src/Spectrum/test.cpp'}}
clangd: I[15:45:06.034] --> textDocument/publishDiagnostics
clangd: I[15:45:06.034] --> reply:textDocument/documentLink(3) 34 ms
clangd: I[15:45:06.034] --> reply:textDocument/codeAction(4) 7 ms
:: [15:45:06.031] <-- clangd workspace/semanticTokens/refresh (2): None
:: [15:45:06.031] >>> clangd (2) (duration: 0ms): None
:: [15:45:06.048] <-  clangd textDocument/publishDiagnostics: {'uri': 'file:///D:/arc_blanc_these/Programmes/HybridizationPlugin/TessendorfPlugin/src/Spectrum/test.cpp', 'diagnostics': [{'message': "'cuda_runtime.h' file not found", 'severity': 1, 'relatedInformation': [], 'source': 'clang', 'code': 'pp_file_not_found', 'range': {'end': {'character': 25, 'line': 0}, 'start': {'character': 9, 'line': 0}}}], 'version': 0}
:: [15:45:06.050] <<< clangd (3) (duration: 51ms): []
:: [15:45:06.051] <<< clangd (4) (duration: 25ms): []

I will check if the cuda path has been well defined.

davidAlgis commented 1 year ago

The problem seems to be solved by adding the include of cuda in the include folder of clangd... But it's a bit dirty ^^

rchl commented 1 year ago

@rchl according to code.visualstudio.com/docs/languages/identifiers it's cuda-cpp

I don't know then. I've seen some google results where people are passing cuda. Even tried to find some references to it in clagnd code but couldn't find any which makes me think that it might not care and just follow the file extension...

davidAlgis commented 1 year ago

As it works when adding cuda include in the include folder of clangd. I tried to add --cuda-path option to clangd, but the option doesn't seems to exists in clangd arguments (I have not seen it with --help). So where should I add this option ? In compile commands ?

LDAP commented 1 year ago

So where should I add this option ?

This should be an option for clang, not clangd. You should add it into your compilation database.

davidAlgis commented 1 year ago

Ok thanks @LDAP ! Sorry I'm a bit a beginner on clang, have you any idea how i can add this option in compilation database ?

LDAP commented 1 year ago

I do not use Cuda myself, but the workflow should be as follows:

You need a compile_commands.json or compile_flags.txt file (see https://github.com/sublimelsp/LSP-clangd#usage) you can manually edit these files and add the option where necessary. Ideally, the generator of those files adds the option for you - maybe you need to tweak your build system to detect Cuda (regenerating the files would overwrite your customization).

davidAlgis commented 1 year ago

@LDAP thanks for the details.

davidAlgis commented 1 year ago

I found a similar issue on the github of vscode clangd extenstion.

I solve this by adding a .clangd file at the root of 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