Skip to content

Commit d9b50f2

Browse files
committed
Merge branch 'main' of github.com:fwcd/kotlin-language-server into dependency-caching
2 parents 18ff7e8 + 2abfe06 commit d9b50f2

File tree

87 files changed

+3015
-529
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+3015
-529
lines changed

.github/workflows/build.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
name: Build
2-
on: [ push, pull_request ]
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
39

410
jobs:
511
build:
6-
runs-on: ubuntu-latest
12+
runs-on: ${{ matrix.os }}
713
strategy:
814
matrix:
15+
os: [ubuntu-latest, macos-latest, windows-latest]
916
java: [ '11', '17' ]
1017
steps:
1118
- uses: actions/checkout@v3
@@ -14,6 +21,9 @@ jobs:
1421
with:
1522
distribution: 'temurin'
1623
java-version: ${{ matrix.java }}
17-
- uses: gradle/gradle-build-action@v2
24+
- name: Setup Gradle
25+
uses: gradle/gradle-build-action@v2
1826
- name: Build
19-
run: ./gradlew :server:build :shared:build
27+
run: ./gradlew :server:build :shared:build -PjavaVersion=${{ matrix.java }}
28+
- name: Detekt
29+
run: ./gradlew detekt

.github/workflows/deploy.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ jobs:
1515
with:
1616
distribution: 'temurin'
1717
java-version: '11'
18-
- uses: gradle/gradle-build-action@v2
18+
- name: Setup Gradle
19+
uses: gradle/gradle-build-action@v2
1920
- name: Build distribution
2021
run: ./gradlew :server:distZip :grammars:distZip
2122
- name: Create release

.vscode/launch.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@
3030
"request": "attach",
3131
"hostName": "localhost",
3232
"port": 5005
33+
},
34+
{
35+
"type": "extensionHost",
36+
"name": "Run Grammar Dev Extension",
37+
"request": "launch",
38+
"args": [
39+
"--disable-extension=fwcd.kotlin",
40+
"--extensionDevelopmentPath=${workspaceFolder}/grammars/vscode-grammar-dev"
41+
]
3342
}
3443
]
3544
}

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ All notable changes to the language server will be documented in this file.
33

44
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
55

6+
## [1.3.1]
7+
- Add support for run/debug code lenses
8+
- Add definition lookup support for JDT symbols
9+
- Add quick fix for implementing abstract functions
10+
- Add experimental JDT.LS integration
11+
612
## [1.3.0]
713
- Bump to Kotlin 1.6
814
- Support JDK 17

