All Projects → fwcd → Kotlin Language Server

fwcd / Kotlin Language Server

Licence: mit
Intelligent Kotlin support for any editor/IDE using the Language Server Protocol

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Kotlin Language Server

Elm Language Client Vscode
Improving your Elm experience since 2019
Stars: ✭ 162 (-75.08%)
Mutual labels:  hacktoberfest, vscode, lsp, language-server
Ironpython Stubs
Autocomplete stubs for common IronPython/.NET libraries
Stars: ✭ 135 (-79.23%)
Mutual labels:  vscode, atom, autocomplete
Monaco Languageclient
NPM module to connect Monaco editor with language servers
Stars: ✭ 419 (-35.54%)
Mutual labels:  vscode, lsp, language-server
Elm Language Server
Language server implementation for Elm
Stars: ✭ 298 (-54.15%)
Mutual labels:  hacktoberfest, lsp, language-server
Typescript Language Server
TypeScript & JavaScript Language Server
Stars: ✭ 462 (-28.92%)
Mutual labels:  hacktoberfest, lsp, language-server
atom-ide-scala
Scala & Dotty support for Atom IDE (🧟‍♂️ zombie repo)
Stars: ✭ 47 (-92.77%)
Mutual labels:  atom, language-server, lsp
Themer
themer is inspired by trevordmiller/nova and chriskempson/base16.
Stars: ✭ 4,483 (+589.69%)
Mutual labels:  hacktoberfest, vscode, atom
Autocomplete.js
Simple autocomplete pure vanilla Javascript library.
Stars: ✭ 3,428 (+427.38%)
Mutual labels:  hacktoberfest, autocomplete
Themer Gui
A graphical UI for themer. Replaced by Progressive Web App at https://themer.dev.
Stars: ✭ 337 (-48.15%)
Mutual labels:  vscode, atom
T Rec Rs
Blazingly fast terminal recorder that generates animated gif images for the web written in rust
Stars: ✭ 361 (-44.46%)
Mutual labels:  hacktoberfest, vscode
Atom Languageclient
Language Server Protocol support for Atom (the basis of Atom-IDE)
Stars: ✭ 385 (-40.77%)
Mutual labels:  atom, lsp
Terraform Ls
Terraform Language Server
Stars: ✭ 389 (-40.15%)
Mutual labels:  lsp, language-server
Powershelleditorservices
A common platform for PowerShell development support in any editor or application!
Stars: ✭ 394 (-39.38%)
Mutual labels:  hacktoberfest, language-server
Vscode Solargraph
A Visual Studio Code extension for Solargraph.
Stars: ✭ 292 (-55.08%)
Mutual labels:  vscode, language-server
Erlang ls
The Erlang Language Server
Stars: ✭ 363 (-44.15%)
Mutual labels:  lsp, language-server
Ltfinderbuttons
My Finder buttons collection for macOS.
Stars: ✭ 269 (-58.62%)
Mutual labels:  vscode, atom
Ide Php
PHP language support for Atom-IDE
Stars: ✭ 269 (-58.62%)
Mutual labels:  atom, language-server
Import Js
A tool to simplify importing JS modules
Stars: ✭ 511 (-21.38%)
Mutual labels:  vscode, atom
Clojure Lsp
Language Server (LSP) for Clojure
Stars: ✭ 547 (-15.85%)
Mutual labels:  lsp, language-server
Vim Language Server
VImScript language server, LSP for vim script
Stars: ✭ 264 (-59.38%)
Mutual labels:  lsp, autocomplete

Kotlin Language Server

Release Build Downloads Chat

A language server that provides smart code completion, diagnostics, hover, document symbols, definition lookup, method signature help and more for Kotlin.

Icon

Any editor conforming to LSP is supported, including VSCode and Atom.

Getting Started

This repository needs your help!

The original author 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.

There are two hard parts of implementing a language server:

  • Figuring out the dependencies
  • Incrementally re-compiling as the user types

The project uses the internal APIs of the Kotlin compiler.

Dependencies are determined by the findClassPath function, which invokes Maven or Gradle and tells it to output a list of dependencies. Currently, both Maven and Gradle projects are supported.

I get incremental compilation at the file-level by keeping the same KotlinCoreEnvironment alive between compilations in Compiler.kt. There is a performance benchmark in OneFilePerformance.kt that verifies this works.

Getting incremental compilation at the expression level is a bit more complicated:

  • Fully compile a file and store in CompiledFile:
    • val content: String A snapshot of the source code
    • val parse: KtFile The parsed AST
    • val compile: BindingContext Additional information about the AST from typechecking
  • After the user edits the file:
    • Find the smallest section the encompasses all the user changes
    • Get the LexicalScope encompassing this region from the BindingContext that was generated by the full-compile
    • Create a fake, in-memory .kt file with just the expression we want to re-compile
      • Add space at the top of the file so the line numbers match up
    • Re-compile this tiny fake file

The incremental expression compilation logic is all in 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.

There is an extensive suite of behavioral tests, 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.

Modules

Name Description
server The language server executable
shared Classpath resolution and utilities

Scripts

Name Command Description
release_version.py python3 scripts/release_version.py Creates a tag for the current version and bumps the development version

Protocol Extensions

The Kotlin language server supports some non-standard requests through LSP. See KotlinProtocolExtensions for a description of the interface. The general syntax for these methods is kotlin/someCustomMethod.

Features

Autocomplete

Autocomplete

Signature help

Signature Help

Hover

Hover

Go-to-definition, find all references

Find all references

Document symbols

Document symbols

Global symbols

Global symbols

Authors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].