Skip to content

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

Merged
MrSubidubi merged 3 commits into
zed-extensions:mainfrom
10000DOO:add-objc-language-support
Jul 22, 2026
Merged

Declare C, C++, and Objective-C support for sourcekit-lsp#70
MrSubidubi merged 3 commits into
zed-extensions:mainfrom
10000DOO:add-objc-language-support

Conversation

@10000DOO

@10000DOO 10000DOO commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

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

cla-bot Bot commented Apr 10, 2026

Copy link
Copy Markdown

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
Contributor Author

@cla-bot check

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

cla-bot Bot commented Apr 10, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

10000DOO and others added 2 commits April 11, 2026 15:47
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 MrSubidubi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@MrSubidubi MrSubidubi changed the title Add C, C++, and Objective-C language support for sourcekit-lsp Declare C, C++, and Objective-C support for sourcekit-lsp Jul 20, 2026
@10000DOO

Copy link
Copy Markdown
Contributor Author

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!

@MrSubidubi

Copy link
Copy Markdown
Contributor

No problem, thank you for getting the PR up in the first place!

@MrSubidubi
MrSubidubi merged commit 25ccb79 into zed-extensions:main Jul 22, 2026
5 checks passed
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.

2 participants