Added python syntax highlight support

This commit is contained in:
Abdelilah El Aissaoui 2024-07-15 02:53:25 +02:00
parent 284597cdeb
commit 1897845a37
No known key found for this signature in database
GPG Key ID: 7587FC860F594869
2 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,44 @@
package com.jetpackduba.gitnuro.ui.diff.syntax_highlighter
class PythonSyntaxHighlighter : SyntaxHighlighter() {
override fun loadKeywords(): List<String> = listOf(
"False",
"await",
"else",
"import",
"pass",
"None",
"break",
"except",
"in",
"raise",
"True",
"class",
"finally",
"is",
"return",
"and",
"continue",
"for",
"lambda",
"try",
"as",
"def",
"from",
"nonlocal",
"while",
"assert",
"del",
"global",
"not",
"with",
"async",
"elif",
"if",
"or",
"yield",
)
override fun isAnnotation(word: String): Boolean = word.startsWith("@")
override fun isComment(line: String): Boolean = line.startsWith("//")
}

View File

@ -77,4 +77,5 @@ private enum class HighlightLanguagesSupported(val extensions: List<String>, val
Kotlin(listOf("kt", "kts"), { KotlinSyntaxHighlighter() }),
Rust(listOf("rs"), { RustSyntaxHighlighter() }),
TypeScript(listOf("js", "jsx", "ts", "tsx", "vue", "astro"), { TypeScriptSyntaxHighlighter() }),
Python(listOf("py"), { PythonSyntaxHighlighter() }),
}