Added python syntax highlight support
This commit is contained in:
parent
284597cdeb
commit
1897845a37
@ -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("//")
|
||||||
|
}
|
@ -77,4 +77,5 @@ private enum class HighlightLanguagesSupported(val extensions: List<String>, val
|
|||||||
Kotlin(listOf("kt", "kts"), { KotlinSyntaxHighlighter() }),
|
Kotlin(listOf("kt", "kts"), { KotlinSyntaxHighlighter() }),
|
||||||
Rust(listOf("rs"), { RustSyntaxHighlighter() }),
|
Rust(listOf("rs"), { RustSyntaxHighlighter() }),
|
||||||
TypeScript(listOf("js", "jsx", "ts", "tsx", "vue", "astro"), { TypeScriptSyntaxHighlighter() }),
|
TypeScript(listOf("js", "jsx", "ts", "tsx", "vue", "astro"), { TypeScriptSyntaxHighlighter() }),
|
||||||
|
Python(listOf("py"), { PythonSyntaxHighlighter() }),
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user