Skip to content

Commit e6d7e89

Browse files
committed
Merge branch 'atom-tree-sitter'
2 parents 943c8ea + 5191179 commit e6d7e89

File tree

13 files changed

+212
-17
lines changed

13 files changed

+212
-17
lines changed

BUILDING.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,14 @@ Run `./gradlew :editors:vscode:packageExtension` from the repository's top-level
3535
## Atom plugin
3636

3737
### Development/Running
38-
To install the Atom plugin, run `./gradlew :editors:atom:link`.
38+
To build and link the Atom plugin into your local packages folder, run:
39+
40+
>`./gradlew :editors:atom:apmLink`
3941
4042
That's it! To use the extension, just reload your Atom window.
4143

44+
> Note that you might have to manually run `apm rebuild` and `apm link` in `editors/atom` if `apm` could not be found on your `PATH` or you are using Windows.
45+
4246
## Gradle Tasks
4347
This paragraph assumes that you are familiar with Gradle's [task system](https://docs.gradle.org/current/userguide/build_lifecycle.html). In short: Every task describes an atomic piece of work and may depend on other tasks. Task dependencies will automatically be executed. The following subsections describe the available tasks for each module of this project.
4448

@@ -72,4 +76,5 @@ This paragraph assumes that you are familiar with Gradle's [task system](https:/
7276
| ---- | ------- | ----------- |
7377
| Prepare | `./gradlew :editors:atom:prepare` | Copies the packaged language server into the extension's directory. |
7478
| Install | `./gradlew :editors:atom:install` | Installs the npm dependencies of the extension. |
75-
| Link | `./gradlew :editors:atom:link` | Links the extension into your local Atom package directory. |
79+
| APM Rebuild | `./gradlew :editors:atom:apmRebuild` | Rebuilds the extension's native modules using Atom's Node version. |
80+
| APM Link | `./gradlew :editors:atom:apmLink` | Links the extension into your local Atom package directory. |

TROUBLESHOOTING.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Troubleshooting
22

