-
-
Save yasudacloud/c7c80f1a2f09fc135c96d57d10c0bc69 to your computer and use it in GitHub Desktop.
ex) IntelliJ LSP Plugin for Terraform
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
package com.example.demo1 | |
import com.intellij.execution.configurations.GeneralCommandLine | |
import com.intellij.openapi.project.Project | |
import com.intellij.openapi.vfs.VirtualFile | |
import com.intellij.platform.lsp.api.* | |
class FooLspServerSupportProvider : LspServerSupportProvider { | |
override fun fileOpened( | |
project: Project, | |
file: VirtualFile, | |
serverStarter: LspServerSupportProvider.LspServerStarter | |
) { | |
if (file.extension == "tf") { | |
serverStarter.ensureServerStarted(FooLspServerDescriptor(project)) | |
} | |
} | |
} | |
private class FooLspServerDescriptor(project: Project) : ProjectWideLspServerDescriptor(project, "Foo") { | |
override val lspGoToDefinitionSupport = false | |
override fun isSupportedFile(file: VirtualFile) = file.extension == "tf" | |
override fun createCommandLine(): GeneralCommandLine { | |
val commandLine = GeneralCommandLine() | |
commandLine.withExePath("terraform-ls") | |
commandLine.addParameters( | |
"serve", | |
) | |
return commandLine | |
} | |
override fun getLanguageId(file: VirtualFile): String { | |
return "terraform" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment