swift objc language server
Ultra-lightweight VSCode extension + Language Server Protocol (LSP) server for Swift and Objective-C files.
Supported features
- Swift (
.swift) and Objective-C (.m, .h, .mm) documents
- Document Symbol (
@ in VSCode quick open): lists symbols for current file
- Breadcrumb symbol path: shows the current Swift / Objective-C class and function or method in the editor path bar when Breadcrumbs are enabled
- Go to Definition (
F12 / cmd-click): resolves symbols from open documents, then falls back to full-project scan, and finally to bundled Swift / Objective-C stubs for built-in and framework symbols. By default, F12 and Ctrl/Cmd-click open documentation fallback when no definition target is found; this can be disabled with swiftObjcLanguageServer.definitionFallback.enabled
- Swift stdlib stubs: F12 on
map, filter, compactMap, flatMap, sorted, first(where:), allSatisfy, reduce, grouped(by:), chunked(into:), uniqued, clamped(to:), etc. opens the bundled swift-stdlib-stubs.swift reference with signatures and descriptions
- Objective-C/Foundation stubs: F12 on common Objective-C / Foundation / UIKit symbols such as
NSObject, NSString, NSArray, NSDictionary, UIView, UIViewController, NSLog, and dispatch helpers opens bundled local reference stubs
- Workspace Symbol (
# in quick open): searches open documents first, then falls back to full-project scan when no match is found
- Quick Symbol Search in Project (editor right-click menu): searches the workspace from the word under cursor and provides jump targets
- Quick Reference Search in Project (
Cmd+Alt+R / Ctrl+Alt+R, or editor right-click menu): finds every usage of the symbol under the cursor across the workspace. Behaves like Goto Definition — a single match jumps directly, multiple matches open VS Code's inline Peek view
- Explain Unknown Symbol (editor right-click menu / Command Palette): when the symbol under the cursor has no local/project/bundled-stub definition target, opens an in-editor documentation result page with official Apple Developer summaries, declarations, details, and reference links where available
Current scope intentionally focuses on symbols that are already opened in VSCode.
Architecture
src/extension.ts: VSCode Language Client
src/server.ts: Node-based LSP server
src/symbols.ts: Swift / Objective-C symbol parsing and cursor word extraction
This follows the standard VSCode Language Client + Language Server split architecture.
Install dependencies
npm install
Build
npm run compile
Run in VSCode (manual review)
- Open this repository in VSCode.
- Run
npm run compile.
- Press
F5 to launch an Extension Development Host.
- In the new window, open a Swift or Objective-C file.
- Verify:
Cmd+Shift+O (or quick open with @) shows symbols from current file.
- Breadcrumbs show the current symbol path for Swift and Objective-C files when
breadcrumbs.enabled is on.
F12 on a symbol jumps to its definition when the defining file is currently open.
Package and install in local VSCode
- Install VSCE:
npm install -D @vscode/vsce
- Create VSIX:
npx vsce package --allow-missing-repository
- Install VSIX:
code --install-extension swift-objc-language-server-0.2.2.vsix
Release Notes
0.2.2
- Richer Apple Developer documentation pages: Explain Unknown Symbol now reads Apple documentation JSON when available, so in-editor results can include longer summaries, declarations, supported platforms, and topic/member summaries instead of only the short HTML meta description. For example,
UIResponder now shows responder chain and event-handling topics directly in VS Code.
- Import-aware Apple API lookup: Swift / Objective-C documentation fallback now prioritizes frameworks imported in the current file (
import SwiftUI, #import <UIKit/UIKit.h>, @import Foundation;) before falling back to standard library, prefix rules, and common Apple frameworks, so more symbols resolve to direct Apple API pages instead of generic search.
0.2.1
- Explain Unknown Symbol direct lookup: Manually running Explain Unknown Symbol now always opens the official Apple Developer documentation result page for the selected symbol, even when the symbol already has a local definition. F12 / Ctrl-click fallback still only opens documentation when definition lookup returns no target.
- Apple Developer direct URLs: Improved direct documentation mapping for common SwiftUI, Combine, Foundation, UIKit, StoreKit, CoreGraphics, and Dispatch symbols such as
Spacer, ObservableObject, NotificationCenter, and SKStoreProductViewController.
- Swift local parameter navigation: Go to Definition now resolves Swift local declarations and multiline function parameters such as
dropDownMenuText before falling back to project and bundled stub lookup.
0.2.0
- Explain Unknown Symbol: New editor context menu / Command Palette command. It first asks the existing definition provider; only if no local, project, or bundled-stub target exists does it open an in-editor result page with official Apple Developer documentation summaries, declarations, details, and links where available.
- Definition fallback to documentation: Added
swiftObjcLanguageServer.definitionFallback.enabled setting. It defaults to true, so F12 and Ctrl/Cmd-click open the in-editor external documentation result page when definition lookup returns no target. Disable it to keep VS Code's built-in definition behavior only. The fallback command is not shown in the editor context menu to avoid duplicating the built-in Go to Definition item.
- Multi-language builtin stubs: The bundled fallback now covers Swift standard-library symbols and common Objective-C / Foundation / UIKit symbols.
- Swift stdlib coverage expansion: Added common missing Swift symbols and types such as
String, Array, Dictionary, Set, Optional, Result, print, debugPrint, assert, precondition, fatalError, abs, min, and max.
- Objective-C / Foundation references: Added lightweight local reference stub file for high-frequency Objective-C APIs (
NSObject, NSString, NSArray, NSMutableArray, NSDictionary, NSNumber, NSDate, NSURL, NSError, UIView, UIViewController, UITableView, NSLog, dispatch helpers, and memory helpers).
0.1.19
- Swift string interpolation parsing: Fixed Document Symbol / Workspace Symbol / Go to Definition silently dropping every declaration after a single line containing a complex string interpolation. A
print("…\(value.map { "\"\($0)\"" } ?? "-")…") style call would leave the parser stuck in inDoubleQuote mode for the rest of the file because nested quotes inside \(...) were toggling string state instead of being treated as code. The brace-tracking and reference-finder state machines now properly enter "code mode" on \(, run with their own paren depth (with nested strings, closures, and braces), and pop back into the surrounding string on the matching ) — including inside triple-quoted ("""…\(…)…""") and raw (#"…\#(…)…"#) strings. Symbols declared after such a line (and identifier references inside the interpolation) are now indexed correctly.
- Added regression tests covering single-line nested-quote interpolation, multi-line interpolation, and reference search within
\(...).
0.1.18
- Objective-C
static local variable symbols: static variables declared inside a method body (e.g. static NSString *encodedHostname;) are now indexed and navigable via Go to Definition, Document Symbol (@), and Workspace Symbol (#). Regular (non-static) local variables inside methods continue to be excluded to avoid noise.
0.1.17
- Goto Definition relevance ranking: When
F12 finds multiple symbols with the same name, results are now sorted so the most likely definition appears first. Same-file matches win, with closer-to-cursor and at-or-before-cursor preferred; across files, those sharing more directory segments with the current file rank higher. Pure path comparison — no extra IO and the cost is negligible (microseconds for the small candidate set).
- Consistent ranking everywhere: Indexed open-file matches, case-insensitive fallbacks, and full-project scans all use the same scoring helper, so VS Code's Peek view shows the same order regardless of which fallback path was hit.
0.1.16
- Quick Reference Search in Project: New command
swiftObjcLanguageServer.quickReferenceSearch finds every usage of the symbol under the cursor across the workspace. Triggered via right-click menu, Command Palette, or the default keybinding Cmd+Alt+R (macOS) / Ctrl+Alt+R (Windows/Linux).
- Goto Definition–style UI: A single match jumps directly to the location; multiple matches open VS Code's native inline Peek view, identical to
F12 / Peek Definition / Find All References.
- Comment / string aware scanning: Reference matches use whole-word boundaries and skip occurrences inside
// line comments, /* block comments */, "strings", Swift triple-quoted ("""…""") blocks, and extended-delimiter raw strings (#"…"#).
- LSP
referencesProvider: The server now implements textDocument/references, so other clients (and VS Code's own "Find All References" / Peek View) also work for Swift and Objective-C files.
0.1.15
- Swift stdlib F12 navigation: Press
F12 (Go to Definition) on common Swift standard library extension functions such as map, filter, compactMap, flatMap, reduce, allSatisfy, contains(where:), first(where:), sorted(by:), grouped(by:), chunked(into:), uniqued, clamped(to:), partitioned(by:), etc. to jump to a bundled reference stub file (assets/swift-stdlib-stubs.swift) that shows the function signature and description.
- Stdlib stubs coverage: String/StringProtocol (
hasPrefix, hasSuffix, contains, lowercased, uppercased, trimmed, lines, split, components(separatedBy:), toInt, toDouble, matches(pattern:), before(first:), after(first:) …), Optional (map, flatMap, or), Sequence/Collection (map, filter, compactMap, flatMap, forEach, reduce, allSatisfy, contains(where:), first(where:), last(where:), enumerated, sorted(by:), min/max, drop/prefix/suffix, dropFirst/dropLast, partitioned(by:), uniqued, uniqued(by:), adjacentPairs, chunked(into:), firstIndex(where:), [safe:] …), Dictionary (mapValues, filter, merging, mapKeys), Set (intersection, union, subtracting, symmetricDifference), Comparable (clamped(to:), isIn), Result (value, error, isSuccess, isFailure, map, flatMap), plus array helpers (zip, stride, repeatedArray).
- User symbols take priority: The stdlib lookup is last resort (step 5), so your own functions with the same name always navigate to your code first.
0.1.14
- Fixed Go to Definition / Workspace Symbols for Swift files containing extended-delimiter raw strings (
#"..."#). Previously a regex-style raw string with brace quantifiers (e.g. {0,16}) and \#(...) interpolation could desynchronize brace tracking, causing every symbol declared after that string to be silently dropped from the index.
- Restored parser features that existed in the published 0.1.12 binary but were missing from source: nested block comments, triple-quoted strings, extended-delimiter raw strings, and Objective-C duplicate-symbol dedup on the same line.
- Added regression tests covering Swift extended-delimiter raw strings and triple-quoted strings.
0.1.12
- Fixed parsing: avoid duplicate Objective-C symbols when a function and variable share the same identifier on the same line.
- Improved Swift/ObjC position calculation to use regex match offsets for more accurate ranges.
- Added tests and sample files for nested comments, raw/triple-quoted strings, and complex ObjC parameters.
- Packaged a VSIX for local testing (note: consider adding a .vscodeignore to reduce package size).
0.1.11
- Fixed Breadcrumbs for C-style functions declared inside Objective-C implementation files.
- Breadcrumbs now correctly show functions such as
stream_interrupt_cb while the cursor is inside the function body.
0.1.10
- Fixed Swift Breadcrumbs for multiline function signatures where the opening brace appears on a later line.
- Breadcrumbs now correctly show functions such as
execute while the cursor is inside the function body.
0.1.9
- Fixed Objective-C Breadcrumbs for multiline method signatures where the opening brace appears on a later line.
- Breadcrumbs now correctly show methods such as
writeVideoPacket while the cursor is inside the method body.
0.1.8
- Fixed project-wide symbol search for nested Swift symbols, including methods declared inside
extension blocks.
- Quick Symbol Search in Project now finds nested Swift symbols even when only the parent file is open.
0.1.7
- Added dedicated Output and Trace channels for language-server logs in VS Code.
- Startup failures and uncaught server errors are now written to Output and revealed automatically on error.
0.1.6
- Added hierarchical
DocumentSymbol output for both Swift and Objective-C.
- Breadcrumbs can now show the current class and function or method path at the top of the editor.
- Improved symbol ranges so current scope detection works inside method and function bodies.
| |