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 stdlib stubs for built-in extension functions
- 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
- 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
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
- Install VSIX:
code --install-extension swift-objc-language-server-0.1.17.vsix
Release Notes
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.
| |