diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 3272bf1..94a25f7 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -2,6 +2,5 @@
-
\ No newline at end of file
diff --git a/src/main/kotlin/org/gregorybednov/clsp/CLanguage.kt b/src/main/kotlin/org/gregorybednov/clsp/CLanguage.kt
new file mode 100644
index 0000000..ea844fd
--- /dev/null
+++ b/src/main/kotlin/org/gregorybednov/clsp/CLanguage.kt
@@ -0,0 +1,65 @@
+package org.gregorybednov.clsp
+
+import com.intellij.execution.configurations.GeneralCommandLine
+import com.intellij.lang.Language
+import com.intellij.notification.NotificationGroupManager
+import com.intellij.notification.NotificationType
+import com.intellij.openapi.fileTypes.LanguageFileType
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.util.IconLoader.getIcon
+import com.intellij.util.EnvironmentUtil
+import com.redhat.devtools.lsp4ij.LanguageServerFactory
+import com.redhat.devtools.lsp4ij.LanguageServerManager
+import com.redhat.devtools.lsp4ij.server.OSProcessStreamConnectionProvider
+import com.redhat.devtools.lsp4ij.server.StreamConnectionProvider
+import javax.swing.Icon
+import org.jetbrains.annotations.NotNull
+import java.io.File
+import java.nio.file.Paths
+import kotlin.io.path.pathString
+
+object CLanguage : Language("C") {
+ private fun readResolve(): Any = CLanguage
+ val INSTANCE: CLanguage = CLanguage
+}
+
+object CIcon {
+ val FILE: Icon = getIcon("/icons/clogo.svg", CIcon::class.java)
+}
+
+class CFileType private constructor() : LanguageFileType(CLanguage.INSTANCE) {
+ override fun getName(): String { return "C File" }
+ override fun getDescription(): String { return "C language file" }
+ override fun getDefaultExtension(): String { return "c" }
+ override fun getIcon(): Icon { return CIcon.FILE }
+ companion object { val INSTANCE: CFileType = CFileType() }
+}
+
+class CLanguageServer(project: Project) : OSProcessStreamConnectionProvider() {
+ private fun findExecutableInPATH(executable: String) =
+ EnvironmentUtil.getEnvironmentMap().values.flatMap { it.split(File.pathSeparator) }
+ .map { File(Paths.get(it, executable).pathString) }.find { it.exists() && it.canExecute() }?.path
+
+ init {
+ val clangdPath = findExecutableInPATH("clangd")
+ if (clangdPath.isNullOrEmpty()) {
+ NotificationGroupManager.getInstance().getNotificationGroup("C/C++ notifications").createNotification(
+ "C LSP",
+ "LSP server clangd not found. Make sure it is installed properly (and is available in PATH)," +
+ "and restart the IDE.",
+ NotificationType.ERROR).notify(project)
+ LanguageServerManager.getInstance(project).stop("CLanguageServer")
+ } else {
+ val commandLine = GeneralCommandLine("clangd")
+ commandLine.setWorkDirectory(project.basePath)
+ super.setCommandLine(commandLine)
+ }
+ }
+}
+
+class CLanguageServerFactory : LanguageServerFactory {
+ @NotNull
+ override fun createConnectionProvider(project: Project): StreamConnectionProvider {
+ return CLanguageServer(project)
+ }
+}
diff --git a/src/main/kotlin/org/gregorybednov/clsp/CTextMateBundleProvider.kt b/src/main/kotlin/org/gregorybednov/clsp/CTextMateBundleProvider.kt
deleted file mode 100644
index ba511e5..0000000
--- a/src/main/kotlin/org/gregorybednov/clsp/CTextMateBundleProvider.kt
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.gregorybednov.clsp
-
-import org.jetbrains.plugins.textmate.api.TextMateBundleProvider
-import org.jetbrains.plugins.textmate.api.TextMateBundleProvider.PluginBundle
-import kotlin.io.path.Path
-
-class CTextMateBundleProvider : TextMateBundleProvider {
- override fun getBundles(): List {
- return listOf(
- PluginBundle("c/c++", Path("/Users/gregorybednov/Downloads/better-cpp-syntax"))
- )
- }
-}
\ No newline at end of file
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index 1813763..177e38d 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -42,9 +42,6 @@
-
-
-
diff --git a/src/main/resources/icons/clogo.svg b/src/main/resources/icons/clogo.svg
new file mode 100644
index 0000000..591e246
--- /dev/null
+++ b/src/main/resources/icons/clogo.svg
@@ -0,0 +1,38 @@
+
diff --git a/src/main/resources/icons/cpplogo.svg b/src/main/resources/icons/cpplogo.svg
index 71f3958..8a246c9 100644
--- a/src/main/resources/icons/cpplogo.svg
+++ b/src/main/resources/icons/cpplogo.svg
@@ -4,20 +4,20 @@
width="16" height="16" viewBox="0 0 306 344.35" enable-background="new 0 0 306 344.35" xml:space="preserve">
-
-
-
+
-
+
-
+