3-
## The tests fail with `java.lang.NoSuchMethodError`
3+
## Atom: Failed to load `ide-kotlin` package grammar
4+
5+
### A dynamic link library (DLL) initialization routine failed / The module was compiled against a different Node.js version using `NODE_MODULE_VERSION` X, but requires `NODE_MODULE_VERSION` Y
6+
7+
Run `./gradlew :editors:atom:apmRebuild` (or inside `editors/atom`: `apm rebuild`).
8+
9+
See also [this issue](https://github.com/tree-sitter/tree-sitter/issues/377) and [the Electron docs](https://electronjs.org/docs/tutorial/using-native-node-modules) on how to rebuild.
10+
11+
## Language Server: The tests fail with `java.lang.NoSuchMethodError`
412
* After updating the Kotlin version, there may be multiple copies of the compiler plugin in `lib-kotlin`, for example:
513

614
```
@@ -16,7 +24,7 @@ lib-kotlin
1624
* If that still does not work, delete the entire `lib-kotlin` folder
1725
* Gradle will automatically re-download the necessary files once the project is built again
1826

19-
## Running `npm run compile` or `vsce package` fails
27+
## VSCode: Running `npm run compile` or `vsce package` fails
2028
If you get the error
2129

2230
```

editors/atom/build.gradle

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ plugins {
22
id 'com.github.node-gradle.node' version '2.0.0'
33
}
44

5-
/** Prepares the grammars for packaging. */
6-
task copyGrammars(type: Sync) {
5+
/** Prepares the TextMate grammar for packaging. */
6+
task copyTextMateGrammar(type: Copy) {
77
from "$rootDir/grammars/textmate/Kotlin.tmLanguage.json"
88
into file('grammars')
99
}
1010

11+
/** Prepares the Tree-Sitter grammar for packaging. */
12+
task copyTreeSitterGrammar(type: Copy) {
13+
from "$rootDir/grammars/tree-sitter/tree-sitter-kotlin.cson"
14+
into file('grammars')
15+
}
16+
1117
/** Prepares the language server binaries for packaging. */
1218
task copyLanguageServer(type: Sync) {
1319
dependsOn ':server:installDist'
@@ -16,20 +22,30 @@ task copyLanguageServer(type: Sync) {
1622
}
1723

1824
/** Prepares resources used by the extension. */
19-
task prepare { dependsOn copyGrammars, copyLanguageServer }
25+
task prepare { dependsOn copyTextMateGrammar, copyTreeSitterGrammar, copyLanguageServer }
2026

2127
npmInstall { dependsOn prepare }
2228

2329
task install { dependsOn npmInstall }
2430

2531
task build { dependsOn install }
2632

33+
/**
34+
* Rebuilds the extension's native modules (the
35+
* Tree-Sitter parser) using Atom's node version.
36+
*/
37+
task apmRebuild(type: Exec) {
38+
dependsOn install
39+
workingDir projectDir
40+
commandLine 'apm', 'rebuild'
41+
}
42+
2743
/**
2844
* Links the extension into your local Atom
2945
* package directory.
3046
*/
31-
task link(type: Exec) {
32-
dependsOn install
47+
task apmLink(type: Exec) {
48+
dependsOn apmRebuild
3349
workingDir projectDir
3450
commandLine 'apm', 'link'
3551
}

editors/atom/lib/main.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ class KotlinLanguageClient extends AutoLanguageClient {
1515
getServerName() { return "KotlinLanguageServer"; }
1616

1717
startServerProcess(projectPath) {
18-
// TODO: Windows-support
19-
const serverPath = path.join(__dirname, "..", "install", "bin", "kotlin-language-server");
18+
const serverPath = path.join(__dirname, "..", "install", "bin", this.correctScriptName("kotlin-language-server"));
2019
const process = cp.spawn(serverPath);
2120
process.on("close", () => {
2221
if (!process.killed) {
@@ -28,6 +27,10 @@ class KotlinLanguageClient extends AutoLanguageClient {
2827
return process;
2928
}
3029

30+
correctScriptName(name) {
31+
return name + ((process.platform === "win32") ? ".bat" : "");
32+
}
33+
3134
preInitialization(connection) {
3235
this.updateStatusMessage("Activating KLS...");
3336
}

editors/atom/package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

editors/atom/package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,21 @@
44
"version": "0.2.4",
55
"description": "Smart code completion, linting and more for Kotlin",
66
"keywords": [],
7-
"repository": "https://github.com/fwcd/KotlinLanguageServer",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/fwcd/kotlin-language-server.git"
10+
},
811
"license": "MIT",
912
"engines": {
10-
"atom": ">=1.0.0 <2.0.0"
13+
"atom": "*",
14+
"node": "*"
1115
},
1216
"enhancedScopes": [
1317
"source.kotlin"
1418
],
1519
"dependencies": {
16-
"atom-languageclient": "^0.9.9"
20+
"atom-languageclient": "^0.9.9",
21+
"tree-sitter-kotlin": "^0.2.3"
1722
},
1823
"consumedServices": {
1924
"linter-indie": {

editors/vscode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"icon": "resources/Icon128.png",
66
"repository": {
77
"type": "git",
8-
"url": "https://github.com/fwcd/KotlinLanguageServer.git"
8+
"url": "https://github.com/fwcd/kotlin-language-server.git"
99
},
1010
"version": "0.2.4",
1111
"preview": true,

grammars/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Grammars
2+
Grammar files that are used by the editor extensions.

grammars/textmate/Kotlin.tmLanguage.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@
232232
]
233233
},
234234
"prefix-modifiers": {
235-
"match": "\\b(abstract|final|enum|open|annotation|sealed|data|override|final|abstract|lateinit|private|protected|public|internal|inner|companion|noinline|crossinline|vararg|reified|tailrec|operator|infix|inline|external|const|suspend)\\b",
235+
"match": "\\b(abstract|final|enum|open|annotation|sealed|data|override|final|lateinit|private|protected|public|internal|inner|companion|noinline|crossinline|vararg|reified|tailrec|operator|infix|inline|external|const|suspend)\\b",
236236
"name": "storage.modifier.other.kotlin"
237237
},
238238
"postfix-modifiers": {

grammars/textmate/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# TextMate-Grammar
2+
A Kotlin grammar that is shared between the VSCode- and the Atom-extension.

0 commit comments

Comments
 (0)