ktlsp
A fast, lightweight language server for Kotlin and Java, written in Rust.
ktlsp focuses on the editor loop: quick startup, low overhead, useful navigation, and
conservative answers. It uses tree-sitter and an in-memory index instead of keeping a compiler or
JVM on the request path.
Features
Kotlin and Java support includes:
- definitions, references, implementations, and type definitions
- completion, hover, signature help, highlights, and symbols
- rename, auto-import, and unused-import actions
- semantic tokens, inlay hints, folding, and selection ranges
- call and type hierarchies
- navigation into dependency, JDK, and Android SDK sources
- fast, compiler-free diagnostics
Results are intentionally conservative: when the index cannot prove an answer, ktlsp may return
no result instead of guessing. Kotlin type inference, overload resolution, and Gradle modeling are
not yet compiler-complete.
Install
Download a binary from GitHub Releases, or install
from source:
cargo install --git https://github.com/pepegar/ktlsp ktlsp
With Nix:
nix run github:pepegar/ktlsp
Building requires a Rust toolchain and a C compiler for the tree-sitter grammars.
Editor setup
ktlsp communicates over standard input and output. Configure your editor to start ktlsp for
Kotlin and Java files.
Neovim example:
vim.lsp.start({
name = "ktlsp",
cmd = { "ktlsp" },
root_dir = vim.fs.root(0, {
"settings.gradle.kts",
"settings.gradle",
"build.gradle.kts",
"build.gradle",
".git",
}),
})
Logs are written to standard error. Set RUST_LOG=ktlsp=debug for debug logging.
Zed
Zed's Java and Kotlin support comes from extensions that bundle their own language servers
(Eclipse JDTLS and JetBrains' Kotlin LSP or the community kotlin-language-server). To use
ktlsp instead, install the extensions for file-type association and syntax highlighting, then
override the language server binary each one launches with the lsp
setting in
settings.json:
{
"lsp": {
"jdtls": {
"binary": {
"path": "ktlsp"
}
},
"kotlin-lsp": {
"binary": {
"path": "ktlsp"
}
}
}
}
jdtls is the adapter name used by Zed's Java extension; kotlin-lsp is the default adapter used
by Zed's Kotlin extension (use kotlin-language-server instead if you've switched to the
community server). Overriding binary.path replaces the extension's managed server binary with
ktlsp while keeping the extension installed for tree-sitter and language detection.
Claude Code
The repository is also a Claude Code plugin marketplace. The ktlsp-lsp plugin connects Claude
Code's built-in LSP tools to ktlsp for Kotlin, Kotlin Script, and Java files.
Install ktlsp first using one of the methods above and verify the binary is on the PATH used to
start Claude Code:
command -v ktlsp
Then add the marketplace and install the plugin from Claude Code:
/plugin marketplace add pepegar/ktlsp
/plugin install ktlsp-lsp@ktlsp
/reload-plugins
Claude Code LSP plugins configure a connection to an installed language server; they do not install
the server binary itself. If another Kotlin or Java LSP plugin is enabled, disable it to avoid an
extension conflict. See the plugin README for CLI installation,
troubleshooting, local validation, and community-marketplace publishing notes.
Configuration
ktlsp reads Gradle version catalogs and resolves source archives from local Gradle and Maven
caches, Maven Central, installed JDKs, and Android SDKs. Extracted sources and symbol caches are
stored in the platform cache directory.
Useful environment variables:
KTLSP_CACHE_DIR — override writable cache storage
KTLSP_JDK_SRC — point to a JDK src.zip
KTLSP_ANDROID_SOURCES — point to an Android sources directory or archive
KTLSP_ANDROID_SOURCES_DOWNLOAD=0 — disable Android source downloads
Formatting is opt-in through initializationOptions.formatting and delegates to an external
formatter such as ktfmt.
Benchmarks
A July 2026 protocol-level comparison used Pinterest ktlint (multi-module JVM) and Square Okio
(Kotlin Multiplatform), with one cold run and medians of three warm process restarts.