EDITORS.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,27 @@ See [atom-ide-kotlin](https://github.com/fwcd/atom-ide-kotlin).
99
## Emacs
1010
_using [`lsp-mode`](https://github.com/emacs-lsp/lsp-mode)_
1111

12-
Add the language server executable to your `PATH`.
12+
There are two ways of setting up the language server with `lsp-mode`:
13+
- Add the language server executable to your `PATH`. This is useful for development and for always using the latest version from the `main`-branch.
14+
- Let `lsp-mode` download the server for you (`kotlin-ls`). This will use [the latest release](https://github.com/fwcd/kotlin-language-server/releases/latest).
15+
16+
17+
### Run/debug code lenses
18+
If you use [dap-mode](https://github.com/emacs-lsp/dap-mode), you can set `(setq lsp-kotlin-debug-adapter-enabled t)` to enable the debug adapter. You will need to have [Kotlin Debug Adapter](https://github.com/fwcd/kotlin-debug-adapter) on your system. A simple configuration of `dap-mode` for Kotlin may look like:
19+
```emacs-lisp
20+
(require 'dap-kotlin)
21+
(setq lsp-kotlin-debug-adapter-enabled t)
22+
;; replace the path below to the path to your Kotlin Debug Adapter
23+
(setq lsp-kotlin-debug-adapter-path "/path/to/kotlin-debug-adapter")
24+
```
25+
26+
Then you can activate `lsp-kotlin-lens-mode` to see the Run/Debug code lenses at your main-functions.
27+
28+
29+
### Override members (e.g, toString and equals)
30+
The language server provides a custom protocol extension for finding overridable members of a class (variables and methods). `lsp-mode` provides a function that uses this called `lsp-kotlin-implement-member`. You can run it while hovering a class name, and you will get a menu with all available overridable members. (protip: Bind this function to a key!). If you have [Helm](https://github.com/emacs-helm/helm) or [Ivy](https://github.com/abo-abo/swiper) installed, one of them will be utilized.
31+
32+
1333

1434
## Vim
1535
_using [`LanguageClient-neovim`](https://github.com/autozimu/LanguageClient-neovim)_
@@ -42,6 +62,25 @@ Add the following to your coc-settings.json file:
4262
Note that you may need to substitute `kotlin-language-server` with `kotlin-language-server.bat` on Windows.\
4363
You should also note, that you need a syntax highlighter like [udalov/kotlin-vim](https://github.com/udalov/kotlin-vim) or [sheerun/vim-polyglot](https://github.com/sheerun/vim-polyglot) to work well with coc.
4464

65+
## Neovim
66+
67+
Using Neovim's [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig), register
68+
the language server using the following.
69+
70+
```lua
71+
require'lspconfig'.kotlin_language_server.setup{}
72+
```
73+
74+
If desired, you can also pass in your own defined options to the setup function.
75+
76+
```lua
77+
require'lspconfig'.kotlin_language_server.setup{
78+
on_attach = on_attach,
79+
flags = lsp_flags,
80+
capabilities = capabilities,
81+
}
82+
```
83+
4584
## Other Editors
4685
Install a [Language Server Protocol client](https://microsoft.github.io/language-server-protocol/implementors/tools/) for your tool. Then invoke the language server executable in a client-specific way.
4786

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@ Any editor conforming to LSP is supported, including [VSCode](https://github.com
1515

1616
* See [BUILDING.md](BUILDING.md) for build instructions
1717
* See [Editor Integration](EDITORS.md) for editor-specific instructions
18+
* See [Troubleshooting](TROUBLESHOOTING.md) for tips on troubleshooting errors
1819
* See [Roadmap](https://github.com/fwcd/kotlin-language-server/projects/1) for features, planned additions, bugfixes and changes
1920
* See [Kotlin Quick Start](https://github.com/fwcd/kotlin-quick-start) for a sample project
2021
* See [Kotlin Debug Adapter](https://github.com/fwcd/kotlin-debug-adapter) for debugging support on JVM
2122
* See [tree-sitter-kotlin](https://github.com/fwcd/tree-sitter-kotlin) for an experimental [Tree-Sitter](https://tree-sitter.github.io/tree-sitter/) grammar
2223

24+
## Packaging
25+
26+
[![Packaging status](https://repology.org/badge/vertical-allrepos/kotlin-language-server.svg)](https://repology.org/project/kotlin-language-server/versions)
27+
2328
## This repository needs your help!
2429

2530
[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.
@@ -103,6 +108,7 @@ The Kotlin language server supports some non-standard requests through LSP. See
103108
### Global symbols
104109
![Global symbols](images/GlobalSymbols.png)
105110

111+
106112
## Authors
107113
* [georgewfraser](https://github.com/georgewfraser)
108114
* [fwcd](https://github.com/fwcd)

TROUBLESHOOTING.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,13 @@ error TS6059: File '.../KotlinLanguageServer/bin/vscode-extension-src/...' is no
3232
```
3333

3434
delete the `bin` folder in the repository directory.
35+
36+
37+
## java.lang.OutOfMemoryError when running language server
38+
The language server is currently a memory hog, mostly due to its use of an in-memory database for symbols (ALL symbols from dependencies etc.!). This makes it not work well for machines with little RAM. If you experience out of memory issues, and still have lots of RAM, the default heap space might be too low. You might want to try tweaking the maximum heap space setting by setting `-Xmx8g` (which sets the heap size to 8GB. Change the number to your needs). This can be done by setting the `JAVA_OPTS` environment variable.
39+
40+
41+
In [the VSCode extension](https://github.com/fwcd/vscode-kotlin), this is in the extension settings in the setting `Kotlin > Java: Opts`.
42+
43+
44+
If you use Emacs, you can try the `setenv` function to set environment variables. Example: `(setenv "JAVA_OPTS" "-Xmx8g")`.

build.gradle

Lines changed: 0 additions & 39 deletions
This file was deleted.

build.gradle.kts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import io.gitlab.arturbosch.detekt.Detekt
2+
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
3+
4+
plugins {
5+
kotlin("jvm")
6+
`maven-publish`
7+
id("io.gitlab.arturbosch.detekt") version "1.22.0"
8+
}
9+
10+
repositories {
11+
mavenCentral()
12+
}
13+
14+
15+
detekt {
16+
allRules = false // activate all available (even unstable) rules.
17+
buildUponDefaultConfig = true // preconfigure defaults
18+
parallel = true
19+
config = files("$rootDir/detekt.yml")
20+
baseline = file("$rootDir/detekt_baseline.xml")
21+
source = files(projectDir)
22+
}
23+
24+
// Registers a baseline for Detekt.
25+
//
26+
// The way it works is that you set create "baseline" for Detekt
27+
// by running this task. It will then creatae a detekt-baseline.xml which
28+
// contains a list of current issues found within the project.
29+
// Then every time you run the "detekt" task it will only report errors
30+
// that are not in the baseline config.
31+
//
32+
// We should routinely run this task and commit the baseline file as we
33+
// fix detekt issues so that we can prevent regressions.
34+
tasks.register<DetektCreateBaselineTask>("createDetektBaseline") {
35+
description = "Overrides current baseline."
36+
buildUponDefaultConfig.set(true)
37+
ignoreFailures.set(true)
38+
parallel.set(true)
39+
setSource(files(projectDir))
40+
config.setFrom(files("$rootDir/detekt.yml"))
41+
baseline.set(file("$rootDir/detekt_baseline.xml"))
42+
include("**/*.kt")
43+
include("**/*.kts")
44+
exclude("shared/build/**/*.*")
45+
exclude("server/build/**/*.*")
46+
exclude("gradle/plugins/build/**/*.*")
47+
}
48+
49+
tasks.withType<Detekt>().configureEach {
50+
jvmTarget = JavaVersion.VERSION_11.toString()
51+
reports {
52+
html.required.set(true)
53+
md.required.set(true)
54+
}
55+
}
56+
57+
tasks.check.get().dependsOn(tasks.detekt)

detekt.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
config:
2+
validation: true # verifies that this config file is valid
3+
warningsAsErrors: false

0 commit comments

Comments
 (0)