-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add LSP support (#68) [paid versions of IDEA only]
- Loading branch information
1 parent
27d2110
commit ad0b924
Showing
6 changed files
with
66 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/org/nixos/idea/lsp/NixLspServerDescriptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
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.ProjectWideLspServerDescriptor; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.nixos.idea.file.NixFileType; | ||
|
||
@SuppressWarnings("UnstableApiUsage") | ||
final class NixLspServerDescriptor extends ProjectWideLspServerDescriptor { | ||
NixLspServerDescriptor(@NotNull Project project) { | ||
super(project, "Nix"); | ||
} | ||
|
||
@Override | ||
public @NotNull GeneralCommandLine createCommandLine() throws ExecutionException { | ||
return new GeneralCommandLine("nix", "--extra-experimental-features", "nix-command", "--extra-experimental-features", "flakes", "run", "nixpkgs#nil"); | ||
} | ||
|
||
@Override | ||
public boolean isSupportedFile(@NotNull VirtualFile virtualFile) { | ||
return virtualFile.getFileType() == NixFileType.INSTANCE; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/org/nixos/idea/lsp/NixLspServerSupportProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.nixos.idea.lsp; | ||
|
||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.vfs.VirtualFile; | ||
import com.intellij.platform.lsp.api.LspServer; | ||
import com.intellij.platform.lsp.api.LspServerSupportProvider; | ||
import com.intellij.platform.lsp.api.lsWidget.LspServerWidgetItem; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.nixos.idea.file.NixFileType; | ||
import org.nixos.idea.icon.NixIcons; | ||
|
||
@SuppressWarnings("UnstableApiUsage") | ||
public final 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)); | ||
} | ||
} | ||
|
||
@Override | ||
public @NotNull LspServerWidgetItem createLspServerWidgetItem(@NotNull LspServer lspServer, @Nullable VirtualFile currentFile) { | ||
return new LspServerWidgetItem(lspServer, currentFile, NixIcons.FILE, null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters