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), and C (.c, .h) 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 stdlib stubs for built-in extension functions
- Kotlin stdlib stubs: F12 on
isNotBlank, firstOrNull, let, apply, scan, buildList, require, etc. opens the bundled kotlin-stdlib-stubs.kt reference with signatures and KDoc 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
- Android ViewBinding mapping:
ActivityDeviceInfoBinding automatically maps to res/layout*/activity_device_info.xml for direct jump
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: Kotlin / Java / 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 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.1.18.vsix
Release Notes
0.1.18
- 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).
- Returns full ranked list: Indexed open-file matches now return all candidates sorted by relevance (rather than just the single best), so VS Code's Peek view shows the same order as Quick Reference Search. Project-scan fallbacks also share the same ranking.
0.1.17
- Quick Reference Search in Project: New command
kotlinJavaCLanguageServer.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", 'chars', and Kotlin triple-quoted ("""…""") blocks.
- LSP
referencesProvider: The server now implements textDocument/references, so other clients (and VS Code's own "Find All References" / Peek View) also work for Kotlin, Java, C, and C++ files.
0.1.16
- C++ support: Added full C++ (
.cpp, .cc, .cxx, .hpp, .hh, .hxx) language support — @ document symbols, F12 Go to Definition, Breadcrumbs, and workspace symbol search now work for C++ files.
- C++ symbols: class, struct, namespace, enum class (with members), template class/function, operator overloads, destructor,
using type alias, out-of-line method definitions (Foo::bar()), local variables and function parameters.
0.1.15
- Critical fix: extension now activates when opening Kotlin / Java / C files — Added
onLanguage:kotlin, onLanguage:java, onLanguage:c to activationEvents, and packaged node_modules into VSIX. Previously the LSP server never started, causing blank @ symbols, broken F12, and missing Breadcrumbs.
- F12 on function parameters — Pressing F12 on parameters like
intensityLevel or originalColorValue now correctly jumps to their declaration in the function signature.
- F12 on local
val/var — Pressing F12 on local variables like hatX now correctly jumps to their declaration.
- Scope-aware Go to Definition: When multiple symbols share the same name, the definition closest to (and before) the cursor in the same file is preferred over definitions in other files.
0.1.13
- Kotlin stdlib F12 navigation: Press
F12 (Go to Definition) on built-in Kotlin extension functions such as isNotBlank, firstOrNull, let, apply, scan, buildList, require, coerceIn, joinToString, etc. to jump to a bundled reference stub file (assets/kotlin-stdlib-stubs.kt) that shows the function signature and a KDoc description.
- Stdlib stubs coverage: CharSequence (
isEmpty, isNotEmpty, isBlank, isNotBlank, trim, lines …), nullable String (isNullOrBlank, isNullOrEmpty, orEmpty), String (toInt/OrNull, toLong/OrNull, substringAfter/Before/Last, removePrefix/Suffix, startsWith, endsWith, padStart/End, chunked, trimIndent, ifEmpty, ifBlank, encodeToByteArray, toRegex …), scope functions (let, run, apply, also, with, takeIf, takeUnless), Collection/Iterable (first/OrNull, last/OrNull, single/OrNull, any, all, none, filter, map, mapIndexed, flatMap, fold, reduce, scan, runningFold, groupBy, sortedBy/Descending, distinct/By, take/While, drop/While, zip, zipWithNext, unzip, windowed, associate/With/By, intersect, union, subtract, partition, onEach, joinToString, maxByOrNull, minByOrNull, sumOf, withIndex, ifEmpty …), Map (getOrDefault, getOrPut, mapKeys, mapValues), top-level utilities (buildString, buildList, buildSet, buildMap, lazy, require, requireNotNull, check, checkNotNull, error, TODO, repeat, listOf, setOf, mapOf …), and Range operators (downTo, until, step).
- User symbols take priority: The stdlib lookup is step 5 (last resort), so your own functions with the same name always jump to your code first.
0.1.12
- Kotlin enum members with constructor params:
PENDING(0), / ACTIVE(1), and all parameterised enum entries are now correctly indexed as enummember symbols (was: silently dropped due to a regex anchor bug on the prefix before ().
- Kotlin
annotation class: Classes declared with annotation class (e.g. Spring / Jakarta / Android custom annotations) are now indexed. Also enables fun interface SAM declarations.
- Kotlin
operator / override / tailrec functions: Methods declared with operator fun, override fun, tailrec fun, external fun, actual fun, or expect fun are now indexed as method / function symbols.
- Kotlin extension functions on generic receivers:
fun List<T>.filterActive(), fun Flow<T>.retry(), and similar extensions on parameterised types are now matched correctly.
- Kotlin
for ((key, value) in map) destructuring: Destructured loop variables are now extracted as parameter symbols before the control-flow guard fires.
- C pointer-return-type functions: Functions like
Buffer *buffer_create(...), struct Node *node_create(...), and char *strdup(...) — where there is no space between * and the function name — are now parsed correctly. struct/union/enum return-type prefixes are also handled.
- C anonymous
typedef struct / typedef enum / typedef union: The closing line } Alias; is now matched by a new typealias rule, so Student, StatusCode, EventHandlers, PageTableEntry, U32Split, and similar names are indexed.
- Java
@interface annotation types: Annotation type declarations (e.g. @interface Transactional) are now recognised and listed as protocol symbols.
- Comprehensive test suite: Added
tmp/test_sample.{kt,java,c} (25 Kotlin / 15 Java / 25 C scenarios) and src/test/comprehensive.test.ts (52 tests) covering lambdas, destructuring, macros, typedefs, generics, sealed classes, records, varargs, and more.
0.1.11
- Kotlin & Java lambda parameters: Index lambda parameters (parenthesized and single-param forms) and emit them as
parameter symbols so lambda arguments can be navigated.
- Kotlin destructuring: Detect destructuring declarations (
val (a, b) = ..., for ((k, v) in ...)) and function parameter destructuring.
- C macros & typedefs: Index
#define macros as macro symbols and correctly recognize function-pointer typedefs (e.g., typedef void (*cb_t)(int)) as typealias.
- Tests & packaging: Added unit tests for sample files and produced the VSIX package
kotlin-java-language-server-0.1.11.vsix.
0.1.10
- C local symbol parsing: C function-local variables are now indexed for navigation, including declarations such as
size_t dlen, clen; and int val;
- Improved C F12 support: Go to Definition can now jump to local C variables like
clen and val inside the current function
0.1.9
- C Breadcrumbs fix: C functions now stay visible in Breadcrumbs when the function signature spans multiple lines or the opening brace appears on a later line
- Improved C function parsing: Multiline C function signatures now produce hierarchical
DocumentSymbol ranges that cover the full function body
0.1.8
- Output logging: Added dedicated Output and Trace channels for language-server logs in VS Code
- Error visibility: Startup failures and uncaught server errors are now written to Output and revealed automatically on error
0.1.7
- Breadcrumb symbol path: Kotlin, Java, and C now return hierarchical
DocumentSymbol trees so VS Code Breadcrumbs can show the current type and function or method path
- Improved symbol ranges: Type and executable symbol ranges now cover their full scopes, which makes current-scope detection work inside method and function bodies
0.1.5
- Symbol search ranking: Workspace symbol results are now sorted by relevance — exact match → prefix match (CamelCase preferred) → contains match
- ViewBinding in
# search: Typing ActivityMain in quick open (#) now resolves to the corresponding XML layout file
- Improved ViewBinding conversion: Better handling of edge cases like
HTTPResponseBinding → http_response.xml
0.1.4
- Phase 1: Enhanced symbol parsing — supports inner class, value class, annotation class, sealed permits, static nested class, companion object with name, annotated methods
- Annotation stripping: Robust handling of complex annotations (balanced parentheses)
- Control flow filter fix: No longer filters valid lines containing keywords in method bodies
| |