Declare C, C++, and Objective-C support for sourcekit-lsp - #70
Conversation
Migrate from deprecated `language` field to `languages` array and register sourcekit-lsp for C, C++, and Objective-C in addition to Swift. sourcekit-lsp natively supports these languages via its built-in clangd integration. This mirrors the approach taken by the official VSCode Swift extension, which declares support for all sourcekit-lsp-supported languages. Closes zed-extensions#47 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
We require contributors to sign our Contributor License Agreement, and we don't have @10000DOO on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
Without language definitions, Zed cannot recognize .m/.mm/.h files as Objective-C, causing sourcekit-lsp to never start for these files. - Add tree-sitter-objc grammar - Add languages/objective-c/ with config.toml and highlights.scm - Add languages/objective-cpp/ for .mm file support - Add Objective-C++ to sourcekit-lsp language routing
MrSubidubi
left a comment
There was a problem hiding this comment.
Thanks for this and sorry for the slow reponse!
I removed the additional language definitions for now given our extension publishing prerequisites - people will need to install the corresponding extension for Objective-C this way, but that should still make the language server work with that.
Will leave you a few days to comment on this, otherwise happy to merge!
|
Thanks for the update, and no worries about the timing! That approach makes sense to me — requiring the separate Objective-C extension is a fine trade-off as long as the language server still works. Everything looks good on my end, so please feel free to merge whenever you're ready. Thanks again for your work on this! |
|
No problem, thank you for getting the PR up in the first place! |
Problem
In mixed Xcode projects (Swift + Objective-C), sourcekit-lsp only activates for
.swiftfiles because this extension only declaresSwiftas a supported language.This means:
.m/.mm/.hfiles get no LSP support from sourcekit-lspSolution
sourcekit-lsp already handles C, C++, Objective-C, and Objective-C++ internally via its embedded clangd integration. The server is ready — Zed just isn't routing those file types to it.
This PR:
languagefield to thelanguagesarrayThis matches how the official VSCode Swift extension already works:
https://github.com/swiftlang/vscode-swift/blob/fd00b062831a3919b07071b8b5f5e6a5690c6e8a/src/configuration.ts#L153-L157
Also,
xcode-build-serveralready generatesbuildServer.jsonwith all 5 languages declared — so the server side is already set up for this.Changes
extension.toml: