Skip to content

Add C, C++, and Objective-C language support for sourcekit-lsp#70

Open
10000DOO wants to merge 2 commits intozed-extensions:mainfrom
10000DOO:add-objc-language-support
Open

Add C, C++, and Objective-C language support for sourcekit-lsp#70
10000DOO wants to merge 2 commits intozed-extensions:mainfrom
10000DOO:add-objc-language-support

Conversation

@10000DOO
Copy link
Copy Markdown

@10000DOO 10000DOO commented Apr 10, 2026

Problem

In mixed Xcode projects (Swift + Objective-C), sourcekit-lsp only activates for .swift files because this extension only declares Swift as a supported language.

This means:

  • .m / .mm / .h files get no LSP support from sourcekit-lsp
  • Cross-references between Swift and ObjC code don't work (e.g. jump-to-definition from Swift → ObjC class fails)

Solution

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:

  1. Migrates from the deprecated language field to the languages array
  2. Adds Objective-C and Objective-C++ language definitions with tree-sitter-objc grammar
  3. Routes all 5 languages to sourcekit-lsp

This 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-server already generates buildServer.json with all 5 languages declared — so the server side is already set up for this.

Changes

extension.toml:

# Before (deprecated single-language field)
[language_servers.sourcekit-lsp]
language = "Swift"

# After
[language_servers.sourcekit-lsp]
languages = ["Swift", "C", "C++", "Objective-C", "Objective-C++"]

[language_servers.sourcekit-lsp.language_ids]
Swift = "swift"
C = "c"
"C++" = "cpp"
"Objective-C" = "objective-c"
"Objective-C++" = "objective-cpp"

[grammars.objc]
repository = "https://github.com/amaanq/tree-sitter-objc"
commit = "181a81b8f23a2d593e7ab4259981f50122909fda"

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>
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 10, 2026

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'.

@10000DOO
Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed label Apr 10, 2026
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 10, 2026

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant