Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) Use LanguageServer.jl for better completions #413

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ version = pluginVersion

plugins {
java
id("org.jetbrains.intellij") version "0.4.8"
id("org.jetbrains.grammarkit") version "2019.1"
kotlin("jvm") version "1.3.30"
id("org.jetbrains.intellij") version "0.4.9"
id("org.jetbrains.grammarkit") version "2019.2"
kotlin("jvm") version "1.3.41"
}

fun fromToolbox(path: String) = file(path).listFiles().orEmpty().filter { it.isDirectory }.maxBy {
Expand Down Expand Up @@ -60,7 +60,7 @@ allprojects {
// pycharmPath?.absolutePath?.let { alternativeIdePath = it }
// }
// }
version = "2019.1"
version = "2019.2"
setMarkdownDependency()
}
}
Expand Down Expand Up @@ -93,13 +93,17 @@ sourceSets {
}
}

repositories { mavenCentral() }
repositories {
mavenCentral()
maven { setUrl("https://jitpack.io") }
}

dependencies {
compile(kotlin("stdlib-jdk8"))
compile(group = "org.eclipse.mylyn.github", name = "org.eclipse.egit.github.core", version = "2.1.5") {
exclude(module = "gson")
}
compile(group = "com.github.ballerina-platform", name="lsp4intellij", version = "0.92.1")
testCompile(kotlin(module = "test-junit"))
testCompile(group = "junit", name = "junit", version = "4.12")
}
Expand All @@ -117,8 +121,8 @@ task("isCI") {
}

