8000 Restart IDE when external C/C++ file is opened in active editor leads to clangd compilation commands fallback · Issue #87 · eclipse-cdt/cdt-lsp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

Restart IDE when external C/C++ file is opened in active editor leads to clangd compilation commands fallback #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghentschke opened this issue May 17, 2023 · 4 comments · Fixed by #103
Assignees
Milestone

Comments

@ghentschke
Copy link
Contributor
ghentschke commented May 17, 2023

When clangd cannot find a compile_commands.json the fallback values are used.

Solution proposal:
I assume that in most cases this external file has been opened by a hyperlink in the editor. During startup, the LS will be started, when the active editor is the LSP based C/C++ editor.
If the IDE keeps track of the origin file, the LS has to be started with this origin file, which must be a file in the current workspace. If the origin file is not a workspace file then get the origin of this file and so on until a project file (with a compile_commands.json) has been reached. When the LS server is started with the origin file, clangd will inherit the compile settings from the first opened file for the external file in focus.

@ddscharfe
Copy link
Contributor

Sounds good. I don't know if you meant it this way, but I think each editor would have to keep the whole chain of files from where it was opened. Otherwise if one of the intermediate editors is closed before restarting, after restart the editor would not be able to find the next origin which is in the workspace.

@ghentschke
Copy link 10000
Contributor Author

but I think each editor would have to keep the whole chain of files from where it was opened.

Yep, good point, and this info should be stored persistent.

@ddscharfe
Copy link
Contributor

I had a quick look how to implement this. I think we'll have to make some changes in lsp4e.
org.eclipse.lsp4e.operations.declaration.OpenDeclarationHyperlinkDetector::toHyperlinks might be the right place, because it creates the IHyperlink which is used to open the editor.

@ghentschke ghentschke self-assigned this May 22, 2023
@ghentschke
Copy link
Contributor Author

I provided a PR to LSP4E with a similar approach to support a LS per project. The PR was declined, because it was to LS specific.

ghentschke added a commit to ghentschke/eclipse-cdt-lsp that referenced this issue Jun 1, 2023
clangd has trouble on Windows machines to detect the system headers.
Therefore we add the includes paths from the first project file opened
by the LS client to the fallbackFlags.

see https://clangd.llvm.org/extensions#compilation-commands

LIMITATION: The include path detection by
ICBuildConfiguration.getScannerInformation works currently only for the
clang compiler. g++/gcc doesn't work.

fixes eclipse-cdt#87
ghentschke added a commit to ghentschke/eclipse-cdt-lsp that referenced this issue Jun 2, 2023
clangd has trouble on Windows machines to detect the system headers.
Therefore we add the includes paths from the first project file opened
by the LS client to the fallbackFlags.

see https://clangd.llvm.org/extensions#compilation-commands

LIMITATION: The include path detection by
ICBuildConfiguration.getScannerInformation works currently only for the
clang compiler. g++/gcc doesn't work.

fixes eclipse-cdt#87
ghentschke added a commit to ghentschke/eclipse-cdt-lsp that referenced this issue Jun 2, 2023
clangd has trouble on Windows machines to detect the system headers.
Therefore we add the includes paths from the first project file opened
by the LS client to the fallbackFlags.

see https://clangd.llvm.org/extensions#compilation-commands

LIMITATION: The include path detection by
ICBuildConfiguration.getScannerInformation works currently only for the
clang compiler. g++/gcc doesn't work.

fixes eclipse-cdt#87
ghentschke added a commit to ghentschke/eclipse-cdt-lsp that referenced this issue Jun 2, 2023
clangd has trouble on Windows machines to detect the system headers.
Therefore we add the includes paths from the first project file opened
by the LS client to the fallbackFlags.

see https://clangd.llvm.org/extensions#compilation-commands

LIMITATION: The include path detection by
ICBuildConfiguration.getScannerInformation works currently only for the
clang compiler. g++/gcc doesn't work.

fixes eclipse-cdt#87
ruspl-afed pushed a commit that referenced this issue Jun 2, 2023
clangd has trouble on Windows machines to detect the system headers.
Therefore we add the includes paths from the first project file opened
by the LS client to the fallbackFlags.

see https://clangd.llvm.org/extensions#compilation-commands

LIMITATION: The include path detection by
ICBuildConfiguration.getScannerInformation works currently only for the
clang compiler. g++/gcc doesn't work.

fixes #87
@jonahgraham jonahgraham added this to the 1.0.0 milestone Sep 18, 2023
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 a pull request may close this issue.

3 participants
0