generated from JetBrains/intellij-platform-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add a custom JSON schema provider for Oxc config files (#66)
- Loading branch information
1 parent
1b77031
commit 5964246
Showing
4 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/com/github/iwanabethatguy/oxcintellijplugin/Constants.kt
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,7 @@ | ||
package com.github.iwanabethatguy.oxcintellijplugin | ||
|
||
object Constants { | ||
|
||
val CONFIG_FILES = listOf("oxlintrc.json", "oxlint.json", ".oxlintrc.json", ".oxlint.json", | ||
".oxlintrc") | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/kotlin/com/github/iwanabethatguy/oxcintellijplugin/OxcSchemaProviderFactory.kt
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,33 @@ | ||
package com.github.iwanabethatguy.oxcintellijplugin | ||
|
||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.vfs.VirtualFile | ||
import com.jetbrains.jsonSchema.extension.JsonSchemaFileProvider | ||
import com.jetbrains.jsonSchema.extension.JsonSchemaProviderFactory | ||
import com.jetbrains.jsonSchema.extension.SchemaType | ||
import com.jetbrains.jsonSchema.remote.JsonFileResolver | ||
import org.jetbrains.annotations.Nls | ||
|
||
class OxcSchemaProviderFactory : JsonSchemaProviderFactory { | ||
|
||
override fun getProviders(project: Project): List<JsonSchemaFileProvider?> { | ||
return listOf(object : JsonSchemaFileProvider { | ||
override fun isAvailable(file: VirtualFile): Boolean { | ||
return Constants.CONFIG_FILES.contains(file.name) | ||
} | ||
|
||
override fun getName(): @Nls String { | ||
return MyBundle.message("oxc.schema.name") | ||
} | ||
|
||
override fun getSchemaFile(): VirtualFile? { | ||
return JsonFileResolver.urlToFile( | ||
"https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxlint/configuration_schema.json") | ||
} | ||
|
||
override fun getSchemaType(): SchemaType { | ||
return SchemaType.remoteSchema | ||
} | ||
}) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
action.com.github.iwanabethatguy.oxcintellijplugin.actions.RestartLanguageServer.text=Restart Oxc Server | ||
|
||
oxc.name=Oxc | ||
oxc.schema.name=Oxc |