kotlin java c language_server
Ultra-lightweight VSCode extension + Language Server Protocol (LSP) lightweight server for Kotlin, Java, C and C++ files.
Supported features
- Kotlin (
.kt, .kts), Java (.java), C (.c, .h), and C++ (.cpp, .cc, .cxx, .hpp, .hh, .hxx) documents
- Kotlin syntax highlighting (TextMate grammar)
- Document Symbol (
@ in VSCode quick open): lists symbols for current file
- Breadcrumb symbol path: shows the current Kotlin / Java / C type 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 Kotlin / Java / JVM API stubs. Qualified member calls use receiver types, explicit imports, and supported inheritance/extension declarations. The extension's explicit F12 command can open documentation fallback when no definition target is found and kotlinJavaCLanguageServer.definitionFallback.enabled is enabled; background provider requests and Ctrl/Cmd-click never open documentation automatically
- Callback/type navigation: explicit named Kotlin lambda inputs use supported visible function/constructor callback signatures; Java block-body lambdas can use directly declared non-generic SAMs. Go to Type Definition is separate from F12 on a variable/parameter. Unknown/conflicting callback inputs are not guessed. See supported cases and limits.
- Bundled API stubs: F12 on Kotlin stdlib helpers (
isNotBlank, firstOrNull, let, apply, etc.), common Java APIs, and imported javax.inject / jakarta.inject types opens bundled reference stubs with usage explanations, examples, API-specific caveats and documentation links
- 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 Kotlin / Java / Android / C / C++ summaries, declarations, details, and reference links where available
- Class literal navigation: Supported imported Kotlin
Type::class / @Throws references and Java Type.class references resolve to type declarations, including aliases and unopened source files; ::class is not treated as a parameter declaration.
- Explicit enclosing receivers: Supported
this.member, this@Outer.member, and super@Outer.member expressions resolve through the lexical class hierarchy. Imported nested classes are matched by their declaration paths rather than treating enclosing classes as packages.
- Kotlin type references: Default-imported collection, core, and sequence types such as
List, MutableList, Map, String, and Array jump to bundled declarations; supported collection members also resolve through their declared supertypes.
- Apollo GraphQL navigation: Kotlin imports and supported nested response-model types jump to
.graphql/.gql operation and response-field selections using literal Apollo package/source-directory configuration. Default semantic operation suffixes and response aliases are supported; no build or network access is required. See scope and examples.
- GraphQL enum members: Follow supported typed response-field chains using a local Apollo introspection schema.
data.goldCurrency?.name navigates to the bundled kotlin.Enum.name declaration only when the selected field is proven to be an enum with default enum-class generation; selected response fields navigate to the GraphQL operation. Missing/scalar/list/conflicting schemas are not guessed.
- AndroidX children callbacks: Explicit
forEach/forEachIndexed inputs on the imported androidx.core.view.children property can resolve to android.view.View for proven ViewGroup/RecyclerView receivers, including visible project View extensions. Unknown receivers or shadowed declarations are not guessed.
- Gradle BuildConfig fields:
BuildConfig.FIELD jumps to literal buildConfigField or Android Components buildConfigFields declarations in the corresponding module's Kotlin/Groovy Gradle build script. Multiple flavor declarations remain selectable. Gradle expressions and convention plugins are not evaluated.
- AndroidX RecyclerView constants: Qualified
SCROLL_STATE_IDLE, SCROLL_STATE_DRAGGING, and SCROLL_STATE_SETTLING navigate to bundled reference declarations through the normal definition provider, including Ctrl/Cmd-click.
- Android member documentation fallback: When source lookup finds no target, explicit F12 resolves imported Android / AndroidX member owners and opens the official class reference at the member anchor. F12 and Explain show progress while looking up definitions or documentation.
- Android ViewBinding mapping:
ActivityDeviceInfoBinding automatically maps to res/layout*/activity_device_info.xml for direct jump
Lightweight declaration-based navigation, not a compiler type checker. Complex chained expressions, overload selection, wildcard type imports, and fully semantic references remain limited.
Offline API guides
All ten Kotlin/Java/injection/RecyclerView/C/C++ reference files have English API-level guides covering parameters/results through examples and explanations, null/empty behavior, exceptions, mutability, sequence evaluation, buffer bounds and ownership. Signatures and bodies remain abbreviated navigation placeholders, not compiled SDK implementations; verify target-version availability. javax.inject and jakarta.inject are different namespaces and must match the DI implementation.
Owned copies of extension reference assets are excluded from application lookup; genuine app assets with the same filenames remain searchable. Explicit F12 deduplicates identical provider selections but preserves distinct definitions.
Coverage and the unchanged-code gate: stub documentation audit. Run npm run docs:audit; after reviewing scripts/stub-guides-*.cjs, use node scripts/document-stubs.cjs . --apply and run npm test.
Architecture
src/extension.ts: VSCode Language Client
src/server.ts: Node-based LSP server
src/symbols.ts: Kotlin / Java / C / C++ symbol parsing and cursor word extraction
src/memberResolution.ts / src/callbackBindings.ts: conservative owner lookup, callback input declarations and lexical callback anchors
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 Kotlin, Java, or C file.
- Verify:
Cmd+Shift+O (or quick open with @) shows symbols from current file.
- Breadcrumbs show the current symbol path for Kotlin, Java, and 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 kotlin-java-language-server-0.2.17.vsix
| |