swiftlang / sourcekit-lsp

Language Server Protocol implementation for Swift and C-based languages
Apache License 2.0
3.33k stars 280 forks source link

Respect .clangd CompilationDatabase configuration #1816

Open ADKaster opened 2 weeks ago

ADKaster commented 2 weeks ago

Description

SourceKit-LSP does not search in the relative path provided by the clangd config file's CompilationDatabase configuration.

https://clangd.llvm.org/config#compilationdatabase

Example .clangd:

CompileFlags:
  CompilationDatabase: Build/release

Diagnostics:
  UnusedIncludes: None
  MissingIncludes: None

Given only this configuration, clangd finds my compile_commands.json in Build/release relative to the project root.

SourceKit-LSP only finds my compile_commands json after creating a symlink to the project root.

Here's the log from the Swift tab of VsCode's Output window:

13:58:42: Swift version 6.1-dev (LLVM cdc8e8b92cfb482, Swift fc03688e63434e8)
Swift Path: /home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-09-18/usr/bin
Toolchain Path: /home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-09-18/usr
Runtime Library Path: /home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-09-18/usr/lib/swift/linux
Default Target: x86_64-unknown-linux-gnu
13:58:42: SourceKit-LSP setup
13:58:42: focus: undefined
14:36:48: unfocus: undefined
14:36:49: ladybird-browser: add: /home/andrew/ladybird-org/ladybird-browser
14:36:49: ladybird-browser: focus: /home/andrew/ladybird-org/ladybird-browser

At 14:36:49 I added the symlink ln -s Build/release/compile_commands.json compile_commands.json, and SourceKit-LSP immediately picked it up.

ahoppen commented 2 weeks ago

Synced to Apple’s issue tracker as rdar://139673190