Skip to content

Set path to compileCommands automatically. - #247

Open
Symbitic wants to merge 1 commit into
xmake-io:devfrom
Symbitic:dev
Open

Set path to compileCommands automatically.#247
Symbitic wants to merge 1 commit into
xmake-io:devfrom
Symbitic:dev

Conversation

@Symbitic

@Symbitic Symbitic commented Jan 5, 2024

Copy link
Copy Markdown

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

waruqi commented Jan 5, 2024

Copy link
Copy Markdown
Member

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

Comment thread src/xmake.ts
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
Copy Markdown
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

123485k commented Jan 6, 2024

Copy link
Copy Markdown

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

@bytesiz3d

Copy link
Copy Markdown

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

Comment thread README.md
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
Copy Markdown
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