{"id":13428764,"url":"https://github.com/fwcd/kotlin-language-server","last_synced_at":"2025-04-29T23:40:33.206Z","repository":{"id":37484425,"uuid":"135159301","full_name":"fwcd/kotlin-language-server","owner":"fwcd","description":"Kotlin code completion, diagnostics and more for any editor/IDE using the Language Server Protocol","archived":false,"fork":false,"pushed_at":"2025-02-26T00:24:03.000Z","size":38470,"stargazers_count":1818,"open_issues_count":215,"forks_count":225,"subscribers_count":29,"default_branch":"main","last_synced_at":"2025-04-10T00:12:33.279Z","etag":null,"topics":["atom","autocomplete","code-completion","ide","kotlin","language-server","language-server-protocol","lsp","vscode"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fwcd.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-28T12:40:14.000Z","updated_at":"2025-04-08T10:44:22.000Z","dependencies_parsed_at":"2023-10-11T20:48:04.847Z","dependency_job_id":"e5e94de8-8533-4a29-b246-19148bc57e94","html_url":"https://github.com/fwcd/kotlin-language-server","commit_stats":{"total_commits":1384,"total_committers":68,"mean_commits":"20.352941176470587","dds":0.3988439306358381,"last_synced_commit":"bdba774daa2f4113a723b7a2d07d696be3b563cf"},"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwcd%2Fkotlin-language-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwcd%2Fkotlin-language-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwcd%2Fkotlin-language-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwcd%2Fkotlin-language-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fwcd","download_url":"https://codeload.github.com/fwcd/kotlin-language-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251602591,"owners_count":21615955,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["atom","autocomplete","code-completion","ide","kotlin","language-server","language-server-protocol","lsp","vscode"],"created_at":"2024-07-31T01:01:04.542Z","updated_at":"2025-04-29T23:40:33.136Z","avatar_url":"https://github.com/fwcd.png","language":"Kotlin","funding_links":[],"categories":["Libraries","Kotlin","Languages","Android应用"],"sub_categories":["资源传输下载"],"readme":"# Kotlin Language Server\n\n[![Release](https://img.shields.io/github/release/fwcd/kotlin-language-server)](https://github.com/fwcd/kotlin-language-server/releases)\n[![Build](https://github.com/fwcd/kotlin-language-server/actions/workflows/build.yml/badge.svg)](https://github.com/fwcd/kotlin-language-server/actions/workflows/build.yml)\n[![Downloads](https://img.shields.io/github/downloads/fwcd/kotlin-language-server/total)](https://github.com/fwcd/kotlin-language-server/releases)\n[![Chat](https://img.shields.io/badge/chat-on%20discord-7289da)](https://discord.gg/cNtppzN)\n\nA [language server](https://microsoft.github.io/language-server-protocol/) that provides smart code completion, diagnostics, hover, document symbols, definition lookup, method signature help and more for [Kotlin](https://kotlinlang.org).\n\n![Icon](Icon128.png)\n\nAny editor conforming to LSP is supported, including [VSCode](https://github.com/fwcd/vscode-kotlin) and [Atom](https://github.com/fwcd/atom-ide-kotlin).\n\n## Getting Started\n\n* See [BUILDING.md](BUILDING.md) for build instructions\n* See [Editor Integration](EDITORS.md) for editor-specific instructions\n* See [Troubleshooting](TROUBLESHOOTING.md) for tips on troubleshooting errors\n* See [Roadmap](https://github.com/fwcd/kotlin-language-server/projects/1) for features, planned additions, bugfixes and changes\n* See [Kotlin Quick Start](https://github.com/fwcd/kotlin-quick-start) for a sample project\n* See [Kotlin Debug Adapter](https://github.com/fwcd/kotlin-debug-adapter) for editor-agnostic launch and debug support of Kotlin/JVM programs\n* See [tree-sitter-kotlin](https://github.com/fwcd/tree-sitter-kotlin) for an experimental [Tree-Sitter](https://tree-sitter.github.io/tree-sitter/) grammar\n\n## Packaging\n\n[![Packaging status](https://repology.org/badge/vertical-allrepos/kotlin-language-server.svg)](https://repology.org/project/kotlin-language-server/versions)\n\n## This repository needs your help!\n\n[The original author](https://github.com/georgewfraser) created this project while he was considering using Kotlin in his work. He ended up deciding not to and is not really using Kotlin these days though this is a pretty fully-functional language server that just needs someone to use it every day for a while and iron out the last few pesky bugs.\n\nThere are two hard parts of implementing a language server:\n- Figuring out the dependencies\n- Incrementally re-compiling as the user types\n\nThe project uses the internal APIs of the [Kotlin compiler](https://github.com/JetBrains/kotlin/tree/master/compiler).\n\n### Figuring out the dependencies\n\nDependencies are determined by the [DefaultClassPathResolver.kt](shared/src/main/kotlin/org/javacs/kt/classpath/DefaultClassPathResolver.kt), which invokes Maven or Gradle to get a list of classpath JARs. Alternatively, projects can also 'manually' provide a list of dependencies through a shell script, located either at `[project root]/kls-classpath` or `[config root]/kotlin-language-server/classpath`, which outputs a list of JARs. Depending on your platform, the scripts also can be suffixed with `.{sh,bat,cmd}`.\n\n* Example of the `~/.config/kotlin-language-server/classpath` on Linux:\n```bash\n#!/bin/bash\necho /my/path/kotlin-compiler-1.4.10/lib/kotlin-stdlib.jar:/my/path/my-lib.jar\n```\n\n* Example of the `%HOMEPATH%\\.config\\kotlin-language-server\\classpath.bat` on Windows:\n```cmd\n@echo off\necho C:\\my\\path\\kotlin-compiler-1.4.10\\lib\\kotlin-stdlib.jar;C:\\my\\path\\my-lib.jar\n```\n\n### Incrementally re-compiling as the user types\n\nI get incremental compilation at the file-level by keeping the same `KotlinCoreEnvironment` alive between compilations in [Compiler.kt](server/src/main/kotlin/org/javacs/kt/compiler/Compiler.kt). There is a performance benchmark in [OneFilePerformance.kt](server/src/test/kotlin/org/javacs/kt/OneFilePerformance.kt) that verifies this works.\n\nGetting incremental compilation at the expression level is a bit more complicated:\n- Fully compile a file and store in [CompiledFile](server/src/main/kotlin/org/javacs/kt/CompiledFile.kt):\n    - `val content: String` A snapshot of the source code\n    - `val parse: KtFile` The parsed AST\n    - `val compile: BindingContext` Additional information about the AST from typechecking\n- After the user edits the file:\n    - Find the smallest section the encompasses all the user changes\n    - Get the `LexicalScope` encompassing this region from the `BindingContext` that was generated by the full-compile\n    - Create a fake, in-memory .kt file with just the expression we want to re-compile\n        - [Add space](https://github.com/fwcd/kotlin-language-server/blob/427cfa7a688d6d2ff202625ebad1ea605e3b8c37/server/src/main/kotlin/org/javacs/kt/CompiledFile.kt#L125) at the top of the file so the line numbers match up\n    - Re-compile this tiny fake file\n\nThe incremental expression compilation logic is all in [CompiledFile.kt](server/src/main/kotlin/org/javacs/kt/CompiledFile.kt). The Kotlin AST has a built-in repair API, which seems to be how IntelliJ works, but as far as I can tell this API does not work if the surrounding IntelliJ machinery is not present. Hence I created the \"fake tiny file\" incremental-compilation mechanism, which seems to be quite fast and predictable.\n\nThere is an extensive suite of behavioral [tests](server/src/test/kotlin/org/javacs/kt), which are all implemented in terms of the language server protocol, so you should be able to refactor the code any way you like and the tests should still work.\n\n## Modules\n\n| Name | Description |\n| ---- | ----------- |\n| server | The language server executable |\n| shared | Classpath resolution and utilities |\n\n## Scripts\n\n| Name | Command | Description |\n| ---- | ------- | ----------- |\n| release_version.py | `python3 scripts/release_version.py` | Creates a tag for the current version and bumps the development version |\n\n## Protocol Extensions\n\nThe Kotlin language server supports some non-standard requests through LSP. See [KotlinProtocolExtensions](server/src/main/kotlin/org/javacs/kt/KotlinProtocolExtensions.kt) for a description of the interface. The general syntax for these methods is `kotlin/someCustomMethod`.\n\n## Initialization Options\n\nThe Kotlin language server supports some custom initialization options via the `initializationOptions` property in the `initialize` request parameters. See `InitializationOptions` in [Configuration](server/src/main/kotlin/org/javacs/kt/Configuration.kt) for a list of supported properties.\n\n## Features\n\n### Autocomplete\n![Autocomplete](images/Autocomplete.png)\n\n### Signature help\n![Signature Help](images/SignatureHelp.png)\n\n### Hover\n![Hover](images/Hover.png)\n\n### Go-to-definition, find all references\n![Find all references](images/FindAllReferences.png)\n\n### Document symbols\n![Document symbols](images/DocumentSymbols.png)\n\n### Global symbols\n![Global symbols](images/GlobalSymbols.png)\n\n\n## Authors\n* [georgewfraser](https://github.com/georgewfraser)\n* [fwcd](https://github.com/fwcd)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffwcd%2Fkotlin-language-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffwcd%2Fkotlin-language-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffwcd%2Fkotlin-language-server/lists"}