diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1a52ae8..df19229 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,10 @@
## [Unreleased]
+### Added
+
+- Support for the [Pact 5 Language Server (LSP)](https://github.com/kadena-io/pact-5)
+
## [0.4.0] - 2024-05-13
### Added
diff --git a/README.md b/README.md
index 482ca2c..c6785b7 100644
--- a/README.md
+++ b/README.md
@@ -123,7 +123,7 @@ Configuration is required to enable functionality from the Pact Language Server:
1. Navigate to Settings/Preferences
2. Select Languages & Frameworks > Pact
-3. Specify your Pact and Pact Language Server paths
+3. Specify your Pact Compiler and Pact Language Server paths
#### Homebrew
diff --git a/gradle.properties b/gradle.properties
index dbef16f..219a4bf 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -4,7 +4,7 @@ pluginGroup = io.kadena.pact
pluginName = Pact
pluginRepositoryUrl = https://github.com/lukeribchester/pact-intellij
# SemVer format -> https://semver.org
-pluginVersion = 0.4.0
+pluginVersion = 0.5.0
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 232
diff --git a/src/main/kotlin/io/kadena/pact/ide/runner/PactRunConfigurationOptions.kt b/src/main/kotlin/io/kadena/pact/ide/runner/PactRunConfigurationOptions.kt
index 32e0d6e..8ad7de4 100644
--- a/src/main/kotlin/io/kadena/pact/ide/runner/PactRunConfigurationOptions.kt
+++ b/src/main/kotlin/io/kadena/pact/ide/runner/PactRunConfigurationOptions.kt
@@ -2,14 +2,14 @@ package io.kadena.pact.ide.runner
import com.intellij.execution.configurations.RunConfigurationOptions
import com.intellij.openapi.components.StoredProperty
-import io.kadena.pact.ide.settings.AppSettingsState
+import io.kadena.pact.ide.settings.PactSettingsState
class PactRunConfigurationOptions : RunConfigurationOptions() {
- private val settings: AppSettingsState = AppSettingsState.instance
+ private val settings: PactSettingsState = PactSettingsState.instance
private val _compilerPath: StoredProperty =
- string(settings.pactPath.takeIf { it.isNotBlank() } ?: "")
+ string(settings.compilerPath.takeIf { it.isNotBlank() } ?: "")
.provideDelegate(this, "compilerPath")
private val _modulePath: StoredProperty =
@@ -17,13 +17,13 @@ class PactRunConfigurationOptions : RunConfigurationOptions() {
.provideDelegate(this, "modulePath")
var compilerPath: String
- get() = _compilerPath.getValue(this).toString()
+ get() = _compilerPath.getValue(this).takeIf { !it.equals(null) } ?: ""
set(newCompilerPath) {
_compilerPath.setValue(this, newCompilerPath)
}
var modulePath: String
- get() = _modulePath.getValue(this).toString()
+ get() = _modulePath.getValue(this).takeIf { !it.equals(null) } ?: ""
set(newModulePath) {
_modulePath.setValue(this, newModulePath)
}
diff --git a/src/main/kotlin/io/kadena/pact/ide/runner/PactSettingsEditor.kt b/src/main/kotlin/io/kadena/pact/ide/runner/PactSettingsEditor.kt
index ec9e851..f6bc1cb 100644
--- a/src/main/kotlin/io/kadena/pact/ide/runner/PactSettingsEditor.kt
+++ b/src/main/kotlin/io/kadena/pact/ide/runner/PactSettingsEditor.kt
@@ -1,44 +1,66 @@
package io.kadena.pact.ide.runner
-import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
+import com.intellij.openapi.fileChooser.FileChooserDescriptor
import com.intellij.openapi.options.SettingsEditor
+import com.intellij.openapi.ui.ComboBox
import com.intellij.openapi.ui.TextFieldWithBrowseButton
-import com.intellij.util.ui.FormBuilder
+import com.intellij.ui.dsl.builder.Align
+import com.intellij.ui.dsl.builder.RowLayout
+import io.kadena.pact.ide.settings.createComboBox
import org.jetbrains.annotations.NotNull
import javax.swing.JComponent
import javax.swing.JPanel
+import com.intellij.ui.dsl.builder.panel as dslPanel
class PactSettingsEditor : SettingsEditor() {
private val panel: JPanel
- private val compilerPathField = TextFieldWithBrowseButton()
- private val modulePathField = TextFieldWithBrowseButton()
+ private val compilerPathField: ComboBox = createComboBox(
+ "Select a Pact Compiler", "Choose an executable file"
+ )
- init {
- compilerPathField.addBrowseFolderListener(
- "Select a Pact Compiler", null, null,
- FileChooserDescriptorFactory.createSingleFileDescriptor()
+ private val modulePathField = TextFieldWithBrowseButton().apply {
+ addBrowseFolderListener(
+ "Select a Pact Module",
+ "Choose a Pact file",
+ null,
+ FileChooserDescriptor(
+ true,
+ false,
+ false,
+ false,
+ false,
+ false
+ )
)
+ }
- modulePathField.addBrowseFolderListener(
- "Select a Pact Module", null, null,
- FileChooserDescriptorFactory.createSingleFileDescriptor()
- )
+ init {
+ panel = dslPanel {
+ // Compiler path
+ row("Pact compiler:") {
+ cell(compilerPathField)
+ .align(Align.FILL)
+ .resizableColumn()
+ }.layout(RowLayout.LABEL_ALIGNED)
- panel = FormBuilder.createFormBuilder()
- .addLabeledComponent("Pact compiler:", compilerPathField)
- .addLabeledComponent("Pact module:", modulePathField)
- .panel
+ // Module path
+ row("Pact module:") {
+ cell(modulePathField)
+ .align(Align.FILL)
+ .resizableColumn()
+ }.layout(RowLayout.LABEL_ALIGNED)
+ }
}
override fun resetEditorFrom(pactRunConfiguration: PactRunConfiguration) {
- compilerPathField.text = pactRunConfiguration.compilerPath
+ compilerPathField.selectedItem = pactRunConfiguration.compilerPath
modulePathField.text = pactRunConfiguration.modulePath
}
override fun applyEditorTo(@NotNull pactRunConfiguration: PactRunConfiguration) {
- pactRunConfiguration.compilerPath = compilerPathField.text
+ pactRunConfiguration.compilerPath = compilerPathField.selectedItem?.toString() ?: ""
pactRunConfiguration.modulePath = modulePathField.text
}
diff --git a/src/main/kotlin/io/kadena/pact/ide/settings/AppSettingsComponent.kt b/src/main/kotlin/io/kadena/pact/ide/settings/AppSettingsComponent.kt
deleted file mode 100644
index b6ef964..0000000
--- a/src/main/kotlin/io/kadena/pact/ide/settings/AppSettingsComponent.kt
+++ /dev/null
@@ -1,148 +0,0 @@
-package io.kadena.pact.ide.settings
-
-import com.intellij.openapi.fileChooser.FileChooser
-import com.intellij.openapi.fileChooser.FileChooserDescriptor
-import com.intellij.openapi.ui.ComboBox
-import com.intellij.openapi.vfs.VirtualFile
-import com.intellij.ui.components.JBLabel
-import com.intellij.ui.components.JBPanel
-import com.intellij.ui.util.maximumWidth
-import com.intellij.ui.util.minimumWidth
-import com.intellij.ui.util.preferredWidth
-import com.intellij.util.ui.FormBuilder
-import org.jetbrains.annotations.NotNull
-import java.awt.Dimension
-import javax.swing.Box
-import javax.swing.BoxLayout
-import javax.swing.JButton
-import javax.swing.JComponent
-import javax.swing.JPanel
-
-
-/**
- * Supports creating and managing a [JPanel] for the Settings Dialog.
- */
-class AppSettingsComponent {
- val panel: JPanel
-
- private val pactPathLabel = JBLabel("Pact:")
- private val pactPathField = ComboBox()
- private val pactPathBrowseButton = JButton("...")
-
- private val pactLanguageServerPathLabel = JBLabel("Language Server (LSP):")
- private val pactLanguageServerPathField = ComboBox()
- private val pactLanguageServerPathBrowseButton = JButton("...")
-
- init {
- panel = FormBuilder.createFormBuilder()
- .addComponent(pactPathPanel())
- .addComponent(pactLanguageServerPathPanel())
- .addComponentFillVertically(JPanel(), 0)
- .panel
- }
-
- val preferredFocusedComponent: JComponent
- get() = pactPathField
-
- @get:NotNull
- var pactPath: String?
- get() = pactPathField.selectedItem?.toString()
- set(newPath) {
- pactPathField.selectedItem = newPath
- }
-
- @get:NotNull
- var pactLanguageServerPath: String?
- get() = pactLanguageServerPathField.selectedItem?.toString()
- set(newPath) {
- pactLanguageServerPathField.selectedItem = newPath
- }
-
- private fun pactPathPanel(): JBPanel> {
- pactPathField.apply {
- addItem("/path/to/pact")
- isEditable = true
- preferredWidth = 300
- }
- pactPathBrowseButton.addActionListener {
- onBrowseForPactPath(
- "Select a Pact Compiler",
- "Choose an executable file",
- pactPathField
- )
- }
- pactPathBrowseButton.apply {
- preferredWidth = 30
- minimumWidth = 30
- maximumWidth = 30
- }
-
- return JBPanel>().apply {
- // Align the components horizontally
- layout = BoxLayout(this, BoxLayout.X_AXIS)
-
- val gap = Box.createRigidArea(Dimension(10, 0))
-
- add(pactPathLabel)
- add(gap)
- add(pactPathField)
- add(pactPathBrowseButton)
- }
- }
-
- private fun pactLanguageServerPathPanel(): JBPanel> {
- pactLanguageServerPathField.apply {
- addItem("/path/to/pact-lsp")
- isEditable = true
- preferredWidth = 300
- }
- pactLanguageServerPathBrowseButton.addActionListener {
- onBrowseForPactPath(
- "Select a Pact Language Server (LSP)",
- "Choose an executable file",
- pactLanguageServerPathField
- )
- }
- pactLanguageServerPathBrowseButton.apply {
- preferredWidth = 30
- minimumWidth = 30
- maximumWidth = 30
- }
-
- return JBPanel>().apply {
- // Align the components horizontally
- layout = BoxLayout(this, BoxLayout.X_AXIS)
-
- val gap = Box.createRigidArea(Dimension(10, 0))
-
- add(pactLanguageServerPathLabel)
- add(gap)
- add(pactLanguageServerPathField)
- add(pactLanguageServerPathBrowseButton)
- }
- }
-
- private fun onBrowseForPactPath(title: String, description: String, field: ComboBox) {
- // Configure the file browser window
- val fileChooserDescriptor = FileChooserDescriptor(
- true,
- true,
- false,
- false,
- false,
- false
- )
- .withTitle(title)
- .withDescription(description)
-
- // Open the file browser window
- val file: VirtualFile? = FileChooser.chooseFile(fileChooserDescriptor, null, null)
- file?.let {
- val path = it.path
-
- // Add the path to the ComboBox and select it
- field.addItem(path)
- field.selectedItem = path
- }
- }
-}
diff --git a/src/main/kotlin/io/kadena/pact/ide/settings/AppSettingsConfigurable.kt b/src/main/kotlin/io/kadena/pact/ide/settings/AppSettingsConfigurable.kt
deleted file mode 100644
index ba8ab9e..0000000
--- a/src/main/kotlin/io/kadena/pact/ide/settings/AppSettingsConfigurable.kt
+++ /dev/null
@@ -1,51 +0,0 @@
-package io.kadena.pact.ide.settings
-
-import com.intellij.openapi.options.Configurable
-import org.jetbrains.annotations.Nullable
-import javax.swing.JComponent
-
-
-/**
- * Provides controller functionality for application settings.
- */
-internal class AppSettingsConfigurable : Configurable {
- private var appSettingsComponent: AppSettingsComponent? = null
-
- override fun getDisplayName(): String {
- return "Pact"
- }
-
- fun preferredFocusedComponent(): JComponent {
- return appSettingsComponent!!.preferredFocusedComponent
- }
-
- @Nullable
- override fun createComponent(): JComponent {
- appSettingsComponent = AppSettingsComponent()
- return appSettingsComponent!!.panel
- }
-
- override fun isModified(): Boolean {
- val settings: AppSettingsState = AppSettingsState.instance
- var modified: Boolean = !appSettingsComponent?.pactPath.equals(settings.pactPath)
- modified = modified or (!appSettingsComponent?.pactLanguageServerPath.equals(settings.pactLanguageServerPath))
- return modified
- }
-
- override fun apply() {
- val settings: AppSettingsState = AppSettingsState.instance
- settings.pactPath = appSettingsComponent?.pactPath.toString()
- settings.pactLanguageServerPath = appSettingsComponent?.pactLanguageServerPath.toString()
- settings.notifyAppSettingsStateChanged(settings)
- }
-
- override fun reset() {
- val settings: AppSettingsState = AppSettingsState.instance
- appSettingsComponent?.pactPath = settings.pactPath
- appSettingsComponent?.pactLanguageServerPath = settings.pactLanguageServerPath
- }
-
- override fun disposeUIResources() {
- appSettingsComponent = null
- }
-}
diff --git a/src/main/kotlin/io/kadena/pact/ide/settings/PactSettingsComponent.kt b/src/main/kotlin/io/kadena/pact/ide/settings/PactSettingsComponent.kt
new file mode 100644
index 0000000..3f24080
--- /dev/null
+++ b/src/main/kotlin/io/kadena/pact/ide/settings/PactSettingsComponent.kt
@@ -0,0 +1,88 @@
+package io.kadena.pact.ide.settings
+
+import com.intellij.openapi.ui.ComboBox
+import com.intellij.ui.dsl.builder.Align
+import com.intellij.ui.dsl.builder.RowLayout
+import com.intellij.ui.dsl.builder.TopGap
+import org.jetbrains.annotations.NotNull
+import java.awt.Image
+import javax.swing.ImageIcon
+import javax.swing.JComponent
+import javax.swing.JLabel
+import javax.swing.JPanel
+import com.intellij.ui.dsl.builder.panel as dslPanel
+
+
+/**
+ * Supports creating and managing a [JPanel] for the Settings Dialog.
+ */
+class PactSettingsComponent {
+ val panel: JPanel
+
+ private val compilerPathField: ComboBox = createComboBox(
+ "Select a Pact Compiler", "Choose an executable file"
+ )
+
+ private val languageServerPathField: ComboBox = createComboBox(
+ "Select a Pact Language Server", "Choose an executable file"
+ )
+
+ init {
+ val logo = ImageIcon(javaClass.getResource("/icons/logo.png"))
+ .image.getScaledInstance(64, 64, Image.SCALE_SMOOTH)
+
+ panel = dslPanel {
+ // Compiler path
+ row("Pact compiler:") {
+ cell(compilerPathField)
+ .comment("Pact compiler versions 4.x.x and 5.x.x are supported".trimIndent())
+ .align(Align.FILL)
+ .resizableColumn()
+ }.layout(RowLayout.LABEL_ALIGNED)
+
+ // Language server path
+ row("Pact language server:") {
+ cell(languageServerPathField)
+ .comment("Specify a Pact 5 compiler path or a standalone Pact 4 language server path".trimIndent())
+ .align(Align.FILL)
+ .resizableColumn()
+ }.layout(RowLayout.LABEL_ALIGNED)
+
+ separator().topGap(TopGap.SMALL)
+
+ // Check for updates
+ row {
+ cell(JLabel(ImageIcon(logo)))
+ text(
+ """
+ Check for updates
+ Visit the
+ Pact 4
+ and
+ Pact 5
+ repositories
+
+ to stay up to date with the latest versions
+ """.trimIndent()
+ )
+ }
+ }
+ }
+
+ val preferredFocusedComponent: JComponent
+ get() = compilerPathField
+
+ @get:NotNull
+ var compilerPath: String?
+ get() = compilerPathField.selectedItem?.toString()
+ set(newPath) {
+ compilerPathField.selectedItem = newPath
+ }
+
+ @get:NotNull
+ var languageServerPath: String?
+ get() = languageServerPathField.selectedItem?.toString()
+ set(newPath) {
+ languageServerPathField.selectedItem = newPath
+ }
+}
diff --git a/src/main/kotlin/io/kadena/pact/ide/settings/PactSettingsConfigurable.kt b/src/main/kotlin/io/kadena/pact/ide/settings/PactSettingsConfigurable.kt
new file mode 100644
index 0000000..436fcff
--- /dev/null
+++ b/src/main/kotlin/io/kadena/pact/ide/settings/PactSettingsConfigurable.kt
@@ -0,0 +1,51 @@
+package io.kadena.pact.ide.settings
+
+import com.intellij.openapi.options.Configurable
+import org.jetbrains.annotations.Nullable
+import javax.swing.JComponent
+
+
+/**
+ * Provides controller functionality for application settings.
+ */
+internal class PactSettingsConfigurable : Configurable {
+ private var pactSettingsComponent: PactSettingsComponent? = null
+
+ override fun getDisplayName(): String {
+ return "Pact"
+ }
+
+ fun preferredFocusedComponent(): JComponent {
+ return pactSettingsComponent!!.preferredFocusedComponent
+ }
+
+ @Nullable
+ override fun createComponent(): JComponent {
+ pactSettingsComponent = PactSettingsComponent()
+ return pactSettingsComponent!!.panel
+ }
+
+ override fun isModified(): Boolean {
+ val settings: PactSettingsState = PactSettingsState.instance
+ var modified: Boolean = !pactSettingsComponent?.compilerPath.equals(settings.compilerPath)
+ modified = modified or (!pactSettingsComponent?.languageServerPath.equals(settings.languageServerPath))
+ return modified
+ }
+
+ override fun apply() {
+ val settings: PactSettingsState = PactSettingsState.instance
+ settings.compilerPath = pactSettingsComponent?.compilerPath.toString()
+ settings.languageServerPath = pactSettingsComponent?.languageServerPath.toString()
+ settings.notifyAppSettingsStateChanged(settings)
+ }
+
+ override fun reset() {
+ val settings: PactSettingsState = PactSettingsState.instance
+ pactSettingsComponent?.compilerPath = settings.compilerPath
+ pactSettingsComponent?.languageServerPath = settings.languageServerPath
+ }
+
+ override fun disposeUIResources() {
+ pactSettingsComponent = null
+ }
+}
diff --git a/src/main/kotlin/io/kadena/pact/ide/settings/AppSettingsState.kt b/src/main/kotlin/io/kadena/pact/ide/settings/PactSettingsState.kt
similarity index 69%
rename from src/main/kotlin/io/kadena/pact/ide/settings/AppSettingsState.kt
rename to src/main/kotlin/io/kadena/pact/ide/settings/PactSettingsState.kt
index 15efbdf..9a8753e 100644
--- a/src/main/kotlin/io/kadena/pact/ide/settings/AppSettingsState.kt
+++ b/src/main/kotlin/io/kadena/pact/ide/settings/PactSettingsState.kt
@@ -15,40 +15,40 @@ import org.jetbrains.annotations.Nullable
* these persistent application settings are stored.
*/
@State(
- name = "io.kadena.pact.ide.settings.AppSettingsState",
+ name = "io.kadena.pact.ide.settings.PactSettingsState",
storages = [Storage("PactPlugin.xml")]
)
-class AppSettingsState : PersistentStateComponent {
- var pactPath: String = ""
- var pactLanguageServerPath: String = ""
+class PactSettingsState : PersistentStateComponent {
+ var compilerPath: String = ""
+ var languageServerPath: String = ""
private val listeners = mutableSetOf()
@Nullable
- override fun getState(): AppSettingsState {
+ override fun getState(): PactSettingsState {
return this
}
- override fun loadState(@NotNull state: AppSettingsState) {
+ override fun loadState(@NotNull state: PactSettingsState) {
XmlSerializerUtil.copyBean(state, this)
}
companion object {
- val instance: AppSettingsState
- get() = ApplicationManager.getApplication().getService(AppSettingsState::class.java)
+ val instance: PactSettingsState
+ get() = ApplicationManager.getApplication().getService(PactSettingsState::class.java)
}
fun addAppSettingsStateListener(listener: AppSettingsStateListener) {
listeners.add(listener)
}
- fun notifyAppSettingsStateChanged(state: AppSettingsState) {
+ fun notifyAppSettingsStateChanged(state: PactSettingsState) {
for (listener in listeners) {
listener.onAppSettingsStateChanged(state)
}
}
interface AppSettingsStateListener {
- fun onAppSettingsStateChanged(state: AppSettingsState)
+ fun onAppSettingsStateChanged(state: PactSettingsState)
}
}
diff --git a/src/main/kotlin/io/kadena/pact/ide/settings/PactSettingsUtils.kt b/src/main/kotlin/io/kadena/pact/ide/settings/PactSettingsUtils.kt
new file mode 100644
index 0000000..e257349
--- /dev/null
+++ b/src/main/kotlin/io/kadena/pact/ide/settings/PactSettingsUtils.kt
@@ -0,0 +1,68 @@
+package io.kadena.pact.ide.settings
+
+import com.intellij.icons.AllIcons
+import com.intellij.openapi.fileChooser.FileChooser
+import com.intellij.openapi.fileChooser.FileChooserDescriptor
+import com.intellij.openapi.ui.ComboBox
+import com.intellij.openapi.vfs.LocalFileSystem
+import com.intellij.openapi.vfs.VirtualFile
+import com.intellij.ui.components.fields.ExtendableTextComponent
+import com.intellij.ui.components.fields.ExtendableTextField
+import java.awt.Dimension
+import javax.swing.JTextField
+import javax.swing.plaf.basic.BasicComboBoxEditor
+
+
+fun createComboBox(title: String, description: String): ComboBox {
+ val comboBox: ComboBox = ComboBox()
+
+ val browseExtension = ExtendableTextComponent.Extension.create(
+ AllIcons.General.OpenDisk, AllIcons.General.OpenDiskHover, "Browse files"
+ ) {
+ // Configure the file browser window
+ val fileChooserDescriptor = FileChooserDescriptor(
+ true,
+ false,
+ false,
+ false,
+ false,
+ false
+ )
+ .withTitle(title)
+ .withDescription(description)
+
+ // Set the initial file browser window directory
+ val directory = LocalFileSystem.getInstance().findFileByPath(
+ (comboBox.selectedItem as? String).takeIf { !it.isNullOrEmpty() } ?: System.getProperty("user.home")
+ )
+
+ // Open the file browser window
+ val file: VirtualFile? = FileChooser.chooseFile(fileChooserDescriptor, null, null, directory)
+
+ file?.let {
+ // Add the path to the ComboBox and select it
+ val path = it.path
+ comboBox.addItem(path)
+ comboBox.selectedItem = path
+ }
+ }
+
+ comboBox.apply {
+ isEnabled = true
+ isEditable = true
+ preferredSize = Dimension(300, preferredSize.height)
+ editor = object : BasicComboBoxEditor() {
+
+ override fun createEditorComponent(): JTextField {
+ val editor = ExtendableTextField().apply {
+ addExtension(browseExtension)
+ border = null
+ }
+
+ return editor
+ }
+ }
+ }
+
+ return comboBox
+}
diff --git a/src/main/kotlin/io/kadena/pact/lsp/PactLspServerDescriptor.kt b/src/main/kotlin/io/kadena/pact/lsp/PactLspServerDescriptor.kt
index bd47b5c..7c514e7 100644
--- a/src/main/kotlin/io/kadena/pact/lsp/PactLspServerDescriptor.kt
+++ b/src/main/kotlin/io/kadena/pact/lsp/PactLspServerDescriptor.kt
@@ -7,7 +7,7 @@ import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.platform.lsp.api.ProjectWideLspServerDescriptor
-import io.kadena.pact.ide.settings.AppSettingsState
+import io.kadena.pact.ide.settings.PactSettingsState
import java.io.File
class PactLspServerDescriptor(project: Project) : ProjectWideLspServerDescriptor(project, "Pact") {
@@ -32,32 +32,36 @@ class PactLspServerDescriptor(project: Project) : ProjectWideLspServerDescriptor
// return pluginPath?.let { Paths.get(it, executableRelativePath).toString() }
// }
- fun doesExecutableExist(executablePath: String): Boolean {
+ private fun doesExecutableExist(executablePath: String): Boolean {
val file = File(executablePath)
return file.exists() && file.isFile
}
+ private fun isIntegratedLanguageServer(): Boolean {
+ return PactSettingsState.instance.languageServerPath == PactSettingsState.instance.compilerPath
+ }
+
override fun isSupportedFile(file: VirtualFile) = file.extension == "pact"
override fun createCommandLine(): GeneralCommandLine {
// Retrieve the configured Pact Language Server executable path
- val pactLanguageServerPath = AppSettingsState.instance.pactLanguageServerPath
+ val languageServerPath = PactSettingsState.instance.languageServerPath
- if (pactLanguageServerPath == "" || !doesExecutableExist(pactLanguageServerPath)) {
+ if (languageServerPath == "" || !doesExecutableExist(languageServerPath)) {
throw ExecutionException("Pact Language Server (LSP) executable not found")
}
// Start the Pact Language Server
- return GeneralCommandLine(pactLanguageServerPath).apply {
+ return GeneralCommandLine(languageServerPath).apply {
withParentEnvironmentType(GeneralCommandLine.ParentEnvironmentType.CONSOLE)
withCharset(Charsets.UTF_8)
- addParameter("--stdio")
+ if (isIntegratedLanguageServer()) addParameter("--lsp")
}
}
override fun createInitializationOptions(): String {
// Retrieve the configured Pact executable path
- val pactPath = AppSettingsState.instance.pactPath
+ val pactPath = PactSettingsState.instance.compilerPath
val pactExe = JsonObject()
pactExe.addProperty("pactExe", pactPath)
diff --git a/src/main/kotlin/io/kadena/pact/lsp/PactLspServerSupportProvider.kt b/src/main/kotlin/io/kadena/pact/lsp/PactLspServerSupportProvider.kt
index 7c49db6..dc1f977 100644
--- a/src/main/kotlin/io/kadena/pact/lsp/PactLspServerSupportProvider.kt
+++ b/src/main/kotlin/io/kadena/pact/lsp/PactLspServerSupportProvider.kt
@@ -4,14 +4,14 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.platform.lsp.api.LspServerManager
import com.intellij.platform.lsp.api.LspServerSupportProvider
-import io.kadena.pact.ide.settings.AppSettingsState
+import io.kadena.pact.ide.settings.PactSettingsState
-class PactLspServerSupportProvider : LspServerSupportProvider, AppSettingsState.AppSettingsStateListener {
+class PactLspServerSupportProvider : LspServerSupportProvider, PactSettingsState.AppSettingsStateListener {
private var _project: Project? = null
init {
- val settings = AppSettingsState.instance
+ val settings = PactSettingsState.instance
settings.addAppSettingsStateListener(this)
}
@@ -26,7 +26,7 @@ class PactLspServerSupportProvider : LspServerSupportProvider, AppSettingsState.
}
}
- override fun onAppSettingsStateChanged(state: AppSettingsState) {
+ override fun onAppSettingsStateChanged(state: PactSettingsState) {
restart()
}
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index 6cb20c7..877dd31 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -18,12 +18,12 @@
+ serviceImplementation="io.kadena.pact.ide.settings.PactSettingsState"/>
diff --git a/src/main/resources/icons/logo.png b/src/main/resources/icons/logo.png
new file mode 100644
index 0000000..9b0dd92
Binary files /dev/null and b/src/main/resources/icons/logo.png differ