// Don't specify type explicitly. Will be incorrectly recognized
val parserRoot = Paths.get("org", "ice1000", "julia", "lang")!!
val lexerRoot = Paths.get("gen", "org", "ice1000", "julia", "lang")!!
val parserRoot = Paths.get("org", "ice1000", "julia", "lang")
val lexerRoot = Paths.get("gen", "org", "ice1000", "julia", "lang")
fun path(more: Iterable<*>) = more.joinToString(File.separator)
fun bnf(name: String) = Paths.get("grammar", "$name-grammar.bnf").toString()
fun flex(name: String) = Paths.get("grammar", "$name-lexer.flex").toString()
Expand Down Expand Up @@ -199,10 +203,10 @@ tasks.withType<KotlinCompile> {
tasks.withType<Delete> { dependsOn(cleanGenerated) }

fun setMarkdownDependency() {
repositories {
maven("https://dl.bintray.com/jetbrains/markdown/")
}
dependencies {
compile("org.jetbrains", "markdown", "0.1.31")
}
repositories {
maven("https://dl.bintray.com/jetbrains/markdown/")
}
dependencies {
compile("org.jetbrains", "markdown", "0.1.31")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you eliminate these whitespaces changes?

}
23 changes: 23 additions & 0 deletions res/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
<xdebugger.breakpointType implementation="org.ice1000.julia.lang.execution.JuliaLineBreakpointType"/>
<consoleFilterProvider implementation="org.ice1000.julia.lang.execution.JuliaConsoleFilterProvider"/>
<console.folding implementation="org.ice1000.julia.lang.execution.JuliaConsoleFolding"/>
<!--
<moduleConfigurationEditorProvider implementation="org.ice1000.julia.lang.module.JuliaModuleConfigEditor"/>
-->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

<directoryProjectGenerator implementation="org.ice1000.julia.lang.module.JuliaProjectGenerator"/>
<iconProvider implementation="org.ice1000.julia.lang.editing.JuliaIconProvider"/>
<errorHandler implementation="org.ice1000.julia.lang.error.GitHubErrorReporter"/>
Expand All @@ -54,12 +56,28 @@
<stubIndex implementation="org.ice1000.julia.lang.psi.JuliaAbstractTypeDeclarationIndex"/>
<stubIndex implementation="org.ice1000.julia.lang.psi.JuliaTypeDeclarationIndex"/>
<stubIndex implementation="org.ice1000.julia.lang.psi.JuliaModuleDeclarationIndex"/>
<localInspection displayName="LSP"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the display name be changed to "language server" or "julia language server"?

shortName="LSP"
enabledByDefault="true"
implementationClass="org.wso2.lsp4intellij.contributors.inspection.DummyLSPInspection"/>
<gotoSymbolContributor implementation="org.wso2.lsp4intellij.contributors.symbol.LSPSymbolContributor"
id="LSPSymbolContributor"/>
<renameHandler implementation="org.wso2.lsp4intellij.contributors.rename.LSPRenameHandler"
id="LSPRenameHandler" order="first"/>
<renamePsiElementProcessor implementation="org.wso2.lsp4intellij.contributors.rename.LSPRenameProcessor"
id="LSPRenameProcessor" order="first"/>
<preloadingActivity implementation="org.ice1000.julia.lang.preload.JuliaPreloadingActivity"
id="org.ice1000.julia.lang.preload.JuliaPreloadingActivity" />
<lang.refactoringSupport
language="Julia"
implementationClass="org.ice1000.julia.lang.editing.JuliaRefactoringSupportProvider"/>
<completion.contributor implementationClass="org.wso2.lsp4intellij.contributors.LSPCompletionContributor"
id="LSPCompletionContributor" language="Julia"/>
<!--
<completion.contributor
language="Julia"
implementationClass="org.ice1000.julia.lang.editing.JuliaBasicCompletionContributor"/>
-->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can keep this, no?

<completion.contributor
language="DocumentFormat"
implementationClass="org.ice1000.julia.lang.docfmt.DocfmtCompletionContributor"/>
Expand Down Expand Up @@ -250,4 +268,9 @@
<keyboard-shortcut first-keystroke="shift ENTER" keymap="$default"/>
</action>
</actions>
<application-components>
<component>
<implementation-class>org.wso2.lsp4intellij.IntellijLanguageClient</implementation-class>
</component>
</application-components>
</idea-plugin>
7 changes: 7 additions & 0 deletions res/META-INF/startlanguageserver.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using LanguageServer, Sockets, SymbolServer, Pkg

const depot = Pkg.depots1()
server = LanguageServer.LanguageServerInstance(stdin, stdout, false, string(depot, ""/environments/v1.1"), depot, Dict())
server.runlinter = true
server.debug_mode = true
run(server)
2 changes: 1 addition & 1 deletion src/org/ice1000/julia/lang/execution/julia-run-config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class JuliaRunConfigurationProducer : RunConfigurationProducer<JuliaRunConfigura
configuration.targetFile == context.dataContext.getData(CommonDataKeys.VIRTUAL_FILE)?.path

override fun setupConfigurationFromContext(
configuration: JuliaRunConfiguration, context: ConfigurationContext, ref: Ref<PsiElement>?): Boolean {
configuration: JuliaRunConfiguration, context: ConfigurationContext, ref: Ref<PsiElement>): Boolean {
val file = context.dataContext.getData(CommonDataKeys.VIRTUAL_FILE)
if (file?.fileType != JuliaFileType) return false
configuration.targetFile = file.path
Expand Down
5 changes: 4 additions & 1 deletion src/org/ice1000/julia/lang/module/julia-modules.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import icons.JuliaIcons
import org.ice1000.julia.lang.*
import org.ice1000.julia.lang.action.errorNotification
import org.ice1000.julia.lang.module.ui.JuliaSetupSdkWizardStepImpl
import javax.swing.JComponent

class JuliaModuleBuilder : ModuleBuilder(), ModuleBuilderListener {
init {
Expand Down Expand Up @@ -78,6 +79,8 @@ class JuliaModuleType : ModuleType<JuliaModuleBuilder>(JULIA_MODULE_ID) {
* @author: zxj5470
* @date: 2018/1/29
*/

/*
class JuliaModuleConfigEditor : ModuleConfigurationEditorProvider {
override fun createEditors(state: ModuleConfigurationState): Array<ModuleConfigurationEditor> {
val module = state.rootModel?.module ?: return emptyArray()
Expand All @@ -95,4 +98,4 @@ class JuliaCompileOutputEditor(state: ModuleConfigurationState) : ModuleElements
override fun getDisplayName() = "Paths"
override fun getHelpTopic() = editor.helpTopic
}

*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

14 changes: 14 additions & 0 deletions src/org/ice1000/julia/lang/preload/julia-preload.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.ice1000.julia.lang.preload

import com.intellij.openapi.application.PreloadingActivity
import com.intellij.openapi.progress.ProgressIndicator
import org.wso2.lsp4intellij.IntellijLanguageClient
import org.wso2.lsp4intellij.client.languageserver.serverdefinition.RawCommandServerDefinition

class JuliaPreloadingActivity: PreloadingActivity() {
override fun preload(indicator: ProgressIndicator) {
indicator.isIndeterminate = true
IntellijLanguageClient.addServerDefinition(
RawCommandServerDefinition("jl", arrayOf("julia", "/home/quangio/IdeaProjects/julia-plugin-test/lsp.jl")))
}
}