Skip to content

Commit

Permalink
Prototype LSP
Browse files Browse the repository at this point in the history
  • Loading branch information
JojOatXGME committed Sep 5, 2023
1 parent 4927f5c commit ab63a53
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:
strategy:
fail-fast: false
matrix:
jdk: [ 11 ]
jdk: [ 17 ]
include:
- jdk: 11
- jdk: 17
primary: true

steps:
Expand Down
5 changes: 3 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.grammarkit.tasks.GenerateLexerTask
import org.jetbrains.grammarkit.tasks.GenerateParserTask
import java.util.EnumSet

plugins {
// Java support
id("java")
// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
id("org.jetbrains.intellij") version "1.13.3"
id("org.jetbrains.intellij") version "1.15.0"
// gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
id("org.jetbrains.changelog") version "2.1.0"
// grammarkit - read more: https://github.com/JetBrains/gradle-grammar-kit-plugin
Expand Down Expand Up @@ -198,7 +199,7 @@ tasks {
}

runPluginVerifier {
failureLevel.set(org.jetbrains.intellij.tasks.RunPluginVerifierTask.FailureLevel.ALL)
failureLevel.set(EnumSet.complementOf(EnumSet.of(org.jetbrains.intellij.tasks.RunPluginVerifierTask.FailureLevel.EXPERIMENTAL_API_USAGES)))
}

publishPlugin {
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
pluginGroup = org.nixos.idea
pluginName = NixIDEA
pluginVersion = 0.4.0.11
pluginSinceBuild = 222
pluginSinceBuild = 232
pluginUntilBuild = 232.*

platformType = IC
platformVersion = 2022.2.5
platformType = IU
platformVersion = 2023.2.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
36 changes: 36 additions & 0 deletions src/main/java/org/nixos/idea/lsp/NixLspServerSupportProvider.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.nixos.idea.lsp;

import com.intellij.execution.ExecutionException;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.platform.lsp.api.LspServerSupportProvider;
import com.intellij.platform.lsp.api.ProjectWideLspServerDescriptor;
import org.jetbrains.annotations.NotNull;
import org.nixos.idea.file.NixFileType;

@SuppressWarnings("UnstableApiUsage")
public class NixLspServerSupportProvider implements LspServerSupportProvider {
@Override
public void fileOpened(@NotNull Project project, @NotNull VirtualFile virtualFile, @NotNull LspServerStarter lspServerStarter) {
if (virtualFile.getFileType() == NixFileType.INSTANCE) {
lspServerStarter.ensureServerStarted(new NixLspServerDescriptor(project));
}
}

private static final class NixLspServerDescriptor extends ProjectWideLspServerDescriptor {
public NixLspServerDescriptor(@NotNull Project project) {
super(project, "nix --extra-experimental-features nix-command --extra-experimental-features flakes run nixpkgs#nixd");
}

@Override
public @NotNull GeneralCommandLine createCommandLine() throws ExecutionException {
return new GeneralCommandLine();
}

@Override
public boolean isSupportedFile(@NotNull VirtualFile virtualFile) {
return virtualFile.getFileType() == NixFileType.INSTANCE;
}
}
}
4 changes: 4 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<vendor>NixOS</vendor>

<depends>com.intellij.modules.lang</depends>
<depends>com.intellij.modules.platform</depends>

<extensions defaultExtensionNs="com.intellij">

Expand Down Expand Up @@ -46,6 +47,9 @@
<colorSettingsPage
implementation="org.nixos.idea.settings.NixColorSettingsPage" />

<platform.lsp.serverSupportProvider
implementation="org.nixos.idea.lsp.NixLspServerSupportProvider"/>

</extensions>

</idea-plugin>

0 comments on commit ab63a53

Please sign in to comment.