Skip to content

Conversation

Symbitic
Copy link

@Symbitic Symbitic commented Jan 5, 2024

I'm not sure if this is a feature or a bug fix, but this removes the need for setting the path to the compile commands file in .vscode/c_cpp_properties.json by setting C_Cpp.default.compileCommands.

With this, IntelliSense should work as soon as XMake is run for the first time.

@waruqi
Copy link
Member

waruqi commented Jan 5, 2024

If the user does not have cpptools installed and is only using clangd. Does it work? https://xmake.io/#/plugin/more_plugins?id=clangd

const compileCommandsFile = path.join(config.compileCommandsDirectory, "compile_commands.json");
const compileCommandsWatcher = vscode.workspace.createFileSystemWatcher(compileCommandsFile);
compileCommandsWatcher.onDidCreate(() => {
const config = vscode.workspace.getConfiguration('C_Cpp');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the user does not have cpptools installed, do we always get a valid config instead of undefined?

@123485k
Copy link

123485k commented Jan 6, 2024

可以参考下cmake插件的实现vscode-cmake-tools/src/cpptools.ts
使用ConfigurationProvider可以无需编辑配置文件,自动让Cpptools使用xmake生成的配置

@bytesiz3d
Copy link

This PR would help me a lot, makes working with Xmake very convenient.

These configuration settings are stored in your project's c_cpp_properties.json file. To edit this file, in VS Code, select C/C++: Edit Configurations (UI) from the Command Palette (⇧⌘P):

Please see [IntelliSense for cross-compiling](https://code.visualstudio.com/docs/cpp/configure-intellisense-crosscompilation)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep this section in case something goes wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants