Pygments Nightfox Style
This commit is contained in:
parent
d2d6d35861
commit
2bb7c431b3
2 changed files with 367 additions and 0 deletions
220
pygments_nightfox_style/__init__.py
Normal file
220
pygments_nightfox_style/__init__.py
Normal file
|
@ -0,0 +1,220 @@
|
||||||
|
"""
|
||||||
|
Pygments Nightfox style
|
||||||
|
=======================
|
||||||
|
Palette from: https://github.com/EdenEast/nightfox.nvim
|
||||||
|
|
||||||
|
:copyright: Copyright 2023 by kujiu, EdenEast
|
||||||
|
:license: MIT, see LICENSE for details.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from pygments.style import Style
|
||||||
|
from pygments.token import Keyword, Name, Other, Comment, String, Error, Number, \
|
||||||
|
Operator, Generic, Whitespace, Punctuation, Escape, Literal, Text, Token
|
||||||
|
|
||||||
|
from typing import Dict, Any
|
||||||
|
|
||||||
|
|
||||||
|
# Normal
|
||||||
|
NFOX_BLACK = "#393b44"
|
||||||
|
NFOX_RED = "#c94f6d"
|
||||||
|
NFOX_GREEN = "#81b29a"
|
||||||
|
NFOX_YELLOW = "#dbc074"
|
||||||
|
NFOX_BLUE = "#719cd6"
|
||||||
|
NFOX_MAGENTA = "#9d79d6"
|
||||||
|
NFOX_CYAN = "#63cdcf"
|
||||||
|
NFOX_WHITE = "#dfdfe0"
|
||||||
|
NFOX_ORANGE = "#f4a261"
|
||||||
|
NFOX_PINK = "#d67ad2"
|
||||||
|
|
||||||
|
NFOX_COMMENT = "#738091"
|
||||||
|
|
||||||
|
NFOX_BG0 = "#131a24"
|
||||||
|
NFOX_BG1 = "#192330"
|
||||||
|
NFOX_BG2 = "#212e3f"
|
||||||
|
NFOX_BG3 = "#29394f"
|
||||||
|
NFOX_BG4 = "#39506d"
|
||||||
|
|
||||||
|
NFOX_FG0 = "#d6d6d7"
|
||||||
|
NFOX_FG1 = "#cdcecf"
|
||||||
|
NFOX_FG2 = "#aeafb0"
|
||||||
|
NFOX_FG3 = "#71839b"
|
||||||
|
|
||||||
|
NFOX_SEL0 = "#2b3b51"
|
||||||
|
NFOX_SEL1 = "#3c5372"
|
||||||
|
|
||||||
|
# Darker
|
||||||
|
NFOX_BLACK_D = "#13151e"
|
||||||
|
NFOX_RED_D = "#a32947"
|
||||||
|
NFOX_GREEN_D = "#5b8c74"
|
||||||
|
NFOX_YELLOW_D = "#b59a4e"
|
||||||
|
NFOX_BLUE_D = "#4b76b0"
|
||||||
|
NFOX_MAGENTA_D = "#7753b0"
|
||||||
|
NFOX_CYAN_D = "#3da7a9"
|
||||||
|
NFOX_WHITE_D = "#b9b9ba"
|
||||||
|
NFOX_ORANGE_D = "#ce7c3b"
|
||||||
|
NFOX_PINK_D = "#b054ac"
|
||||||
|
|
||||||
|
#Lighter
|
||||||
|
NFOX_BLACK_L = "#5F616A"
|
||||||
|
NFOX_RED_L = "#ef7593"
|
||||||
|
NFOX_GREEN_L = "#9bccb4"
|
||||||
|
NFOX_YELLOW_L = "#ffe69a"
|
||||||
|
NFOX_BLUE_L = "#97c2fc"
|
||||||
|
NFOX_MAGENTA_L = "#eac6ff"
|
||||||
|
NFOX_CYAN_L = "#89f3f5"
|
||||||
|
NFOX_WHITE_L = "#ffffff"
|
||||||
|
NFOX_ORANGE_L = "#ffc887"
|
||||||
|
NFOX_PINK_L = "#fca0f8"
|
||||||
|
|
||||||
|
def get_styles(background_color: str) -> Dict[Any, str]:
|
||||||
|
return {
|
||||||
|
Comment.Hashbang: NFOX_FG2,
|
||||||
|
Comment.Multiline: NFOX_COMMENT,
|
||||||
|
Comment.Preproc: NFOX_PINK_L,
|
||||||
|
Comment.PreprocFile: NFOX_PINK_L,
|
||||||
|
Comment.Single: NFOX_COMMENT,
|
||||||
|
Comment.Special: NFOX_COMMENT + " bold",
|
||||||
|
Comment: NFOX_COMMENT,
|
||||||
|
Error: NFOX_RED,
|
||||||
|
Escape: NFOX_RED_L,
|
||||||
|
Generic.Deleted: NFOX_RED,
|
||||||
|
Generic.Emph: "italic",
|
||||||
|
Generic.Error: NFOX_RED,
|
||||||
|
Generic.Heading: "bold " + NFOX_CYAN,
|
||||||
|
Generic.Inserted: NFOX_GREEN,
|
||||||
|
Generic.Output: NFOX_FG1,
|
||||||
|
Generic.Prompt: NFOX_BLUE,
|
||||||
|
Generic.Strong: "bold",
|
||||||
|
Generic.Subheading: "italic " + NFOX_GREEN,
|
||||||
|
Generic.Traceback: NFOX_RED_D,
|
||||||
|
Generic.Underline: "underline",
|
||||||
|
Generic: NFOX_FG1 + " bg:" + background_color,
|
||||||
|
Keyword.Constant: NFOX_MAGENTA,
|
||||||
|
Keyword.Declaration: NFOX_MAGENTA,
|
||||||
|
Keyword.Namespace: NFOX_MAGENTA,
|
||||||
|
Keyword.Pseudo: NFOX_MAGENTA,
|
||||||
|
Keyword.Reserved: NFOX_MAGENTA,
|
||||||
|
Keyword.Type: NFOX_YELLOW,
|
||||||
|
Keyword: NFOX_MAGENTA,
|
||||||
|
Literal.Date: NFOX_GREEN_D,
|
||||||
|
Literal: NFOX_GREEN_D,
|
||||||
|
Name.Attribute: NFOX_BLUE,
|
||||||
|
Name.BackslashReference: NFOX_ORANGE,
|
||||||
|
Name.Builtin.Articulation: NFOX_CYAN_L,
|
||||||
|
Name.Builtin.Clef: NFOX_MAGENTA,
|
||||||
|
Name.Builtin.Context: "bold " + NFOX_CYAN_L,
|
||||||
|
Name.Builtin.ContextProperty: NFOX_CYAN,
|
||||||
|
Name.Builtin.Dynamic: NFOX_ORANGE_L,
|
||||||
|
Name.Builtin.Grob: "bold " + NFOX_RED_L,
|
||||||
|
Name.Builtin.GrobProperty: NFOX_ORANGE,
|
||||||
|
Name.Builtin.HeaderVariable: NFOX_ORANGE_L,
|
||||||
|
Name.Builtin.MarkupCommand: NFOX_BLUE_L,
|
||||||
|
Name.Builtin.MusicCommand: NFOX_MAGENTA,
|
||||||
|
Name.Builtin.MusicFunction: NFOX_BLUE_L,
|
||||||
|
Name.Builtin.PaperVariable: NFOX_CYAN_L,
|
||||||
|
Name.Builtin.Pseudo: NFOX_CYAN_L,
|
||||||
|
Name.Builtin.RepeatType: NFOX_ORANGE_L,
|
||||||
|
Name.Builtin.Scale: NFOX_RED_L,
|
||||||
|
Name.Builtin.SchemeBuiltin: "bold " + NFOX_BLUE_L,
|
||||||
|
Name.Builtin.SchemeFunction: NFOX_BLUE_L,
|
||||||
|
Name.Builtin.Translator: NFOX_ORANGE_L,
|
||||||
|
Name.Builtin: NFOX_CYAN_L,
|
||||||
|
Name.Class: NFOX_BLUE_L,
|
||||||
|
Name.Constant: NFOX_ORANGE_L,
|
||||||
|
Name.Decorator: NFOX_PINK,
|
||||||
|
Name.Entity: NFOX_GREEN,
|
||||||
|
Name.Exception: NFOX_RED,
|
||||||
|
Name.Function.Magic: NFOX_BLUE_L,
|
||||||
|
Name.Function: NFOX_BLUE_L,
|
||||||
|
Name.Label: NFOX_WHITE,
|
||||||
|
Name.Lvalue: NFOX_GREEN,
|
||||||
|
Name.Namespace: NFOX_WHITE,
|
||||||
|
Name.Other: NFOX_FG1,
|
||||||
|
Name.Property: NFOX_BLUE,
|
||||||
|
Name.Tag: NFOX_ORANGE,
|
||||||
|
Name.Variable.Class: NFOX_WHITE,
|
||||||
|
Name.Variable.Global: NFOX_WHITE,
|
||||||
|
Name.Variable.Instance: NFOX_ORANGE,
|
||||||
|
Name.Variable.Magic: NFOX_RED,
|
||||||
|
Name.Variable: NFOX_WHITE,
|
||||||
|
Name: NFOX_YELLOW,
|
||||||
|
Number.Bin: NFOX_ORANGE_D,
|
||||||
|
Number.Float: NFOX_ORANGE,
|
||||||
|
Number.Hex: NFOX_ORANGE_D,
|
||||||
|
Number.Integer.Long: NFOX_ORANGE,
|
||||||
|
Number.Integer: NFOX_ORANGE,
|
||||||
|
Number.Oct: NFOX_ORANGE,
|
||||||
|
Number: NFOX_ORANGE,
|
||||||
|
Operator.Word: NFOX_FG2,
|
||||||
|
Operator: NFOX_FG2,
|
||||||
|
Other: NFOX_FG1 + " bg:" + background_color,
|
||||||
|
String.Affix: NFOX_GREEN,
|
||||||
|
String.Backtick: NFOX_GREEN,
|
||||||
|
String.Char: NFOX_GREEN,
|
||||||
|
String.Delimiter: NFOX_GREEN_D,
|
||||||
|
String.Doc: NFOX_GREEN_L,
|
||||||
|
String.Double: NFOX_GREEN,
|
||||||
|
String.Escape: NFOX_GREEN_D,
|
||||||
|
String.Heredoc: NFOX_GREEN,
|
||||||
|
String.Interpol: NFOX_GREEN,
|
||||||
|
String.Other: NFOX_GREEN,
|
||||||
|
String.Regex: NFOX_YELLOW_L,
|
||||||
|
String.Single: NFOX_GREEN,
|
||||||
|
String.Symbol: NFOX_GREEN_D,
|
||||||
|
String: NFOX_GREEN,
|
||||||
|
Text: NFOX_FG1 + " bg:" + background_color,
|
||||||
|
Token: NFOX_FG1 + " bg:" + background_color,
|
||||||
|
|
||||||
|
Text.Whitespace: NFOX_FG1 + " bg:" + background_color,
|
||||||
|
Whitespace: NFOX_FG1 + " bg:" + background_color,
|
||||||
|
Punctuation.Marker: NFOX_FG2,
|
||||||
|
Punctuation: NFOX_FG2,
|
||||||
|
|
||||||
|
Token.Pitch: NFOX_BLUE,
|
||||||
|
Token.ChordModifier: NFOX_ORANGE,
|
||||||
|
|
||||||
|
#Special tokens for customized IPython Prompt
|
||||||
|
Token.IPython.Prompt.Login: NFOX_BG0 + " bg:" + NFOX_CYAN,
|
||||||
|
Token.IPython.Prompt.Login.Sep: NFOX_CYAN + " bg:" + NFOX_BLUE,
|
||||||
|
Token.IPython.Prompt.Host: NFOX_BG0 + " bg:" + NFOX_BLUE,
|
||||||
|
Token.IPython.Prompt.Host.Sep: NFOX_BLUE + " bg:" + NFOX_FG3,
|
||||||
|
Token.IPython.Prompt.Venv: NFOX_BG0 + " bg:" + NFOX_FG3,
|
||||||
|
Token.IPython.Prompt.Venv.Sep: NFOX_FG3 + " bg:" + NFOX_GREEN,
|
||||||
|
Token.IPython.Prompt.Version: NFOX_BG0 + " bg:" + NFOX_GREEN,
|
||||||
|
Token.IPython.Prompt.Version.Sep: "bg: " + NFOX_GREEN,
|
||||||
|
Token.IPython.Prompt.Cwd: NFOX_BG0 + " bg:" + NFOX_GREEN,
|
||||||
|
Token.IPython.Prompt.Cwd.Sep: NFOX_GREEN + " bg:" + NFOX_BG2,
|
||||||
|
Token.IPython.Prompt.Vcs: NFOX_ORANGE + " bg:" + NFOX_BG2,
|
||||||
|
Token.IPython.Prompt.Vcs.Sep: "bg: " + NFOX_BG2,
|
||||||
|
Token.IPython.Prompt.Mode: NFOX_BG0 + " bg:" + NFOX_GREEN,
|
||||||
|
Token.IPython.Prompt.Mode.Sep: "bg: " + NFOX_GREEN,
|
||||||
|
}
|
||||||
|
|
||||||
|
class NightfoxStyle(Style):
|
||||||
|
"""
|
||||||
|
Pygments Nightfox Style
|
||||||
|
"""
|
||||||
|
line_number_color = NFOX_FG3
|
||||||
|
line_number_background_color = NFOX_BG2
|
||||||
|
line_number_special_color = NFOX_SEL0
|
||||||
|
line_number_special_background_color = NFOX_SEL1
|
||||||
|
|
||||||
|
background_color = NFOX_BG1
|
||||||
|
highlight_color = NFOX_SEL0
|
||||||
|
|
||||||
|
styles = get_styles(background_color)
|
||||||
|
|
||||||
|
|
||||||
|
class NightfoxTransparentStyle(Style):
|
||||||
|
"""
|
||||||
|
Pygments Nightfox Style
|
||||||
|
"""
|
||||||
|
line_number_color = NFOX_FG3
|
||||||
|
line_number_background_color = NFOX_BG2
|
||||||
|
line_number_special_color = NFOX_SEL0
|
||||||
|
line_number_special_background_color = NFOX_SEL1
|
||||||
|
|
||||||
|
background_color = "transparent"
|
||||||
|
highlight_color = NFOX_SEL0
|
||||||
|
|
||||||
|
styles = get_styles("")
|
147
pyproject.toml
Normal file
147
pyproject.toml
Normal file
|
@ -0,0 +1,147 @@
|
||||||
|
[build-system]
|
||||||
|
requires = ["flit_core>=3.2"]
|
||||||
|
build-backend = "flit_core.buildapi"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "pygments_nightfox_style"
|
||||||
|
version = "1.0.0"
|
||||||
|
requires-python = ">=3.8"
|
||||||
|
dependencies = [
|
||||||
|
"pygments"
|
||||||
|
]
|
||||||
|
license = {text = "MIT"}
|
||||||
|
authors = [
|
||||||
|
{name = "Nerv Project ASBL", email = "contact@nerv-project.eu"},
|
||||||
|
{name = "kujiu"},
|
||||||
|
{name = "ptitgnu"}
|
||||||
|
]
|
||||||
|
maintainers = [
|
||||||
|
{name = "Nerv Project ASBL", email = "contact@nerv-project.eu"},
|
||||||
|
{name = "kujiu"},
|
||||||
|
{name = "ptitgnu"}
|
||||||
|
]
|
||||||
|
description = "Nightfox pigments theme based on nightfox.vim (by EdenEast)"
|
||||||
|
readme = {file = "README.rst", content-type = "text/x-rst"}
|
||||||
|
keywords=["pygments", "nightfox", "style"]
|
||||||
|
classifiers=[
|
||||||
|
"Development Status :: 5 - Production/Stable",
|
||||||
|
"Programming Language :: Python :: 3",
|
||||||
|
"Operating System :: OS Independent",
|
||||||
|
"Topic :: Documentation",
|
||||||
|
"Topic :: Software Development :: Documentation",
|
||||||
|
"Intended Audience :: Developers",
|
||||||
|
"License :: OSI Approved :: MIT License",
|
||||||
|
]
|
||||||
|
|
||||||
|
[project.urls]
|
||||||
|
homepage = "https://www.nerv-project.eu"
|
||||||
|
repository = "https://procrastinator.nerv-project.eu/kujiu/pygments_nightfox_style"
|
||||||
|
issues = "https://procrastinator.nerv-project.eu/kujiu/pygments_nightfox_style/issues"
|
||||||
|
editor = "https://www.nerv-project.eu"
|
||||||
|
changelog = "https://procrastinator.nerv-project.eu/kujiu/pygments_nightfox_style/raw/branch/main/CHANGES.rst"
|
||||||
|
|
||||||
|
[project.optional-dependencies]
|
||||||
|
tests = [
|
||||||
|
"pytest",
|
||||||
|
"pyright",
|
||||||
|
"pylint",
|
||||||
|
"pytest-cov"
|
||||||
|
]
|
||||||
|
setup = [
|
||||||
|
"pygments",
|
||||||
|
"pyright",
|
||||||
|
"pylint",
|
||||||
|
"flit",
|
||||||
|
]
|
||||||
|
|
||||||
|
[project.scripts]
|
||||||
|
|
||||||
|
[project.entry-points."pygments.styles"]
|
||||||
|
nightfox = "pygments_nightfox_style:NightfoxStyle"
|
||||||
|
nightfox_transparent = "pygments_nightfox_style:NightfoxTransparentStyle"
|
||||||
|
|
||||||
|
[tool.pytest.ini_options]
|
||||||
|
minversion = "6.0"
|
||||||
|
addopts = "-ra -q"
|
||||||
|
testpaths = [
|
||||||
|
"tests",
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.flit.sdist]
|
||||||
|
include = [
|
||||||
|
"*.py",
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.pyright]
|
||||||
|
analyzeUnannotatedFunctions = true
|
||||||
|
deprecateTypingAliases = true
|
||||||
|
enableExperimentalFeatures = false
|
||||||
|
enableTypeIgnoreComments = false
|
||||||
|
reportAssertAlwaysTrue = "warning"
|
||||||
|
reportCallInDefaultInitializer = "information"
|
||||||
|
reportConstantRedefinition = "warning"
|
||||||
|
reportDeprecated = "warning"
|
||||||
|
reportDuplicateImport = "warning"
|
||||||
|
reportFunctionMemberAccess = "warning"
|
||||||
|
reportGeneralTypeIssues = "error"
|
||||||
|
reportImplicitOverride = "warning"
|
||||||
|
reportImplicitStringConcatenation = "information"
|
||||||
|
reportImportCycles = "error"
|
||||||
|
reportIncompatibleMethodOverride = "warning"
|
||||||
|
reportIncompatibleVariableOverride = "warning"
|
||||||
|
reportIncompleteStub = "warning"
|
||||||
|
reportInconsistentConstructor = "warning"
|
||||||
|
reportInvalidStringEscapeSequence = "error"
|
||||||
|
reportInvalidStubStatement = "warning"
|
||||||
|
reportInvalidTypeVarUse = "warning"
|
||||||
|
reportMatchNotExhaustive = "warning"
|
||||||
|
reportMissingImports = "error"
|
||||||
|
reportMissingModuleSource = "warning"
|
||||||
|
reportMissingParameterType = "error"
|
||||||
|
reportMissingSuperCall = "warning"
|
||||||
|
reportMissingTypeArgument = "error"
|
||||||
|
reportMissingTypeStubs = "warning"
|
||||||
|
reportOptionalCall = "error"
|
||||||
|
reportOptionalContextManager = "error"
|
||||||
|
reportOptionalIterable = "error"
|
||||||
|
reportOptionalMemberAccess = "error"
|
||||||
|
reportOptionalOperand = "error"
|
||||||
|
reportOptionalSubscript = "error"
|
||||||
|
reportOverlappingOverload = "warning"
|
||||||
|
reportPrivateImportUsage = "error"
|
||||||
|
reportPrivateUsage = "warning"
|
||||||
|
reportPropertyTypeMismatch = "error"
|
||||||
|
reportSelfClsParameterName = "error"
|
||||||
|
reportShadowedImports = "warning"
|
||||||
|
reportTypeCommentUsage = "warning"
|
||||||
|
reportTypedDictNotRequiredAccess = "error"
|
||||||
|
reportUnboundVariable = "error"
|
||||||
|
reportUndefinedVariable = "error"
|
||||||
|
reportUninitializedInstanceVariable = "warning"
|
||||||
|
reportUnknownArgumentType = "error"
|
||||||
|
reportUnknownLambdaType = "error"
|
||||||
|
reportUnknownMemberType = "error"
|
||||||
|
reportUnknownParameterType = "error"
|
||||||
|
reportUnknownVariableType = "error"
|
||||||
|
reportUnnecessaryCast = "warning"
|
||||||
|
reportUnnecessaryComparison = "warning"
|
||||||
|
reportUnnecessaryContains = "warning"
|
||||||
|
reportUnnecessaryIsInstance = "warning"
|
||||||
|
reportUnnecessaryTypeIgnoreComment = "warning"
|
||||||
|
reportUnsupportedDunderAll = "warning"
|
||||||
|
reportUntypedBaseClass = "error"
|
||||||
|
reportUntypedClassDecorator = "error"
|
||||||
|
reportUntypedFunctionDecorator = "error"
|
||||||
|
reportUntypedNamedTuple = "error"
|
||||||
|
reportUnusedCallResult = "warning"
|
||||||
|
reportUnusedClass = "information"
|
||||||
|
reportUnusedCoroutine = "error"
|
||||||
|
reportUnusedExpression = "warning"
|
||||||
|
reportUnusedFunction = "information"
|
||||||
|
reportUnusedImport = "information"
|
||||||
|
reportUnusedVariable = "warning"
|
||||||
|
reportWildcardImportFromLibrary = "error"
|
||||||
|
strictDictionaryInference = true
|
||||||
|
strictListInference = true
|
||||||
|
strictParameterNoneValue = true
|
||||||
|
strictSetInference = true
|
Loading…
Reference in a new issue